15.05.2016, 16:03
Hi again. I have a question: I want to test my code. Everything was fine, I created "mock" implementations of Player, Vehicle, etc, to use in tests. Now, the problem is that everytime I get a NullPointerException when I use commons dialogs. Why? Because dialogs uses SampObjectManager.get() to be created.
Seeing the impl, it just asks to Shoebill.get().getSampObjectManager. Now my question: How can I inject my "own" instance of shoebill? I need to create a "mock" instance to test everything, like this:
to decouple shoebill from runtime dependencies. My first idea was to use a proxy, then intercept shoebill "get". However, I dont know if its possible to intercept interface default methods.
Seeing the impl, it just asks to Shoebill.get().getSampObjectManager. Now my question: How can I inject my "own" instance of shoebill? I need to create a "mock" instance to test everything, like this:
PHP код:
class MockShoebill implements Shoebill {
...
@Override
public SampObjectManager getObjectManager() {
return new SampObjectManager() {
createDialogId(..) {
return MockDialogId(..);
}
}
}
...
}

