Search in sources :

Example 1 with Tag

use of org.springdoc.demo.app2.model.Tag in project titus-control-plane by Netflix.

the class AwsInstanceCloudConnector method addTagToResource.

/**
 * Internal method used for testing.
 */
Completable addTagToResource(String resourceId, String tag, String value) {
    List<String> resources = singletonList(resourceId);
    List<Tag> tags = singletonList(new Tag(tag, value));
    Observable<CreateTagsResult> observable = toObservable(new CreateTagsRequest(resources, tags), ec2Client::createTagsAsync);
    return observable.toCompletable();
}
Also used : CreateTagsResult(com.amazonaws.services.ec2.model.CreateTagsResult) CreateTagsRequest(com.amazonaws.services.ec2.model.CreateTagsRequest) Tag(com.amazonaws.services.ec2.model.Tag)

Example 2 with Tag

use of org.springdoc.demo.app2.model.Tag in project aws-cloudformation-resource-providers-transitgateway by aws-cloudformation.

the class CreateHandlerTest method handleRequest_Error.

@Test
public void handleRequest_Error() {
    final List<Tag> tags = new ArrayList<>();
    tags.add(MOCKS.tag());
    AwsErrorDetails errorDetails = AwsErrorDetails.builder().errorMessage("Something went wrong").errorCode("Invalid Request").build();
    AwsServiceException exception = AwsServiceException.builder().awsErrorDetails(errorDetails).build();
    when(proxyClient.client().createTransitGatewayConnect(any(CreateTransitGatewayConnectRequest.class))).thenThrow(exception);
    ResourceModel model = MOCKS.model(tags);
    final ProgressEvent<ResourceModel, CallbackContext> response = handler.handleRequest(proxy, MOCKS.request(model), new CallbackContext(), proxyClient, logger);
    assertThat(response).isNotNull();
    assertThat(response.getStatus()).isEqualTo(OperationStatus.FAILED);
    assertThat(response.getCallbackDelaySeconds()).isEqualTo(0);
    assertThat(response.getResourceModel()).isNull();
    assertThat(response.getResourceModels()).isNull();
    assertThat(response.getMessage().contains("Something went wrong")).isTrue();
    assertThat(response.getErrorCode()).isEqualTo(HandlerErrorCode.InvalidRequest);
}
Also used : CreateTransitGatewayConnectRequest(software.amazon.awssdk.services.ec2.model.CreateTransitGatewayConnectRequest) ArrayList(java.util.ArrayList) AwsServiceException(software.amazon.awssdk.awscore.exception.AwsServiceException) Tag(software.amazon.awssdk.services.ec2.model.Tag) AwsErrorDetails(software.amazon.awssdk.awscore.exception.AwsErrorDetails) Test(org.junit.jupiter.api.Test)

Example 3 with Tag

use of org.springdoc.demo.app2.model.Tag in project aws-cloudformation-resource-providers-transitgateway by aws-cloudformation.

the class ListHandlerTest method handleRequest_Error.

@Test
public void handleRequest_Error() {
    final List<Tag> tags = new ArrayList<>();
    tags.add(MOCKS.tag());
    AwsErrorDetails errorDetails = AwsErrorDetails.builder().errorMessage("Something went wrong").errorCode("Invalid Request").build();
    AwsServiceException exception = AwsServiceException.builder().awsErrorDetails(errorDetails).build();
    when(proxyClient.client().describeTransitGatewayConnects(any(DescribeTransitGatewayConnectsRequest.class))).thenThrow(exception);
    ResourceModel model = MOCKS.model(tags);
    final ProgressEvent<ResourceModel, CallbackContext> response = handler.handleRequest(proxy, MOCKS.request(model), new CallbackContext(), proxyClient, logger);
    assertThat(response).isNotNull();
    assertThat(response.getStatus()).isEqualTo(OperationStatus.FAILED);
    assertThat(response.getCallbackDelaySeconds()).isEqualTo(0);
    assertThat(response.getResourceModel()).isNull();
    assertThat(response.getResourceModels()).isNull();
    assertThat(response.getMessage().contains("Something went wrong")).isTrue();
    assertThat(response.getErrorCode()).isEqualTo(HandlerErrorCode.InvalidRequest);
}
Also used : DescribeTransitGatewayConnectsRequest(software.amazon.awssdk.services.ec2.model.DescribeTransitGatewayConnectsRequest) ArrayList(java.util.ArrayList) AwsServiceException(software.amazon.awssdk.awscore.exception.AwsServiceException) Tag(software.amazon.awssdk.services.ec2.model.Tag) AwsErrorDetails(software.amazon.awssdk.awscore.exception.AwsErrorDetails) Test(org.junit.jupiter.api.Test)

