It works, I can see that UiUtils is now filled up. However calling ui.contextPath() still returns a null string. Is there a way to set this up somewhere, again this is for the sake of a unit test.
@dkayiwa / @mksd, perhaps the right solution for these unit tests is to put something like this in an @Before method, rather than try to recreate the logic:
UiFrameworkActivator activator = new UiFrameworkActivator();
activator.contextRefreshed();
Thanks @mseaton for throwing yet another idea.
In the context of my tests I needed really little out of UiUtils, there would only be calls to
UiUtils#contextPath()
UiUtils#toJson(Object)
The former can be dealth with a mock, but I needed an actual instance of UiUtils for the latter.
I guess your suggestion implies that, after those instructions, I will be in a position to call new BasicUiUtils(), correct? And the context path will set as well as anything else.
That’s quite a nifty one, it could totally work in my current use case. We tend to forget about inline overrides as we are stuck in DI and forbidden to use new!