How can we mock the IRouteHandlerRegistry? The error is Cannot resolve method thenReturn(IHandleRoute<TestRoute>)
public interface RouteDefinition { } public class TestRoute implements RouteDefinition { } public interface IHandleRoute<TRoute extends RouteDefinition> { Route getHandlerFor(TRoute route); } public interface IRouteHandlerRegistry { <TRoute extends RouteDefinition> IHandleRoute<TRoute> getHandlerFor(TRoute route); } @Test @SuppressWarnings("unchecked") public void test() { // in my test RouteDefinition route = new TestRoute(); // TestRoute implements RouteDefinition IRouteHandlerRegistry registry = mock(IRouteHandlerRegistry.class); IHandleRoute<TestRoute> handler = mock(IHandleRoute.class); // Error: Cannot resolve method 'thenReturn(IHandleRoute<TestRoute>)' when(registry.getHandlerFor(route)).thenReturn(handler); }
SutFactory?