Search in sources :

Example 11 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() {
    setupServiceInstanceServiceLastOperation(new ServiceInstanceDoesNotExistException("nonexistent-instance-id"));
    client.get().uri(buildLastOperationUrl()).accept(MediaType.APPLICATION_JSON).exchange().expectStatus().is4xxClientError().expectStatus().isEqualTo(HttpStatus.BAD_REQUEST).expectBody().jsonPath("$.state").doesNotExist().jsonPath("$.description").value(containsString("The requested Service Instance does not exist"));
}
Also used : ServiceInstanceDoesNotExistException(org.springframework.cloud.servicebroker.exception.ServiceInstanceDoesNotExistException) AbstractServiceInstanceControllerIntegrationTest(org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceControllerIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 12 with ServiceInstanceDoesNotExistException

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

the class ServiceInstanceBindingControllerIntegrationTest method createBindingWithUnknownServiceInstanceIdFails.

@Test
void createBindingWithUnknownServiceInstanceIdFails() throws Exception {
    setupCatalogService();
    given(serviceInstanceBindingService.createServiceInstanceBinding(any(CreateServiceInstanceBindingRequest.class))).willThrow(new ServiceInstanceDoesNotExistException(SERVICE_INSTANCE_ID));
    MvcResult mvcResult = mockMvc.perform(put(buildCreateUrl()).content(createRequestBody).accept(MediaType.APPLICATION_JSON).contentType(MediaType.APPLICATION_JSON)).andExpect(request().asyncStarted()).andReturn();
    mockMvc.perform(asyncDispatch(mvcResult)).andExpect(status().isUnprocessableEntity()).andExpect(jsonPath("$.description", containsString(SERVICE_INSTANCE_ID)));
}
Also used : CreateServiceInstanceBindingRequest(org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceBindingRequest) ServiceInstanceDoesNotExistException(org.springframework.cloud.servicebroker.exception.ServiceInstanceDoesNotExistException) MvcResult(org.springframework.test.web.servlet.MvcResult) AbstractServiceInstanceBindingControllerIntegrationTest(org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceBindingControllerIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 13 with ServiceInstanceDoesNotExistException

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

the class ServiceInstanceBindingControllerIntegrationTest method createBindingWithUnknownServiceInstanceIdFails.

@Test
void createBindingWithUnknownServiceInstanceIdFails() {
    setupCatalogService();
    given(serviceInstanceBindingService.createServiceInstanceBinding(any(CreateServiceInstanceBindingRequest.class))).willThrow(new ServiceInstanceDoesNotExistException(SERVICE_INSTANCE_ID));
    client.put().uri(buildCreateUrl()).contentType(MediaType.APPLICATION_JSON).bodyValue(createRequestBody).accept(MediaType.APPLICATION_JSON).exchange().expectStatus().is4xxClientError().expectStatus().isEqualTo(HttpStatus.UNPROCESSABLE_ENTITY).expectBody().jsonPath("$.description").isNotEmpty().consumeWith(result -> assertDescriptionContains(result, String.format("id=%s", SERVICE_INSTANCE_ID)));
}
Also used : CreateServiceInstanceBindingRequest(org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceBindingRequest) ServiceInstanceDoesNotExistException(org.springframework.cloud.servicebroker.exception.ServiceInstanceDoesNotExistException) AbstractServiceInstanceBindingControllerIntegrationTest(org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceBindingControllerIntegrationTest) 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