How to mock generic method in Java with Mockito?

前端 未结 3 2330
生来不讨喜
生来不讨喜 2021-02-15 17:09

How can we mock the IRouteHandlerRegistry? The error is Cannot resolve method thenReturn(IHandleRoute)

public interfac         


        
3条回答
  •  没有蜡笔的小新
    2021-02-15 17:37

    If you write like this it will be ok:

    Mockito.doReturn(handler).when(registry).getHandlerFor(Mockito.any(route.class))
    

提交回复
热议问题