Class MockAsyncHttpClient
- java.lang.Object
-
- software.amazon.awssdk.testutils.service.http.MockAsyncHttpClient
-
- All Implemented Interfaces:
AutoCloseable
,SdkAsyncHttpClient
,MockHttpClient
,SdkAutoCloseable
public final class MockAsyncHttpClient extends Object implements SdkAsyncHttpClient, MockHttpClient
Mock implementation ofSdkAsyncHttpClient
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface software.amazon.awssdk.http.async.SdkAsyncHttpClient
SdkAsyncHttpClient.Builder<T extends SdkAsyncHttpClient.Builder<T>>
-
-
Constructor Summary
Constructors Constructor Description MockAsyncHttpClient()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
CompletableFuture<Void>
execute(AsyncExecuteRequest request)
SdkHttpRequest
getLastRequest()
Get the last request called on the mock.List<SdkHttpRequest>
getRequests()
Get all requests called on the mock.Optional<byte[]>
getStreamingPayload()
Returns the streaming payload byte array, if the asyncRequestBodyLength was set correctly.void
reset()
Resets this mock by clearing any captured requests and wiping any stubbed responses.void
setAsyncRequestBodyLength(int asyncRequestBodyLength)
Enable capturing the streaming payload by setting the length of the AsyncRequestBody.void
stubNextResponse(HttpExecuteResponse nextResponse)
Sets up the next HTTP response that will be returned by the mock.void
stubNextResponse(HttpExecuteResponse nextResponse, Duration delay)
Sets up the next HTTP response that will be returned by the mock with a delay.void
stubResponses(HttpExecuteResponse... responses)
Sets the next set of HTTP responses that will be returned by the mock.void
stubResponses(Pair<HttpExecuteResponse,Duration>... responses)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface software.amazon.awssdk.testutils.service.http.MockHttpClient
stubNextResponse200
-
Methods inherited from interface software.amazon.awssdk.http.async.SdkAsyncHttpClient
clientName
-
-
-
-
Method Detail
-
execute
public CompletableFuture<Void> execute(AsyncExecuteRequest request)
- Specified by:
execute
in interfaceSdkAsyncHttpClient
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceSdkAutoCloseable
-
reset
public void reset()
Description copied from interface:MockHttpClient
Resets this mock by clearing any captured requests and wiping any stubbed responses.- Specified by:
reset
in interfaceMockHttpClient
-
getRequests
public List<SdkHttpRequest> getRequests()
Description copied from interface:MockHttpClient
Get all requests called on the mock.- Specified by:
getRequests
in interfaceMockHttpClient
-
getLastRequest
public SdkHttpRequest getLastRequest()
Description copied from interface:MockHttpClient
Get the last request called on the mock.- Specified by:
getLastRequest
in interfaceMockHttpClient
-
stubNextResponse
public void stubNextResponse(HttpExecuteResponse nextResponse)
Description copied from interface:MockHttpClient
Sets up the next HTTP response that will be returned by the mock. Removes responses previously added to the mock.- Specified by:
stubNextResponse
in interfaceMockHttpClient
-
stubNextResponse
public void stubNextResponse(HttpExecuteResponse nextResponse, Duration delay)
Description copied from interface:MockHttpClient
Sets up the next HTTP response that will be returned by the mock with a delay. Removes responses previously added to the mock.- Specified by:
stubNextResponse
in interfaceMockHttpClient
-
stubResponses
public void stubResponses(Pair<HttpExecuteResponse,Duration>... responses)
- Specified by:
stubResponses
in interfaceMockHttpClient
-
stubResponses
public void stubResponses(HttpExecuteResponse... responses)
Description copied from interface:MockHttpClient
Sets the next set of HTTP responses that will be returned by the mock. Removes responses previously added to the mock.- Specified by:
stubResponses
in interfaceMockHttpClient
-
setAsyncRequestBodyLength
public void setAsyncRequestBodyLength(int asyncRequestBodyLength)
Enable capturing the streaming payload by setting the length of the AsyncRequestBody.
-
getStreamingPayload
public Optional<byte[]> getStreamingPayload()
Returns the streaming payload byte array, if the asyncRequestBodyLength was set correctly. Otherwise, returns empty Optional.
-
-