My getUserDetails class take User(custome class) and string as arguments and return User. If I use Mockito matcher as below:
when(authService.getUserDetails(any(User.class),anyString())).thenReturn(any(User.class));
It gives me InvalidUseOfMatchersException 2 matchers expected, 3 found. Can't I use the above expression?
Matchers are not used for returning.
.thenReturn(any(User.class));
You have to return something tangible here. Matchers are just for matching up input so that you can dictate what is returned when certain input is provided. You still need to have a real output to return.