@Test public void handleRequest_FailedCreate_UnknownError() { final CreateHandler handler = new CreateHandler(); doThrow(SdkException.builder().message("test error").build()) .when(proxy) .injectCredentialsAndInvokeV2( any(), any() ); final ResourceModel model = ResourceModel.builder() .name("test-set") .build(); final ResourceHandlerRequest<ResourceModel> request = ResourceHandlerRequest.<ResourceModel>builder() .desiredResourceState(model) .build(); assertThrows(SdkException.class, () -> { handler.handleRequest(proxy, request, null, logger); }); }
@Override public ProgressEvent<ResourceModel, CallbackContext> handleRequest( final AmazonWebServicesClientProxy proxy, final ResourceHandlerRequest<ResourceModel> request, final CallbackContext callbackContext, final Logger logger) { final SesClient client = ClientBuilder.getClient(); final ResourceModel model = request.getDesiredResourceState(); if (StringUtils.isNullOrEmpty(model.getName())) { model.setName( IdentifierUtils.generateResourceIdentifier( request.getLogicalResourceIdentifier(), request.getClientRequestToken(), MAX_LENGTH_CONFIGURATION_SET_NAME ) ); } final CreateConfigurationSetRequest createConfigurationSetRequest = CreateConfigurationSetRequest.builder() .configurationSet(ConfigurationSet.builder() .name(model.getName()) .build()) .build(); try { proxy.injectCredentialsAndInvokeV2(createConfigurationSetRequest, client::createConfigurationSet); logger.log(String.format("%s [%s] created successfully", ResourceModel.TYPE_NAME, getPrimaryIdentifier(model).toString())); } catch (ConfigurationSetAlreadyExistsException e) { throw new CfnAlreadyExistsException(ResourceModel.TYPE_NAME, getPrimaryIdentifier(model).toString()); } catch (InvalidConfigurationSetException e) { throw new CfnInvalidRequestException(createConfigurationSetRequest.toString(), e); } catch (LimitExceededException e) { throw new CfnServiceLimitExceededException(ResourceModel.TYPE_NAME, e.toString()); } return ProgressEvent.defaultSuccessHandler(model); }
CreateHandler extends BaseHandler<CallbackContext> { @Override public ProgressEvent<ResourceModel, CallbackContext> handleRequest( final AmazonWebServicesClientProxy proxy, final ResourceHandlerRequest<ResourceModel> request, final CallbackContext callbackContext, final Logger logger) { final SesClient client = ClientBuilder.getClient(); final ResourceModel model = request.getDesiredResourceState(); if (StringUtils.isNullOrEmpty(model.getName())) { model.setName( IdentifierUtils.generateResourceIdentifier( request.getLogicalResourceIdentifier(), request.getClientRequestToken(), MAX_LENGTH_CONFIGURATION_SET_NAME ) ); } final CreateConfigurationSetRequest createConfigurationSetRequest = CreateConfigurationSetRequest.builder() .configurationSet(ConfigurationSet.builder() .name(model.getName()) .build()) .build(); try { proxy.injectCredentialsAndInvokeV2(createConfigurationSetRequest, client::createConfigurationSet); logger.log(String.format("%s [%s] created successfully", ResourceModel.TYPE_NAME, getPrimaryIdentifier(model).toString())); } catch (ConfigurationSetAlreadyExistsException e) { throw new CfnAlreadyExistsException(ResourceModel.TYPE_NAME, getPrimaryIdentifier(model).toString()); } catch (InvalidConfigurationSetException e) { throw new CfnInvalidRequestException(createConfigurationSetRequest.toString(), e); } catch (LimitExceededException e) { throw new CfnServiceLimitExceededException(ResourceModel.TYPE_NAME, e.toString()); } return ProgressEvent.defaultSuccessHandler(model); } }
CreateHandler extends BaseHandler<CallbackContext> { @Override public ProgressEvent<ResourceModel, CallbackContext> handleRequest( final AmazonWebServicesClientProxy proxy, final ResourceHandlerRequest<ResourceModel> request, final CallbackContext callbackContext, final Logger logger) { final SesClient client = ClientBuilder.getClient(); final ResourceModel model = request.getDesiredResourceState(); if (StringUtils.isNullOrEmpty(model.getName())) { model.setName( IdentifierUtils.generateResourceIdentifier( request.getLogicalResourceIdentifier(), request.getClientRequestToken(), MAX_LENGTH_CONFIGURATION_SET_NAME ) ); } final CreateConfigurationSetRequest createConfigurationSetRequest = CreateConfigurationSetRequest.builder() .configurationSet(ConfigurationSet.builder() .name(model.getName()) .build()) .build(); try { proxy.injectCredentialsAndInvokeV2(createConfigurationSetRequest, client::createConfigurationSet); logger.log(String.format("%s [%s] created successfully", ResourceModel.TYPE_NAME, getPrimaryIdentifier(model).toString())); } catch (ConfigurationSetAlreadyExistsException e) { throw new CfnAlreadyExistsException(ResourceModel.TYPE_NAME, getPrimaryIdentifier(model).toString()); } catch (InvalidConfigurationSetException e) { throw new CfnInvalidRequestException(createConfigurationSetRequest.toString(), e); } catch (LimitExceededException e) { throw new CfnServiceLimitExceededException(ResourceModel.TYPE_NAME, e.toString()); } return ProgressEvent.defaultSuccessHandler(model); }  }
CreateHandler extends BaseHandler<CallbackContext> { @Override public ProgressEvent<ResourceModel, CallbackContext> handleRequest( final AmazonWebServicesClientProxy proxy, final ResourceHandlerRequest<ResourceModel> request, final CallbackContext callbackContext, final Logger logger) { final SesClient client = ClientBuilder.getClient(); final ResourceModel model = request.getDesiredResourceState(); if (StringUtils.isNullOrEmpty(model.getName())) { model.setName( IdentifierUtils.generateResourceIdentifier( request.getLogicalResourceIdentifier(), request.getClientRequestToken(), MAX_LENGTH_CONFIGURATION_SET_NAME ) ); } final CreateConfigurationSetRequest createConfigurationSetRequest = CreateConfigurationSetRequest.builder() .configurationSet(ConfigurationSet.builder() .name(model.getName()) .build()) .build(); try { proxy.injectCredentialsAndInvokeV2(createConfigurationSetRequest, client::createConfigurationSet); logger.log(String.format("%s [%s] created successfully", ResourceModel.TYPE_NAME, getPrimaryIdentifier(model).toString())); } catch (ConfigurationSetAlreadyExistsException e) { throw new CfnAlreadyExistsException(ResourceModel.TYPE_NAME, getPrimaryIdentifier(model).toString()); } catch (InvalidConfigurationSetException e) { throw new CfnInvalidRequestException(createConfigurationSetRequest.toString(), e); } catch (LimitExceededException e) { throw new CfnServiceLimitExceededException(ResourceModel.TYPE_NAME, e.toString()); } return ProgressEvent.defaultSuccessHandler(model); }  @Override ProgressEvent<ResourceModel, CallbackContext> handleRequest(
        final AmazonWebServicesClientProxy proxy,
        final ResourceHandlerRequest<ResourceModel> request,
        final CallbackContext callbackContext,
        final Logger logger); }
