Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Reuse HttpClientResponseBuilder for verification #41

Open
ipichris opened this issue Jan 19, 2021 · 3 comments
Open

Feature: Reuse HttpClientResponseBuilder for verification #41

ipichris opened this issue Jan 19, 2021 · 3 comments

Comments

@ipichris
Copy link

ipichris commented Jan 19, 2021

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);
@PawelAdamski
Copy link
Owner

Hi @ipichris
Thanks for finding that issues. I will try to look on it during the weekend.

@PawelAdamski
Copy link
Owner

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 ?

@ipichris
Copy link
Author

ipichris commented Feb 4, 2021

Hi @PawelAdamski

Thx for your reply.
Your proposition looks perfectly fine for me.

Keep up the good work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants