Search in sources :

Example 1 with EmptyPublisher

use of software.amazon.awssdk.core.async.EmptyPublisher in project aws-xray-sdk-java by aws.

the class TracingInterceptorTest method mockSdkAsyncHttpClient.

private SdkAsyncHttpClient mockSdkAsyncHttpClient(SdkHttpResponse response) {
    SdkAsyncHttpClient mockClient = Mockito.mock(SdkAsyncHttpClient.class);
    when(mockClient.execute(Mockito.any(AsyncExecuteRequest.class))).thenAnswer((Answer<CompletableFuture<Void>>) invocationOnMock -> {
        AsyncExecuteRequest request = invocationOnMock.getArgument(0);
        SdkAsyncHttpResponseHandler handler = request.responseHandler();
        handler.onHeaders(response);
        handler.onStream(new EmptyPublisher<>());
        return CompletableFuture.completedFuture(null);
    });
    return mockClient;
}
Also used : MethodSorters(org.junit.runners.MethodSorters) AWSXRay(com.amazonaws.xray.AWSXRay) Subsegment(com.amazonaws.xray.entities.Subsegment) RunWith(org.junit.runner.RunWith) CompletableFuture(java.util.concurrent.CompletableFuture) AwsSessionCredentials(software.amazon.awssdk.auth.credentials.AwsSessionCredentials) StaticCredentialsProvider(software.amazon.awssdk.auth.credentials.StaticCredentialsProvider) Segment(com.amazonaws.xray.entities.Segment) Context(software.amazon.awssdk.core.interceptor.Context) LambdaClient(software.amazon.awssdk.services.lambda.LambdaClient) Answer(org.mockito.stubbing.Answer) ListTablesRequest(software.amazon.awssdk.services.dynamodb.model.ListTablesRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) Map(java.util.Map) After(org.junit.After) ExecutionAttributes(software.amazon.awssdk.core.interceptor.ExecutionAttributes) URI(java.net.URI) Emitter(com.amazonaws.xray.emitters.Emitter) SdkAsyncHttpClient(software.amazon.awssdk.http.async.SdkAsyncHttpClient) SdkAsyncHttpResponseHandler(software.amazon.awssdk.http.async.SdkAsyncHttpResponseHandler) Region(software.amazon.awssdk.regions.Region) Before(org.junit.Before) SdkHttpResponse(software.amazon.awssdk.http.SdkHttpResponse) DynamoDbClient(software.amazon.awssdk.services.dynamodb.DynamoDbClient) EmptyPublisher(software.amazon.awssdk.core.async.EmptyPublisher) SdkHttpRequest(software.amazon.awssdk.http.SdkHttpRequest) Test(org.junit.Test) LambdaAsyncClient(software.amazon.awssdk.services.lambda.LambdaAsyncClient) Mockito.when(org.mockito.Mockito.when) SdkHttpClient(software.amazon.awssdk.http.SdkHttpClient) ExecutableHttpRequest(software.amazon.awssdk.http.ExecutableHttpRequest) AWSXRayRecorderBuilder(com.amazonaws.xray.AWSXRayRecorderBuilder) StandardCharsets(java.nio.charset.StandardCharsets) Mockito.verify(org.mockito.Mockito.verify) AsyncExecuteRequest(software.amazon.awssdk.http.async.AsyncExecuteRequest) Mockito(org.mockito.Mockito) AbortableInputStream(software.amazon.awssdk.http.AbortableInputStream) Mockito.never(org.mockito.Mockito.never) MockitoJUnitRunner(org.mockito.runners.MockitoJUnitRunner) InvokeRequest(software.amazon.awssdk.services.lambda.model.InvokeRequest) HttpExecuteResponse(software.amazon.awssdk.http.HttpExecuteResponse) Assert(org.junit.Assert) FixMethodOrder(org.junit.FixMethodOrder) Cause(com.amazonaws.xray.entities.Cause) ClientOverrideConfiguration(software.amazon.awssdk.core.client.config.ClientOverrideConfiguration) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) AsyncExecuteRequest(software.amazon.awssdk.http.async.AsyncExecuteRequest) CompletableFuture(java.util.concurrent.CompletableFuture) SdkAsyncHttpResponseHandler(software.amazon.awssdk.http.async.SdkAsyncHttpResponseHandler) EmptyPublisher(software.amazon.awssdk.core.async.EmptyPublisher) SdkAsyncHttpClient(software.amazon.awssdk.http.async.SdkAsyncHttpClient)

Aggregations

AWSXRay (com.amazonaws.xray.AWSXRay)1 AWSXRayRecorderBuilder (com.amazonaws.xray.AWSXRayRecorderBuilder)1 Emitter (com.amazonaws.xray.emitters.Emitter)1 Cause (com.amazonaws.xray.entities.Cause)1 Segment (com.amazonaws.xray.entities.Segment)1 Subsegment (com.amazonaws.xray.entities.Subsegment)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 URI (java.net.URI)1 StandardCharsets (java.nio.charset.StandardCharsets)1 Map (java.util.Map)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 After (org.junit.After)1 Assert (org.junit.Assert)1 Before (org.junit.Before)1 FixMethodOrder (org.junit.FixMethodOrder)1 Test (org.junit.Test)1 RunWith (org.junit.runner.RunWith)1 MethodSorters (org.junit.runners.MethodSorters)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 Mockito (org.mockito.Mockito)1