Search in sources :

Example 1 with ServiceBrokerOperationInProgressException

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

the class ServiceInstanceControllerIntegrationTest method getServiceInstanceWithOperationInProgressFails.

@Test
void getServiceInstanceWithOperationInProgressFails() throws Exception {
    setupServiceInstanceService(new ServiceBrokerOperationInProgressException("task_10"));
    client.get().uri(buildGetUrl(PLATFORM_INSTANCE_ID)).header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION).header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()).accept(MediaType.APPLICATION_JSON).exchange().expectStatus().isNotFound().expectBody().consumeWith(result -> assertDescriptionContains(result, "operation=task_10"));
}
Also used : ServiceBrokerOperationInProgressException(org.springframework.cloud.servicebroker.exception.ServiceBrokerOperationInProgressException) AbstractServiceInstanceControllerIntegrationTest(org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceControllerIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 2 with ServiceBrokerOperationInProgressException

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

the class ServiceInstanceBindingControllerIntegrationTest method getBindingWithOperationInProgressFails.

@Test
void getBindingWithOperationInProgressFails() throws Exception {
    given(serviceInstanceBindingService.getServiceInstanceBinding(any(GetServiceInstanceBindingRequest.class))).willThrow(new ServiceBrokerOperationInProgressException("task_10"));
    MvcResult mvcResult = mockMvc.perform(get(buildCreateUrl()).accept(MediaType.APPLICATION_JSON).contentType(MediaType.APPLICATION_JSON)).andExpect(request().asyncStarted()).andReturn();
    mockMvc.perform(asyncDispatch(mvcResult)).andExpect(status().isNotFound());
}
Also used : ServiceBrokerOperationInProgressException(org.springframework.cloud.servicebroker.exception.ServiceBrokerOperationInProgressException) GetServiceInstanceBindingRequest(org.springframework.cloud.servicebroker.model.binding.GetServiceInstanceBindingRequest) MvcResult(org.springframework.test.web.servlet.MvcResult) AbstractServiceInstanceBindingControllerIntegrationTest(org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceBindingControllerIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 3 with ServiceBrokerOperationInProgressException

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

the class BaseControllerTest method operationInProgressExceptionGivesExpectedStatus.

@Test
public void operationInProgressExceptionGivesExpectedStatus() {
    ServiceBrokerOperationInProgressException exception = new ServiceBrokerOperationInProgressException("still working");
    ResponseEntity<ErrorMessage> responseEntity = controller.handleException(exception);
    assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
    assertThat(responseEntity.getBody().getError()).isNull();
    assertThat(responseEntity.getBody().getMessage()).contains("still working");
}
Also used : ServiceBrokerOperationInProgressException(org.springframework.cloud.servicebroker.exception.ServiceBrokerOperationInProgressException) ErrorMessage(org.springframework.cloud.servicebroker.model.error.ErrorMessage) Test(org.junit.Test)

Example 4 with ServiceBrokerOperationInProgressException

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

the class ServiceBrokerExceptionHandlerTest method operationInProgressException.

@Test
void operationInProgressException() {
    ServiceBrokerOperationInProgressException exception = new ServiceBrokerOperationInProgressException("task_10");
    ErrorMessage errorMessage = exceptionHandler.handleException(exception);
    assertThat(errorMessage.getError()).isNull();
    assertThat(errorMessage.getMessage()).contains("task_10");
}
Also used : ServiceBrokerOperationInProgressException(org.springframework.cloud.servicebroker.exception.ServiceBrokerOperationInProgressException) ErrorMessage(org.springframework.cloud.servicebroker.model.error.ErrorMessage) Test(org.junit.jupiter.api.Test)

Example 5 with ServiceBrokerOperationInProgressException

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

the class ServiceInstanceControllerIntegrationTest method getServiceInstanceWithOperationInProgressFails.

@Test
void getServiceInstanceWithOperationInProgressFails() throws Exception {
    setupServiceInstanceService(new ServiceBrokerOperationInProgressException("task_10"));
    MvcResult mvcResult = mockMvc.perform(get(buildGetUrl(PLATFORM_INSTANCE_ID)).header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION).header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()).contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)).andExpect(request().asyncStarted()).andReturn();
    mockMvc.perform(asyncDispatch(mvcResult)).andExpect(status().isNotFound()).andExpect(jsonPath("$.description", containsString("task_10")));
}
Also used : ServiceBrokerOperationInProgressException(org.springframework.cloud.servicebroker.exception.ServiceBrokerOperationInProgressException) MvcResult(org.springframework.test.web.servlet.MvcResult) AbstractServiceInstanceControllerIntegrationTest(org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceControllerIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

ServiceBrokerOperationInProgressException (org.springframework.cloud.servicebroker.exception.ServiceBrokerOperationInProgressException)6 Test (org.junit.jupiter.api.Test)5 AbstractServiceInstanceBindingControllerIntegrationTest (org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceBindingControllerIntegrationTest)2 AbstractServiceInstanceControllerIntegrationTest (org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceControllerIntegrationTest)2 GetServiceInstanceBindingRequest (org.springframework.cloud.servicebroker.model.binding.GetServiceInstanceBindingRequest)2 ErrorMessage (org.springframework.cloud.servicebroker.model.error.ErrorMessage)2 MvcResult (org.springframework.test.web.servlet.MvcResult)2 Test (org.junit.Test)1