Reputation: 3638
I have a mocked javax.ws.rs.client.WebTarget webTarget
. Then I do following:
Mockito.when(webTarget.path(Mockito.anyString())).thenReturn(webTarget).
Now I'd like to retrieve the String set during the .path(String)
method out of the webTarget mock. Is there any chance I can do that? At the time
webTarget.getUri()
unfortunately returns null
.
Upvotes: 2
Views: 1853
Reputation: 3273
To get at the string you could use ArgumentCaptor:
ArgumentCaptor<Person> argument = ArgumentCaptor.forClass(Person.class);
verify(mock).doSomething(argument.capture());
assertEquals("John", argument.getValue().getName());
or verify
Mockito.verify(webTarget).path("expectedString")
Upvotes: 3