/** * Construct an exception with the provided message. * * @param message the exception message */ public ServiceBrokerInvalidParametersException(String message) { super(prependMessagePrefix(message)); }
@Override public Mono<CreateServiceInstanceResponse> createServiceInstance( CreateServiceInstanceRequest request) { if (request.getServiceDefinitionId() == null) { return Mono.error(new ServiceBrokerInvalidParametersException("arrrr")); } return Mono.just(CreateServiceInstanceResponse.builder().build()); }
@ExceptionHandler(ServiceBrokerInvalidParametersException.class) public ResponseEntity<ErrorMessage> handleException(ServiceBrokerInvalidParametersException ex) { log.debug("Invalid parameters received: ", ex); return getErrorResponse(ex.getMessage(), HttpStatus.UNPROCESSABLE_ENTITY); }
@Override public Mono<UpdateServiceInstanceResponse> updateServiceInstance( UpdateServiceInstanceRequest request) { if (request.getServiceDefinitionId() == null) { return Mono.error(new ServiceBrokerInvalidParametersException("arrrr")); } return Mono.just(UpdateServiceInstanceResponse.builder().build()); }
/** * Construct an exception with the provided message and cause. * * @param message the exception message * @param cause the cause of the exception */ public ServiceBrokerInvalidParametersException(String message, Throwable cause) { super(prependMessagePrefix(message), cause); }
@Override public Mono<GetLastServiceOperationResponse> getLastOperation(GetLastServiceOperationRequest request) { if (request.getServiceDefinitionId() == null) { return Mono.error(new ServiceBrokerInvalidParametersException("arrrr")); } return Mono.just(GetLastServiceOperationResponse.builder().build()); } }
/** * Construct an exception with the provided error code and message. * * @param errorCode a single word in camel case that uniquely identifies the error condition * @param message the exception message */ public ServiceBrokerInvalidParametersException(String errorCode, String message) { super(errorCode, prependMessagePrefix(message)); }
@Test public void serviceBrokerInvalidParametersException() { ServiceBrokerInvalidParametersException exception = new ServiceBrokerInvalidParametersException("test message"); ErrorMessage errorMessage = exceptionHandler.handleException(exception); assertThat(errorMessage.getError()).isNull(); assertThat(errorMessage.getMessage()).contains("test message"); }
/** * Construct an exception with the provided error code, message and cause. * * @param errorCode a single word in camel case that uniquely identifies the error condition * @param message the exception message * @param cause the cause of the exception */ public ServiceBrokerInvalidParametersException(String errorCode, String message, Throwable cause) { super(errorCode, prependMessagePrefix(message), cause); }
@Test public void createServiceInstanceWithInvalidParametersFails() { setupCatalogService(); setupServiceInstanceService(new ServiceBrokerInvalidParametersException("invalid parameters description")); client.put().uri(buildCreateUpdateUrl()) .contentType(MediaType.APPLICATION_JSON) .syncBody(createRequestBody) .accept(MediaType.APPLICATION_JSON) .exchange() .expectStatus().is4xxClientError() .expectStatus().isEqualTo(HttpStatus.UNPROCESSABLE_ENTITY) .expectBody() .jsonPath("$.description").isNotEmpty() .consumeWith(result -> assertDescriptionContains(result, "invalid parameters description")); }
/** * Construct an exception with the provided error code and message. * * @param errorCode a single word in camel case that uniquely identifies the error condition * @param message the exception message */ public ServiceBrokerInvalidParametersException(String errorCode, String message) { super(errorCode, prependMessagePrefix(message)); }
@Test public void createServiceInstanceWithInvalidParametersFails() throws Exception { setupCatalogService(); setupServiceInstanceService(new ServiceBrokerInvalidParametersException("invalid parameters description")); MvcResult mvcResult = mockMvc.perform(put(buildCreateUpdateUrl()) .content(createRequestBody) .contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON)) .andExpect(request().asyncStarted()) .andReturn(); mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isUnprocessableEntity()) .andExpect(jsonPath("$.description", endsWith("invalid parameters description"))); }
/** * Construct an exception with the provided message. * * @param message the exception message */ public ServiceBrokerInvalidParametersException(String message) { super(prependMessagePrefix(message)); }
/** * Construct an exception with the provided message and cause. * * @param message the exception message * @param cause the cause of the exception */ public ServiceBrokerInvalidParametersException(String message, Throwable cause) { super(prependMessagePrefix(message), cause); }
/** * Construct an exception with the provided error code, message and cause. * * @param errorCode a single word in camel case that uniquely identifies the error condition * @param message the exception message * @param cause the cause of the exception */ public ServiceBrokerInvalidParametersException(String errorCode, String message, Throwable cause) { super(errorCode, prependMessagePrefix(message), cause); }