Example 4 with Tag

use of org.springdoc.demo.app2.model.Tag in project aws-cloudformation-resource-providers-transitgateway by aws-cloudformation.

the class ReadHandlerTest method handleRequest_Error.

@Test
public void handleRequest_Error() {
    final List<Tag> tags = new ArrayList<>();
    tags.add(MOCKS.tag());
    AwsErrorDetails errorDetails = AwsErrorDetails.builder().errorMessage("Something went wrong").errorCode("Invalid Request").build();
    AwsServiceException exception = AwsServiceException.builder().awsErrorDetails(errorDetails).build();
    when(proxyClient.client().describeTransitGatewayConnects(any(DescribeTransitGatewayConnectsRequest.class))).thenThrow(exception);
    ResourceModel model = MOCKS.model(tags);
    final ProgressEvent<ResourceModel, CallbackContext> response = handler.handleRequest(proxy, MOCKS.request(model), new CallbackContext(), proxyClient, logger);
    assertThat(response).isNotNull();
    assertThat(response.getStatus()).isEqualTo(OperationStatus.FAILED);
    assertThat(response.getCallbackDelaySeconds()).isEqualTo(0);
    assertThat(response.getResourceModel()).isNull();
    assertThat(response.getResourceModels()).isNull();
    assertThat(response.getMessage().contains("Something went wrong")).isTrue();
    assertThat(response.getErrorCode()).isEqualTo(HandlerErrorCode.InvalidRequest);
}
Also used : DescribeTransitGatewayConnectsRequest(software.amazon.awssdk.services.ec2.model.DescribeTransitGatewayConnectsRequest) ArrayList(java.util.ArrayList) AwsServiceException(software.amazon.awssdk.awscore.exception.AwsServiceException) Tag(software.amazon.awssdk.services.ec2.model.Tag) AwsErrorDetails(software.amazon.awssdk.awscore.exception.AwsErrorDetails) Test(org.junit.jupiter.api.Test)

Example 5 with Tag

use of org.springdoc.demo.app2.model.Tag in project aws-cloudformation-resource-providers-transitgateway by aws-cloudformation.

the class TagUtilsTest method difference2.

@Test
public void difference2() {
    Tag sharedTag = MOCKS.tag();
    final List<Tag> tags1 = new ArrayList<>();
    tags1.add(sharedTag);
    tags1.add(MOCKS.tag());
    final List<Tag> tags2 = new ArrayList<>();
    tags2.add(sharedTag);
    tags2.add(MOCKS.tag());
    List<Tag> difference = TagUtils.difference(TagUtils.sdkTagsToCfnTags(tags2), TagUtils.sdkTagsToCfnTags(tags1));
    assertThat(difference.size()).isEqualTo(1);
    assertThat(difference.get(0).key()).isEqualTo(tags2.get(1).key());
    assertThat(difference.get(0).value()).isEqualTo(tags2.get(1).value());
}
Also used : ArrayList(java.util.ArrayList) Tag(software.amazon.awssdk.services.ec2.model.Tag) Test(org.junit.jupiter.api.Test)

Aggregations

ArrayList (java.util.ArrayList)116 Tag (com.amazonaws.services.ec2.model.Tag)70 Test (org.junit.jupiter.api.Test)63 Tag (software.amazon.awssdk.services.ec2.model.Tag)61 Tag (com.amazonaws.services.s3.model.Tag)57 Test (org.junit.Test)46 List (java.util.List)36 S3FileTransferRequestParamsDto (org.finra.herd.model.dto.S3FileTransferRequestParamsDto)35 Instance (com.amazonaws.services.ec2.model.Instance)32 GetObjectTaggingRequest (com.amazonaws.services.s3.model.GetObjectTaggingRequest)31 GetObjectTaggingResult (com.amazonaws.services.s3.model.GetObjectTaggingResult)30 S3ObjectTaggerRoleParamsDto (org.finra.herd.model.dto.S3ObjectTaggerRoleParamsDto)26 PutObjectRequest (com.amazonaws.services.s3.model.PutObjectRequest)23 HashMap (java.util.HashMap)22 S3ObjectSummary (com.amazonaws.services.s3.model.S3ObjectSummary)21 ObjectMetadata (com.amazonaws.services.s3.model.ObjectMetadata)20 AmazonServiceException (com.amazonaws.AmazonServiceException)19 Collectors (java.util.stream.Collectors)17 S3VersionSummary (com.amazonaws.services.s3.model.S3VersionSummary)16 SetObjectTaggingRequest (com.amazonaws.services.s3.model.SetObjectTaggingRequest)16