Код: Выделить всё
public interface MyHandler {
void handle(S t1, T t2);
}
Код: Выделить всё
public class MyFirstConcreteHandler implements MyHandler{
// implementation
}
Ниже приведен мой фабричный класс
Код: Выделить всё
public class MyHandlerFactory {
Map myHandlers;
public MyHandler getHandler(String key) {
// myhandlers will be populated in constructor
return myHandlers.get(key.toLowerCase());
}
}
Код: Выделить всё
MyHandlerFactory myHandlerFactory = mock(MyHandlerFactory.class)
MyFirstConcreteHandler mockHandler = mock(MyFirstConcreteHandler.class);
when(myHandlerFactory.getHandler("random")).thenReturn(mockHandler);
Код: Выделить всё
Cannot resolve method 'thenReturn(MyConcreteHandler)'
Подробнее здесь: https://stackoverflow.com/questions/793 ... ng-mockito