Search in sources :

Example 1 with SdkHttpMetadata

use of com.amazonaws.http.SdkHttpMetadata in project beam by apache.

the class AwsCodersTest method testSdkHttpMetadataDecodeEncodeEquals.

@Test
public void testSdkHttpMetadataDecodeEncodeEquals() throws Exception {
    SdkHttpMetadata value = buildSdkHttpMetadata();
    SdkHttpMetadata clone = CoderUtils.clone(AwsCoders.sdkHttpMetadata(), value);
    assertThat(clone.getHttpStatusCode(), equalTo(value.getHttpStatusCode()));
    assertThat(clone.getHttpHeaders(), equalTo(value.getHttpHeaders()));
}
Also used : SdkHttpMetadata(com.amazonaws.http.SdkHttpMetadata) Test(org.junit.Test)

Example 2 with SdkHttpMetadata

use of com.amazonaws.http.SdkHttpMetadata in project beam by apache.

the class AwsCodersTest method testSdkHttpMetadataWithoutHeadersDecodeEncodeEquals.

@Test
public void testSdkHttpMetadataWithoutHeadersDecodeEncodeEquals() throws Exception {
    SdkHttpMetadata value = buildSdkHttpMetadata();
    SdkHttpMetadata clone = CoderUtils.clone(AwsCoders.sdkHttpMetadataWithoutHeaders(), value);
    assertThat(clone.getHttpStatusCode(), equalTo(value.getHttpStatusCode()));
    assertThat(clone.getHttpHeaders().isEmpty(), equalTo(true));
}
Also used : SdkHttpMetadata(com.amazonaws.http.SdkHttpMetadata) Test(org.junit.Test)

Example 3 with SdkHttpMetadata

use of com.amazonaws.http.SdkHttpMetadata in project beam by apache.

the class SnsIOTest method configureAmazonSnsMock.

private static void configureAmazonSnsMock(AmazonSNS amazonSNS) {
    final GetTopicAttributesResult result = Mockito.mock(GetTopicAttributesResult.class);
    final SdkHttpMetadata metadata = Mockito.mock(SdkHttpMetadata.class);
    Mockito.when(metadata.getHttpHeaders()).thenReturn(new HashMap<>());
    Mockito.when(metadata.getHttpStatusCode()).thenReturn(200);
    Mockito.when(result.getSdkHttpMetadata()).thenReturn(metadata);
    Mockito.when(amazonSNS.getTopicAttributes(Mockito.anyString())).thenReturn(result);
}
Also used : SdkHttpMetadata(com.amazonaws.http.SdkHttpMetadata) GetTopicAttributesResult(com.amazonaws.services.sns.model.GetTopicAttributesResult)

Example 4 with SdkHttpMetadata

use of com.amazonaws.http.SdkHttpMetadata in project beam by apache.

the class SnsIOTest method getAmazonSnsMockSuccess.

private static AmazonSNS getAmazonSnsMockSuccess() {
    final AmazonSNS amazonSNS = Mockito.mock(AmazonSNS.class);
    configureAmazonSnsMock(amazonSNS);
    final PublishResult result = Mockito.mock(PublishResult.class);
    final SdkHttpMetadata metadata = Mockito.mock(SdkHttpMetadata.class);
    Mockito.when(metadata.getHttpHeaders()).thenReturn(new HashMap<>());
    Mockito.when(metadata.getHttpStatusCode()).thenReturn(200);
    Mockito.when(result.getSdkHttpMetadata()).thenReturn(metadata);
    Mockito.when(result.getMessageId()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(amazonSNS.publish(Mockito.any())).thenReturn(result);
    return amazonSNS;
}
Also used : SdkHttpMetadata(com.amazonaws.http.SdkHttpMetadata) PublishResult(com.amazonaws.services.sns.model.PublishResult) AmazonSNS(com.amazonaws.services.sns.AmazonSNS)

Aggregations

SdkHttpMetadata (com.amazonaws.http.SdkHttpMetadata)4 Test (org.junit.Test)2 AmazonSNS (com.amazonaws.services.sns.AmazonSNS)1 GetTopicAttributesResult (com.amazonaws.services.sns.model.GetTopicAttributesResult)1 PublishResult (com.amazonaws.services.sns.model.PublishResult)1