Feature: Reuse HttpClientResponseBuilder for verification
Currently i have to rewrite the mock rule to verify the number of calls. I.e.:
mock.onPost().withPath(Matchers.containsString("/something")).doReturn(HttpStatus.SC_OK, "777");
[...]
mock.verify().post().withPath(Matchers.containsString("/something")).called(1);
Especially when using complex rules this is time consuming and a maintenance issue. I would like to reuse the rule, for example like this:
HttpClientResponseBuilder builder = mock.onPost().withPath(Matchers.containsString("/something")).doReturn(HttpStatus.SC_OK, "777");;
[...]
mock.verify(builder).called(1);
Hi @ipichris Thanks for finding that issues. I will try to look on it during the weekend.
Using HttpClientResponseBuilder in the way as you presented is not possible because it contains a definition of all the rules and actions. So if you would pass it to verify you don't know which rule should be verified.
I have a different proposition.
Rule something = Rule.onPost().withPath(Matchers.containsString("/something"))
mock.on(something).doReturn(HttpStatus.SC_OK, "777")
[...]
mock.verifiy(something).called(1)
What do you think about it @ipichris ?
Hi @PawelAdamski
Thx for your reply. Your proposition looks perfectly fine for me.
Keep up the good work!