HttpClientMock icon indicating copy to clipboard operation
HttpClientMock copied to clipboard

Add mocking of HttpAsyncClient

Open PawelAdamski opened this issue 7 years ago • 4 comments

Currently HttpClientMock supports only mocking of HttpClient. In scope of this issue we want to add support for mocking HttpAsyncClient. Working HttpAsyncClientMock should look similar to HttpClientMock. Example: Record:

HttpClientAsyncMock httpClientAsyncMock = new HttpClientAsyncMock();
httpClientAsyncMock .onGet("http://localhost/login")
  .withParameter("user","john")
  .doReturn("Ok");
httpClientAsyncMock .onPost("http://localhost/login").doReturnStatus(501);

verify:

httpClientAsyncMock .verify().get("http://localhost/login").withParameter("user","john").called()
httpClientAsyncMock .verify().post("http://localhost/login").notCalled()

HttpClientAsyncMock should have additional action to simulate a delay response.

httpClientAsyncMock .onPost("http://localhost/login").delay(4,TimeUnit.Seconds).doReturnStatus(501);

PawelAdamski avatar Jul 20 '18 20:07 PawelAdamski

Hi @[PawelAdamski] i am interested in this issue Will you please assign me this issue

Priyanshu-ai902 avatar Oct 15 '23 18:10 Priyanshu-ai902

Hi @Priyanshu-ai902 I'm happy to hear that you are interested in contributing to HttpClientMock. Feel free to work on HttpAsycClient.It would be great if you could first expalin my your idea and then jump into the code, thanks to that approving your PR should be much easier.

PawelAdamski avatar Oct 17 '23 05:10 PawelAdamski

I explain my idea within the code

Priyanshu-ai902 avatar Oct 17 '23 14:10 Priyanshu-ai902

@Priyanshu-ai902 Your code doesn't give me enough information how you would like build mock for HttpClientAsync. Please provide more detail or working examples.

PawelAdamski avatar Oct 20 '23 13:10 PawelAdamski