PawelAdamski / HttpClientMock

Library for mocking Apache HttpClient.
MIT License
44 stars 9 forks source link

Add possibility to set HTTP status text #33

Closed PawelAdamski closed 3 years ago

PawelAdamski commented 3 years ago

Currently, it is not possible to mock the status text of the HTTP response. For now it is always either "ok" or "" depending on which method was used to build the response. In the current version method, withStatus accepts only code which is used to build the HTTP response. I would like to have another version of that method that will accept code and text. E.g.

httpClientMock.onPost("testUlr").doReturn("some message").withStatus(409, "reason");

Acceptance criteria:

huyle1097 commented 3 years ago

Hi @PawelAdamski May I take this issue? Thanks.

PawelAdamski commented 3 years ago

Hi @huyle1097 Yes, sure. I would be very happy if you could contribute to my project. If that is possible for you please raise two PRs one basing on the master branch and the second basing on master_v5. I need it because I have to support HttpCLient in versions 4 and 5.

If you don't have so much time please rise one PR basing on the master branch.

huyle1097 commented 3 years ago

Ok, thanks @PawelAdamski I will try :)

huyle1097 commented 3 years ago

Hey @PawelAdamski As I can see, we don't have method withStattus(code) on HttpClientVerifyBuilder. How should I implement the new method withStattus(code, reason) on it? Should it be the same as what I do on HttpClientResponseBuilder?

PawelAdamski commented 3 years ago

My mistake. It actually doesn't make sense to add withStatus to HttpClientVerifyBuilder because all methods inside that class create the condition to verify HTTP request and HTTP requests don't have any statuses.

huyle1097 commented 3 years ago

Hey @PawelAdamski I created a PR basing on master branch for this issue. Please help to review it. If it's fine, I can create the second basing on master_v5. Thanks.

PawelAdamski commented 3 years ago

I've approved and merged both PRs. Please check if they are counted to your hactoberfest profile.

huyle1097 commented 3 years ago

Both PRs are In Review state, so I guess they are counted. Thanks for your support. :heart_eyes:

PawelAdamski commented 3 years ago

Versions 1.9.0 and 2.1.0 have been released.

abhikt48 commented 3 years ago

@PawelAdamski @huyle1097 Thanks for fixes and release.

PawelAdamski commented 3 years ago

No problem @abhikt48 Please let me know if everything works fine.