CreateHandler extends BaseHandler<CallbackContext> { @Override public ProgressEvent<ResourceModel, CallbackContext> handleRequest( final AmazonWebServicesClientProxy proxy, final ResourceHandlerRequest<ResourceModel> request, final CallbackContext callbackContext, final Logger logger) { final SesClient client = ClientBuilder.getClient(); final ResourceModel model = request.getDesiredResourceState(); if (StringUtils.isNullOrEmpty(model.getName())) { model.setName( IdentifierUtils.generateResourceIdentifier( request.getLogicalResourceIdentifier(), request.getClientRequestToken(), MAX_LENGTH_CONFIGURATION_SET_NAME ) ); } final CreateConfigurationSetRequest createConfigurationSetRequest = CreateConfigurationSetRequest.builder() .configurationSet(ConfigurationSet.builder() .name(model.getName()) .build()) .build(); try { proxy.injectCredentialsAndInvokeV2(createConfigurationSetRequest, client::createConfigurationSet); logger.log(String.format("%s [%s] created successfully", ResourceModel.TYPE_NAME, getPrimaryIdentifier(model).toString())); } catch (ConfigurationSetAlreadyExistsException e) { throw new CfnAlreadyExistsException(ResourceModel.TYPE_NAME, getPrimaryIdentifier(model).toString()); } catch (InvalidConfigurationSetException e) { throw new CfnInvalidRequestException(createConfigurationSetRequest.toString(), e); } catch (LimitExceededException e) { throw new CfnServiceLimitExceededException(ResourceModel.TYPE_NAME, e.toString()); } return ProgressEvent.defaultSuccessHandler(model); }  @Override ProgressEvent<ResourceModel, CallbackContext> handleRequest(
        final AmazonWebServicesClientProxy proxy,
        final ResourceHandlerRequest<ResourceModel> request,
        final CallbackContext callbackContext,
        final Logger logger); static final int MAX_LENGTH_CONFIGURATION_SET_NAME; }