@Test public void responseWithAllValuesIsBuilt() { DeleteServiceInstanceBindingResponse response = DeleteServiceInstanceBindingResponse.builder() .async(true) .operation("in progress") .build(); assertThat(response.isAsync()).isEqualTo(true); assertThat(response.getOperation()).isEqualTo("in progress"); }
@Override public Mono<DeleteServiceInstanceBindingResponse> deleteServiceInstanceBinding(DeleteServiceInstanceBindingRequest request) { String serviceInstanceId = request.getServiceInstanceId(); String bindingId = request.getBindingId(); // // delete any binding-specific credentials // return Mono.just(DeleteServiceInstanceBindingResponse.builder() .async(true) .build()); }
@Test public void deleteBindingWithAsyncAndHeadersSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceBindingService(DeleteServiceInstanceBindingResponse.builder() .async(true) .operation("working") .build()); client.delete().uri(buildDeleteUrl(PLATFORM_INSTANCE_ID, true)) .header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION) .header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()) .exchange() .expectStatus().isAccepted() .expectBody() .jsonPath("$.operation").isEqualTo("working"); verify(serviceInstanceBindingService).deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class)); DeleteServiceInstanceBindingRequest actualRequest = verifyDeleteBinding(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(true); assertHeaderValuesSet(actualRequest); }
@DataPoints("deleteResponsesWithExpectedStatus") public static List<DeleteResponseAndExpectedStatus> deleteDataPoints() { return Arrays.asList( new DeleteResponseAndExpectedStatus( null, HttpStatus.OK ), new DeleteResponseAndExpectedStatus( DeleteServiceInstanceBindingResponse.builder() .async(false) .build(), HttpStatus.OK ), new DeleteResponseAndExpectedStatus( DeleteServiceInstanceBindingResponse.builder() .async(true) .operation("deleting") .build(), HttpStatus.ACCEPTED ) ); }
@Test public void deleteBindingWithAsyncAndHeadersSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceBindingService(DeleteServiceInstanceBindingResponse.builder() .async(true) .operation("working") .build()); MvcResult mvcResult = mockMvc.perform(delete(buildDeleteUrl(PLATFORM_INSTANCE_ID, true)) .header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION) .header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()) .accept(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)) .andExpect(request().asyncStarted()) .andExpect(status().isOk()) .andReturn(); mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isAccepted()) .andExpect(jsonPath("$.operation", equalTo("working"))); verify(serviceInstanceBindingService).deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class)); DeleteServiceInstanceBindingRequest actualRequest = verifyDeleteBinding(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(true); assertHeaderValuesSet(actualRequest); }