Search in sources :

Example 6 with ServiceInstanceDoesNotExistException

use of org.springframework.cloud.servicebroker.exception.ServiceInstanceDoesNotExistException in project spring-cloud-open-service-broker by spring-cloud.

the class ServiceInstanceBindingControllerIntegrationTest method deleteBindingWithUnknownInstanceIdFails.

@Test
void deleteBindingWithUnknownInstanceIdFails() throws Exception {
    setupCatalogService();
    doThrow(new ServiceInstanceDoesNotExistException(SERVICE_INSTANCE_ID)).when(serviceInstanceBindingService).deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class));
    MvcResult mvcResult = mockMvc.perform(delete(buildDeleteUrl()).contentType(MediaType.APPLICATION_JSON)).andExpect(request().asyncStarted()).andReturn();
    mockMvc.perform(asyncDispatch(mvcResult)).andExpect(status().isUnprocessableEntity()).andExpect(jsonPath("$.description", containsString(SERVICE_INSTANCE_ID)));
}
Also used : ServiceInstanceDoesNotExistException(org.springframework.cloud.servicebroker.exception.ServiceInstanceDoesNotExistException) DeleteServiceInstanceBindingRequest(org.springframework.cloud.servicebroker.model.binding.DeleteServiceInstanceBindingRequest) MvcResult(org.springframework.test.web.servlet.MvcResult) AbstractServiceInstanceBindingControllerIntegrationTest(org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceBindingControllerIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 7 with ServiceInstanceDoesNotExistException

use of org.springframework.cloud.servicebroker.exception.ServiceInstanceDoesNotExistException in project spring-cloud-open-service-broker by spring-cloud.

the class ServiceInstanceControllerIntegrationTest method deleteServiceInstanceWithUnknownIdFails.

@Test
void deleteServiceInstanceWithUnknownIdFails() throws Exception {
    setupCatalogService();
    setupServiceInstanceService(new ServiceInstanceDoesNotExistException(SERVICE_INSTANCE_ID));
    MvcResult mvcResult = mockMvc.perform(delete(buildDeleteUrl()).accept(MediaType.APPLICATION_JSON)).andExpect(request().asyncStarted()).andReturn();
    mockMvc.perform(asyncDispatch(mvcResult)).andExpect(status().isGone());
}
Also used : ServiceInstanceDoesNotExistException(org.springframework.cloud.servicebroker.exception.ServiceInstanceDoesNotExistException) MvcResult(org.springframework.test.web.servlet.MvcResult) AbstractServiceInstanceControllerIntegrationTest(org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceControllerIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 8 with ServiceInstanceDoesNotExistException

use of org.springframework.cloud.servicebroker.exception.ServiceInstanceDoesNotExistException in project spring-cloud-open-service-broker by spring-cloud.

the class ServiceInstanceControllerIntegrationTest method lastOperationWithUnknownInstanceBadRequest.

@Test
void lastOperationWithUnknownInstanceBadRequest() throws Exception {
    setupServiceInstanceServiceLastOperation(new ServiceInstanceDoesNotExistException("nonexistent-instance-id"));
    MvcResult mvcResult = mockMvc.perform(get(buildLastOperationUrl())).andExpect(request().asyncStarted()).andReturn();
    mockMvc.perform(asyncDispatch(mvcResult)).andExpect(status().isBadRequest()).andExpect(jsonPath("$.state").doesNotExist()).andExpect(jsonPath("$.description", containsString("The requested Service Instance does not exist")));
}
Also used : ServiceInstanceDoesNotExistException(org.springframework.cloud.servicebroker.exception.ServiceInstanceDoesNotExistException) MvcResult(org.springframework.test.web.servlet.MvcResult) AbstractServiceInstanceControllerIntegrationTest(org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceControllerIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 9 with ServiceInstanceDoesNotExistException

use of org.springframework.cloud.servicebroker.exception.ServiceInstanceDoesNotExistException in project spring-cloud-open-service-broker by spring-cloud.

the class ServiceInstanceBindingControllerIntegrationTest method deleteBindingWithUnknownInstanceIdFails.

@Test
void deleteBindingWithUnknownInstanceIdFails() {
    setupCatalogService();
    given(serviceInstanceBindingService.deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class))).willThrow(new ServiceInstanceDoesNotExistException(SERVICE_INSTANCE_ID));
    client.delete().uri(buildDeleteUrl()).exchange().expectStatus().is4xxClientError().expectStatus().isEqualTo(HttpStatus.UNPROCESSABLE_ENTITY).expectBody().jsonPath("$.description").isNotEmpty().consumeWith(result -> assertDescriptionContains(result, SERVICE_INSTANCE_ID));
}
Also used : ServiceInstanceDoesNotExistException(org.springframework.cloud.servicebroker.exception.ServiceInstanceDoesNotExistException) DeleteServiceInstanceBindingRequest(org.springframework.cloud.servicebroker.model.binding.DeleteServiceInstanceBindingRequest) AbstractServiceInstanceBindingControllerIntegrationTest(org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceBindingControllerIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 10 with ServiceInstanceDoesNotExistException

use of org.springframework.cloud.servicebroker.exception.ServiceInstanceDoesNotExistException in project spring-cloud-open-service-broker by spring-cloud.

the class ServiceBrokerExceptionHandlerTest method serviceInstanceDoesNotExistException.

@Test
void serviceInstanceDoesNotExistException() {
    ServiceInstanceDoesNotExistException exception = new ServiceInstanceDoesNotExistException("service-instance-id");
    ErrorMessage errorMessage = exceptionHandler.handleException(exception);
    assertThat(errorMessage.getError()).isNull();
    assertThat(errorMessage.getMessage()).contains("id=service-instance-id");
}
Also used : ServiceInstanceDoesNotExistException(org.springframework.cloud.servicebroker.exception.ServiceInstanceDoesNotExistException) ErrorMessage(org.springframework.cloud.servicebroker.model.error.ErrorMessage) Test(org.junit.jupiter.api.Test)

Aggregations

ServiceInstanceDoesNotExistException (org.springframework.cloud.servicebroker.exception.ServiceInstanceDoesNotExistException)13 Test (org.junit.jupiter.api.Test)10 AbstractServiceInstanceBindingControllerIntegrationTest (org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceBindingControllerIntegrationTest)4 AbstractServiceInstanceControllerIntegrationTest (org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceControllerIntegrationTest)4 MvcResult (org.springframework.test.web.servlet.MvcResult)4 Test (org.junit.Test)2 CreateServiceInstanceBindingRequest (org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceBindingRequest)2 DeleteServiceInstanceBindingRequest (org.springframework.cloud.servicebroker.model.binding.DeleteServiceInstanceBindingRequest)2 ErrorMessage (org.springframework.cloud.servicebroker.model.error.ErrorMessage)2 DeleteServiceInstanceRequest (org.springframework.cloud.servicebroker.model.instance.DeleteServiceInstanceRequest)2 DeleteServiceInstanceResponse (org.springframework.cloud.servicebroker.model.instance.DeleteServiceInstanceResponse)2 GetServiceInstanceBindingRequest (org.springframework.cloud.servicebroker.model.binding.GetServiceInstanceBindingRequest)1 GetServiceInstanceBindingResponse (org.springframework.cloud.servicebroker.model.binding.GetServiceInstanceBindingResponse)1 ServiceDefinition (org.springframework.cloud.servicebroker.model.catalog.ServiceDefinition)1 ResponseEntity (org.springframework.http.ResponseEntity)1 DeleteMapping (org.springframework.web.bind.annotation.DeleteMapping)1