ReadHandler extends BaseHandler<CallbackContext> { @Override public ProgressEvent<ResourceModel, CallbackContext> handleRequest( final AmazonWebServicesClientProxy proxy, final ResourceHandlerRequest<ResourceModel> request, final CallbackContext callbackContext, final Logger logger) { this.proxy = proxy; this.request = request; this.logger = logger; final ResourceModel model = request.getDesiredResourceState(); final CallbackContext context = callbackContext == null ? CallbackContext.builder() .build() : callbackContext; return fetchComponentAndAssertExists(); }  @Override ProgressEvent<ResourceModel, CallbackContext> handleRequest(
        final AmazonWebServicesClientProxy proxy,
        final ResourceHandlerRequest<ResourceModel> request,
        final CallbackContext callbackContext,
        final Logger logger);  }
@Test public void handleRequest_SimpleSuccess() { final GetComponentResponse getComponentResponse = GetComponentResponse.builder() .component(TestUtil.generateComponentForTest()) .build(); doReturn(getComponentResponse) .when(proxy) .injectCredentialsAndInvokeV2(any(), any()); final ProgressEvent<ResourceModel, CallbackContext> response = handler.handleRequest(proxy, request, context, logger); assertThat(response).isNotNull(); assertThat(response.getStatus()).isEqualTo(OperationStatus.SUCCESS); assertThat(response.getCallbackContext()).isNull(); assertThat(response.getCallbackDelaySeconds()).isEqualTo(0); assertThat(response.getResourceModel()).isEqualTo(request.getDesiredResourceState()); assertThat(response.getResourceModels()).isNull(); assertThat(response.getMessage()).isNull(); assertThat(response.getErrorCode()).isNull(); }
@Test public void handleRequest_ResourceNotFound_Failure() { doThrow(ResourceNotFoundException.class) .when(proxy) .injectCredentialsAndInvokeV2(any(), any()); assertThrows(CfnNotFoundException.class, () -> handler.handleRequest(proxy, request, null, logger)); }
@Test public void handleRequest_InvalidParameter_Failure() { doThrow(InvalidParameterException.class) .when(proxy) .injectCredentialsAndInvokeV2(any(), any()); assertThrows(CfnInvalidRequestException.class, () -> handler.handleRequest(proxy, request, null, logger)); }