@Test public void handleRequest_Success() { final CloudFormationClient client = getServiceClient(); final TypeSummary type = TypeSummary.builder() .defaultVersionId("00000001") .description("AWS Demo Resource") .lastUpdated(Instant.ofEpochSecond(123456789012L)) .type(RegistryType.RESOURCE) .typeArn("arn:aws:cloudformation:us-west-2:123456789012:type/resource/AWS-Demo-Resource") .typeName("AWS::Demo::Resource") .build(); final TypeSummary type2 = TypeSummary.builder() .defaultVersionId("00000007") .description("My Resource") .lastUpdated(Instant.ofEpochSecond(923456789012L)) .type(RegistryType.RESOURCE) .typeArn("arn:aws:cloudformation:us-west-2:123456789012:type/resource/My-Demo-Resource") .typeName("My::Demo::Resource") .build(); final ListTypesResponse listTypesResponse = ListTypesResponse.builder() .typeSummaries(Arrays.asList(type, type2)) .nextToken("token") .build(); when(client.listTypes(ArgumentMatchers.any(ListTypesRequest.class))) .thenReturn(listTypesResponse); final ResourceModel model1 = ResourceModel.builder() .arn("arn:aws:cloudformation:us-west-2:123456789012:type/resource/AWS-Demo-Resource") .build(); final ResourceModel model2 = ResourceModel.builder() .arn("arn:aws:cloudformation:us-west-2:123456789012:type/resource/My-Demo-Resource") .build(); final ResourceHandlerRequest<ResourceModel> request = ResourceHandlerRequest.<ResourceModel>builder() .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()).isNull(); assertThat(response.getResourceModels()).containsAll(Arrays.asList(model1, model2)); assertThat(response.getNextToken()).isEqualTo("token"); assertThat(response.getMessage()).isNull(); assertThat(response.getErrorCode()).isNull(); }
@Override public 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() == null ? ResourceModel.builder().build() : request.getDesiredResourceState(); final CallChain.Initiator<CloudFormationClient, ResourceModel, CallbackContext> initiator = proxy.newInitiator(proxyClient, resourceModel, callbackContext); return initiator .translateToServiceRequest((model) -> Translator.translateToListRequest(request.getNextToken())) .makeServiceCall((awsRequest, sdkProxyClient) -> sdkProxyClient.injectCredentialsAndInvokeV2(awsRequest, sdkProxyClient.client()::listTypes)) .done((listTypesRequest, listTypesResponse, sdkProxyClient, model, cc) -> ProgressEvent.<ResourceModel, CallbackContext>builder() .status(OperationStatus.SUCCESS) .resourceModels(Translator.translateFromListResponse(listTypesResponse)) .nextToken(listTypesResponse.nextToken()) .build() ); }
ListHandler extends BaseHandlerStd { @Override public 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() == null ? ResourceModel.builder().build() : request.getDesiredResourceState(); final CallChain.Initiator<CloudFormationClient, ResourceModel, CallbackContext> initiator = proxy.newInitiator(proxyClient, resourceModel, callbackContext); return initiator .translateToServiceRequest((model) -> Translator.translateToListRequest(request.getNextToken())) .makeServiceCall((awsRequest, sdkProxyClient) -> sdkProxyClient.injectCredentialsAndInvokeV2(awsRequest, sdkProxyClient.client()::listTypes)) .done((listTypesRequest, listTypesResponse, sdkProxyClient, model, cc) -> ProgressEvent.<ResourceModel, CallbackContext>builder() .status(OperationStatus.SUCCESS) .resourceModels(Translator.translateFromListResponse(listTypesResponse)) .nextToken(listTypesResponse.nextToken()) .build() ); } }
ListHandler extends BaseHandlerStd { @Override public 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() == null ? ResourceModel.builder().build() : request.getDesiredResourceState(); final CallChain.Initiator<CloudFormationClient, ResourceModel, CallbackContext> initiator = proxy.newInitiator(proxyClient, resourceModel, callbackContext); return initiator .translateToServiceRequest((model) -> Translator.translateToListRequest(request.getNextToken())) .makeServiceCall((awsRequest, sdkProxyClient) -> sdkProxyClient.injectCredentialsAndInvokeV2(awsRequest, sdkProxyClient.client()::listTypes)) .done((listTypesRequest, listTypesResponse, sdkProxyClient, model, cc) -> ProgressEvent.<ResourceModel, CallbackContext>builder() .status(OperationStatus.SUCCESS) .resourceModels(Translator.translateFromListResponse(listTypesResponse)) .nextToken(listTypesResponse.nextToken()) .build() ); }  }
ListHandler extends BaseHandlerStd { @Override public 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() == null ? ResourceModel.builder().build() : request.getDesiredResourceState(); final CallChain.Initiator<CloudFormationClient, ResourceModel, CallbackContext> initiator = proxy.newInitiator(proxyClient, resourceModel, callbackContext); return initiator .translateToServiceRequest((model) -> Translator.translateToListRequest(request.getNextToken())) .makeServiceCall((awsRequest, sdkProxyClient) -> sdkProxyClient.injectCredentialsAndInvokeV2(awsRequest, sdkProxyClient.client()::listTypes)) .done((listTypesRequest, listTypesResponse, sdkProxyClient, model, cc) -> ProgressEvent.<ResourceModel, CallbackContext>builder() .status(OperationStatus.SUCCESS) .resourceModels(Translator.translateFromListResponse(listTypesResponse)) .nextToken(listTypesResponse.nextToken()) .build() ); }  @Override ProgressEvent<ResourceModel, CallbackContext> handleRequest(
        final AmazonWebServicesClientProxy proxy,
        final ResourceHandlerRequest<ResourceModel> request,
        final CallbackContext callbackContext,
        final ProxyClient<CloudFormationClient> proxyClient,
        final Logger logger); }
ListHandler extends BaseHandlerStd { @Override public 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() == null ? ResourceModel.builder().build() : request.getDesiredResourceState(); final CallChain.Initiator<CloudFormationClient, ResourceModel, CallbackContext> initiator = proxy.newInitiator(proxyClient, resourceModel, callbackContext); return initiator .translateToServiceRequest((model) -> Translator.translateToListRequest(request.getNextToken())) .makeServiceCall((awsRequest, sdkProxyClient) -> sdkProxyClient.injectCredentialsAndInvokeV2(awsRequest, sdkProxyClient.client()::listTypes)) .done((listTypesRequest, listTypesResponse, sdkProxyClient, model, cc) -> ProgressEvent.<ResourceModel, CallbackContext>builder() .status(OperationStatus.SUCCESS) .resourceModels(Translator.translateFromListResponse(listTypesResponse)) .nextToken(listTypesResponse.nextToken()) .build() ); }  @Override ProgressEvent<ResourceModel, CallbackContext> handleRequest(
        final AmazonWebServicesClientProxy proxy,
        final ResourceHandlerRequest<ResourceModel> request,
        final CallbackContext callbackContext,
        final ProxyClient<CloudFormationClient> proxyClient,
        final Logger logger);  }