how do you call another method with same arguments using the mockito method?

You can use thenAnswer, where you can write a lambda that takes an Answer object as parameter where you can extract the arguments of the call to addDate:

when(foo.addDate(eq("myString"), any()))
    .thenAnswer(answer -> 
            foo.addString(answer.getArgument(0)));

Have a look at the docs here.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top