@Test public void operationInProgressException() { ServiceBrokerOperationInProgressException exception = new ServiceBrokerOperationInProgressException("still working"); ErrorMessage errorMessage = exceptionHandler.handleException(exception); assertThat(errorMessage.getError()).isNull(); assertThat(errorMessage.getMessage()).contains("still working"); }
@Test public void getBindingWithOperationInProgressFails() throws Exception { when(serviceInstanceBindingService.getServiceInstanceBinding(any(GetServiceInstanceBindingRequest.class))) .thenThrow(new ServiceBrokerOperationInProgressException("still working")); client.get().uri(buildCreateUrl()) .accept(MediaType.APPLICATION_JSON) .exchange() .expectStatus().isNotFound(); }
@Test public void getBindingWithOperationInProgressFails() throws Exception { when(serviceInstanceBindingService.getServiceInstanceBinding(any(GetServiceInstanceBindingRequest.class))) .thenThrow(new ServiceBrokerOperationInProgressException("still working")); 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()); }
@Test public void getServiceInstanceWithOperationInProgressFails() throws Exception { setupServiceInstanceService(new ServiceBrokerOperationInProgressException("still working")); client.get().uri(buildCreateUpdateUrl(PLATFORM_INSTANCE_ID, false)) .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=still working")); }
@Test public void getServiceInstanceWithOperationInProgressFails() throws Exception { setupServiceInstanceService(new ServiceBrokerOperationInProgressException("still working")); MvcResult mvcResult = mockMvc.perform(get(buildCreateUpdateUrl(PLATFORM_INSTANCE_ID, false)) .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("still working"))); }