@Test public void handleRequest_SelfManagedSS_Success() { when(proxyClient.client().listStackSets(any(ListStackSetsRequest.class))) .thenReturn(LIST_STACK_SETS_RESPONSE); when(proxyClient.client().describeStackSet(any(DescribeStackSetRequest.class))) .thenReturn(DESCRIBE_SELF_MANAGED_STACK_SET_RESPONSE); when(proxyClient.client().listStackInstances(any(ListStackInstancesRequest.class))) .thenReturn(LIST_SELF_MANAGED_STACK_SET_RESPONSE); when(proxyClient.client().describeStackInstance(any(DescribeStackInstanceRequest.class))) .thenReturn(DESCRIBE_STACK_INSTANCE_RESPONSE_1, DESCRIBE_STACK_INSTANCE_RESPONSE_2, DESCRIBE_STACK_INSTANCE_RESPONSE_3, DESCRIBE_STACK_INSTANCE_RESPONSE_4); final ProgressEvent<ResourceModel, CallbackContext> response = handler.handleRequest(proxy, request, new CallbackContext(), proxyClient, logger); 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()).containsExactly(SELF_MANAGED_MODEL_FOR_READ); assertThat(response.getMessage()).isNull(); assertThat(response.getErrorCode()).isNull(); verify(proxyClient.client()).listStackSets(any(ListStackSetsRequest.class)); verify(proxyClient.client()).describeStackSet(any(DescribeStackSetRequest.class)); verify(proxyClient.client()).listStackInstances(any(ListStackInstancesRequest.class)); verify(proxyClient.client(), times(4)).describeStackInstance(any(DescribeStackInstanceRequest.class)); }
@Override protected ProgressEvent<ResourceModel, CallbackContext> handleRequest( final AmazonWebServicesClientProxy proxy, final ResourceHandlerRequest<ResourceModel> request, final CallbackContext callbackContext, final ProxyClient<CloudFormationClient> proxyClient, final Logger logger) { final ListStackSetsResponse response = proxyClient.injectCredentialsAndInvokeV2( listStackSetsRequest(request.getNextToken()), proxyClient.client()::listStackSets); final List<ResourceModel> models = response .summaries() .stream() .map(stackSetSummary -> ResourceModelBuilder.builder() .proxyClient(proxyClient) .stackSet(describeStackSet(proxyClient, stackSetSummary.stackSetId())) .build().buildModel()) .collect(Collectors.toList()); return ProgressEvent.<ResourceModel, CallbackContext>builder() .resourceModels(models) .status(OperationStatus.SUCCESS) .nextToken(response.nextToken()) .build(); }
ListHandler extends BaseHandlerStd { @Override protected ProgressEvent<ResourceModel, CallbackContext> handleRequest( final AmazonWebServicesClientProxy proxy, final ResourceHandlerRequest<ResourceModel> request, final CallbackContext callbackContext, final ProxyClient<CloudFormationClient> proxyClient, final Logger logger) { final ListStackSetsResponse response = proxyClient.injectCredentialsAndInvokeV2( listStackSetsRequest(request.getNextToken()), proxyClient.client()::listStackSets); final List<ResourceModel> models = response .summaries() .stream() .map(stackSetSummary -> ResourceModelBuilder.builder() .proxyClient(proxyClient) .stackSet(describeStackSet(proxyClient, stackSetSummary.stackSetId())) .build().buildModel()) .collect(Collectors.toList()); return ProgressEvent.<ResourceModel, CallbackContext>builder() .resourceModels(models) .status(OperationStatus.SUCCESS) .nextToken(response.nextToken()) .build(); } }
ListHandler extends BaseHandlerStd { @Override protected ProgressEvent<ResourceModel, CallbackContext> handleRequest( final AmazonWebServicesClientProxy proxy, final ResourceHandlerRequest<ResourceModel> request, final CallbackContext callbackContext, final ProxyClient<CloudFormationClient> proxyClient, final Logger logger) { final ListStackSetsResponse response = proxyClient.injectCredentialsAndInvokeV2( listStackSetsRequest(request.getNextToken()), proxyClient.client()::listStackSets); final List<ResourceModel> models = response .summaries() .stream() .map(stackSetSummary -> ResourceModelBuilder.builder() .proxyClient(proxyClient) .stackSet(describeStackSet(proxyClient, stackSetSummary.stackSetId())) .build().buildModel()) .collect(Collectors.toList()); return ProgressEvent.<ResourceModel, CallbackContext>builder() .resourceModels(models) .status(OperationStatus.SUCCESS) .nextToken(response.nextToken()) .build(); }  }
ListHandler extends BaseHandlerStd { @Override protected ProgressEvent<ResourceModel, CallbackContext> handleRequest( final AmazonWebServicesClientProxy proxy, final ResourceHandlerRequest<ResourceModel> request, final CallbackContext callbackContext, final ProxyClient<CloudFormationClient> proxyClient, final Logger logger) { final ListStackSetsResponse response = proxyClient.injectCredentialsAndInvokeV2( listStackSetsRequest(request.getNextToken()), proxyClient.client()::listStackSets); final List<ResourceModel> models = response .summaries() .stream() .map(stackSetSummary -> ResourceModelBuilder.builder() .proxyClient(proxyClient) .stackSet(describeStackSet(proxyClient, stackSetSummary.stackSetId())) .build().buildModel()) .collect(Collectors.toList()); return ProgressEvent.<ResourceModel, CallbackContext>builder() .resourceModels(models) .status(OperationStatus.SUCCESS) .nextToken(response.nextToken()) .build(); }   }
ListHandler extends BaseHandlerStd { @Override protected ProgressEvent<ResourceModel, CallbackContext> handleRequest( final AmazonWebServicesClientProxy proxy, final ResourceHandlerRequest<ResourceModel> request, final CallbackContext callbackContext, final ProxyClient<CloudFormationClient> proxyClient, final Logger logger) { final ListStackSetsResponse response = proxyClient.injectCredentialsAndInvokeV2( listStackSetsRequest(request.getNextToken()), proxyClient.client()::listStackSets); final List<ResourceModel> models = response .summaries() .stream() .map(stackSetSummary -> ResourceModelBuilder.builder() .proxyClient(proxyClient) .stackSet(describeStackSet(proxyClient, stackSetSummary.stackSetId())) .build().buildModel()) .collect(Collectors.toList()); return ProgressEvent.<ResourceModel, CallbackContext>builder() .resourceModels(models) .status(OperationStatus.SUCCESS) .nextToken(response.nextToken()) .build(); }    }