Search in sources :

Example 1 with ExecutableHttpRequest

use of software.amazon.awssdk.http.ExecutableHttpRequest in project aws-xray-sdk-java by aws.

the class TracingInterceptorTest method mockSdkHttpClient.

private SdkHttpClient mockSdkHttpClient(SdkHttpResponse response, String body) throws Exception {
    ExecutableHttpRequest abortableCallable = Mockito.mock(ExecutableHttpRequest.class);
    SdkHttpClient mockClient = Mockito.mock(SdkHttpClient.class);
    when(mockClient.prepareRequest(Mockito.any())).thenReturn(abortableCallable);
    when(abortableCallable.call()).thenReturn(HttpExecuteResponse.builder().response(response).responseBody(AbortableInputStream.create(new ByteArrayInputStream(body.getBytes(StandardCharsets.UTF_8)))).build());
    return mockClient;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) SdkHttpClient(software.amazon.awssdk.http.SdkHttpClient) ExecutableHttpRequest(software.amazon.awssdk.http.ExecutableHttpRequest)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 ExecutableHttpRequest (software.amazon.awssdk.http.ExecutableHttpRequest)1 SdkHttpClient (software.amazon.awssdk.http.SdkHttpClient)1