@Test public void handleRequest_SimpleSuccess() { 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(true) .sourceUrl("https: .type("RESOURCE") .typeName("AWS::Demo::Resource") .visibility("PRIVATE") .build(); when(client.describeType(ArgumentMatchers.any(DescribeTypeRequest.class))) .thenReturn(describeTypeResponse); final ResourceModel inModel = ResourceModel.builder() .arn("arn:aws:cloudformation:us-west-2:123456789012:type/resource/AWS-Demo-Resource/00000001") .build(); final ResourceModel outModel = ResourceModel.builder() .arn("arn:aws:cloudformation:us-west-2:123456789012:type/resource/AWS-Demo-Resource/00000001") .isDefaultVersion(true) .sourceUrl("https: .typeName("AWS::Demo::Resource") .versionId("00000001") .visibility("PRIVATE") .build(); final ResourceHandlerRequest<ResourceModel> request = ResourceHandlerRequest.<ResourceModel>builder() .desiredResourceState(inModel) .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.getResourceModel()).isEqualTo(outModel); assertThat(response.getResourceModels()).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 initiator.initiate("read") .translateToServiceRequest((model) -> Translator.translateToReadRequest(model, logger)) .makeServiceCall((awsRequest, sdkProxyClient) -> readResource(awsRequest, sdkProxyClient , resourceModel)) .done(awsResponse -> ProgressEvent.defaultSuccessHandler(Translator.translateFromReadResponse(awsResponse))); }
ReadHandler 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 initiator.initiate("read") .translateToServiceRequest((model) -> Translator.translateToReadRequest(model, logger)) .makeServiceCall((awsRequest, sdkProxyClient) -> readResource(awsRequest, sdkProxyClient , resourceModel)) .done(awsResponse -> ProgressEvent.defaultSuccessHandler(Translator.translateFromReadResponse(awsResponse))); } }
ReadHandler 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 initiator.initiate("read") .translateToServiceRequest((model) -> Translator.translateToReadRequest(model, logger)) .makeServiceCall((awsRequest, sdkProxyClient) -> readResource(awsRequest, sdkProxyClient , resourceModel)) .done(awsResponse -> ProgressEvent.defaultSuccessHandler(Translator.translateFromReadResponse(awsResponse))); }  }
ReadHandler 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 initiator.initiate("read") .translateToServiceRequest((model) -> Translator.translateToReadRequest(model, logger)) .makeServiceCall((awsRequest, sdkProxyClient) -> readResource(awsRequest, sdkProxyClient , resourceModel)) .done(awsResponse -> ProgressEvent.defaultSuccessHandler(Translator.translateFromReadResponse(awsResponse))); }   }
ReadHandler 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 initiator.initiate("read") .translateToServiceRequest((model) -> Translator.translateToReadRequest(model, logger)) .makeServiceCall((awsRequest, sdkProxyClient) -> readResource(awsRequest, sdkProxyClient , resourceModel)) .done(awsResponse -> ProgressEvent.defaultSuccessHandler(Translator.translateFromReadResponse(awsResponse))); }    }