@Test public void handleRequest_Success() { final CloudFormationClient client = getServiceClient(); final DescribeTypeResponse describeTypeResponse = DescribeTypeResponse.builder() .arn("arn:aws:cloudformation:us-west-2:123456789012:type/resource/AWS-Demo-Resource/00000001") .defaultVersionId("00000001") .deprecatedStatus("LIVE") .isDefaultVersion(false) .sourceUrl("https: .type("RESOURCE") .typeName("AWS::Demo::Resource") .visibility("PRIVATE") .build(); when(client.describeType(ArgumentMatchers.any(DescribeTypeRequest.class))) .thenReturn(describeTypeResponse); final DeregisterTypeResponse deregisterTypeResponse = DeregisterTypeResponse.builder().build(); when(client.deregisterType(ArgumentMatchers.any(DeregisterTypeRequest.class))) .thenReturn(deregisterTypeResponse); final ResourceModel resourceModel = ResourceModel.builder() .arn("arn:aws:cloudformation:us-west-2:123456789012:type/resource/AWS-Demo-Resource/00000001") .build(); final ResourceHandlerRequest<ResourceModel> request = ResourceHandlerRequest.<ResourceModel>builder() .desiredResourceState(resourceModel) .awsPartition("aws") .region("us-west-2") .awsAccountId("123456789012") .build(); final ProgressEvent<ResourceModel, CallbackContext> response = handler.handleRequest(proxy, request, null, loggerProxy); assertThat(response).isNotNull(); assertThat(response.getStatus()).isEqualTo(OperationStatus.SUCCESS); assertThat(response.getCallbackContext()).isNull(); assertThat(response.getCallbackDelaySeconds()).isEqualTo(0); assertThat(response.getResourceModels()).isNull(); assertThat(response.getResourceModel()).isNull(); assertThat(response.getMessage()).isNull(); assertThat(response.getErrorCode()).isNull(); }
protected ProgressEvent<ResourceModel, CallbackContext> handleRequest( final AmazonWebServicesClientProxy proxy, final ResourceHandlerRequest<ResourceModel> request, final CallbackContext callbackContext, final ProxyClient<CloudFormationClient> proxyClient, final Logger logger) { final ResourceModel resourceModel = request.getDesiredResourceState(); final CallChain.Initiator<CloudFormationClient, ResourceModel, CallbackContext> initiator = proxy.newInitiator(proxyClient, resourceModel, callbackContext); return new ReadHandler().handleRequest(proxy, request, callbackContext, proxyClient, logger) .onSuccess(progress -> initiator.initiate("delete") .translateToServiceRequest(model -> Translator.translateToDeleteRequest(progress.getResourceModel(), logger)) .makeServiceCall((awsRequest, proxyInvocation) -> proxyInvocation.injectCredentialsAndInvokeV2(awsRequest, proxyInvocation.client()::deregisterType)) .done(awsResponse -> ProgressEvent.<ResourceModel, CallbackContext>builder() .status(OperationStatus.SUCCESS) .build())); }
DeleteHandler extends BaseHandlerStd { protected ProgressEvent<ResourceModel, CallbackContext> handleRequest( final AmazonWebServicesClientProxy proxy, final ResourceHandlerRequest<ResourceModel> request, final CallbackContext callbackContext, final ProxyClient<CloudFormationClient> proxyClient, final Logger logger) { final ResourceModel resourceModel = request.getDesiredResourceState(); final CallChain.Initiator<CloudFormationClient, ResourceModel, CallbackContext> initiator = proxy.newInitiator(proxyClient, resourceModel, callbackContext); return new ReadHandler().handleRequest(proxy, request, callbackContext, proxyClient, logger) .onSuccess(progress -> initiator.initiate("delete") .translateToServiceRequest(model -> Translator.translateToDeleteRequest(progress.getResourceModel(), logger)) .makeServiceCall((awsRequest, proxyInvocation) -> proxyInvocation.injectCredentialsAndInvokeV2(awsRequest, proxyInvocation.client()::deregisterType)) .done(awsResponse -> ProgressEvent.<ResourceModel, CallbackContext>builder() .status(OperationStatus.SUCCESS) .build())); } }
DeleteHandler extends BaseHandlerStd { protected ProgressEvent<ResourceModel, CallbackContext> handleRequest( final AmazonWebServicesClientProxy proxy, final ResourceHandlerRequest<ResourceModel> request, final CallbackContext callbackContext, final ProxyClient<CloudFormationClient> proxyClient, final Logger logger) { final ResourceModel resourceModel = request.getDesiredResourceState(); final CallChain.Initiator<CloudFormationClient, ResourceModel, CallbackContext> initiator = proxy.newInitiator(proxyClient, resourceModel, callbackContext); return new ReadHandler().handleRequest(proxy, request, callbackContext, proxyClient, logger) .onSuccess(progress -> initiator.initiate("delete") .translateToServiceRequest(model -> Translator.translateToDeleteRequest(progress.getResourceModel(), logger)) .makeServiceCall((awsRequest, proxyInvocation) -> proxyInvocation.injectCredentialsAndInvokeV2(awsRequest, proxyInvocation.client()::deregisterType)) .done(awsResponse -> ProgressEvent.<ResourceModel, CallbackContext>builder() .status(OperationStatus.SUCCESS) .build())); }  }
DeleteHandler extends BaseHandlerStd { protected ProgressEvent<ResourceModel, CallbackContext> handleRequest( final AmazonWebServicesClientProxy proxy, final ResourceHandlerRequest<ResourceModel> request, final CallbackContext callbackContext, final ProxyClient<CloudFormationClient> proxyClient, final Logger logger) { final ResourceModel resourceModel = request.getDesiredResourceState(); final CallChain.Initiator<CloudFormationClient, ResourceModel, CallbackContext> initiator = proxy.newInitiator(proxyClient, resourceModel, callbackContext); return new ReadHandler().handleRequest(proxy, request, callbackContext, proxyClient, logger) .onSuccess(progress -> initiator.initiate("delete") .translateToServiceRequest(model -> Translator.translateToDeleteRequest(progress.getResourceModel(), logger)) .makeServiceCall((awsRequest, proxyInvocation) -> proxyInvocation.injectCredentialsAndInvokeV2(awsRequest, proxyInvocation.client()::deregisterType)) .done(awsResponse -> ProgressEvent.<ResourceModel, CallbackContext>builder() .status(OperationStatus.SUCCESS) .build())); }   }
DeleteHandler extends BaseHandlerStd { protected ProgressEvent<ResourceModel, CallbackContext> handleRequest( final AmazonWebServicesClientProxy proxy, final ResourceHandlerRequest<ResourceModel> request, final CallbackContext callbackContext, final ProxyClient<CloudFormationClient> proxyClient, final Logger logger) { final ResourceModel resourceModel = request.getDesiredResourceState(); final CallChain.Initiator<CloudFormationClient, ResourceModel, CallbackContext> initiator = proxy.newInitiator(proxyClient, resourceModel, callbackContext); return new ReadHandler().handleRequest(proxy, request, callbackContext, proxyClient, logger) .onSuccess(progress -> initiator.initiate("delete") .translateToServiceRequest(model -> Translator.translateToDeleteRequest(progress.getResourceModel(), logger)) .makeServiceCall((awsRequest, proxyInvocation) -> proxyInvocation.injectCredentialsAndInvokeV2(awsRequest, proxyInvocation.client()::deregisterType)) .done(awsResponse -> ProgressEvent.<ResourceModel, CallbackContext>builder() .status(OperationStatus.SUCCESS) .build())); }    }