@Test public void requestWithDefaultsIsBuilt() { DeleteServiceInstanceBindingRequest request = DeleteServiceInstanceBindingRequest.builder() .build(); assertThat(request.getServiceInstanceId()).isNull(); assertThat(request.getServiceDefinitionId()).isNull(); assertThat(request.getPlanId()).isNull(); assertThat(request.getBindingId()).isNull(); assertThat(request.getServiceDefinition()).isNull(); assertThat(request.isAsyncAccepted()).isEqualTo(false); assertThat(request.getApiInfoLocation()).isNull(); assertThat(request.getPlatformInstanceId()).isNull(); assertThat(request.getOriginatingIdentity()).isNull(); }
/** * Construct a {@link DeleteServiceInstanceBindingRequest} from the provided values. * * @return the newly constructed {@literal DeleteServiceInstanceBindingRequest} */ public DeleteServiceInstanceBindingRequest build() { return new DeleteServiceInstanceBindingRequest(serviceInstanceId, serviceDefinitionId, planId, bindingId, serviceDefinition, plan, asyncAccepted, platformInstanceId, apiInfoLocation, originatingIdentity); } }
@Override public final boolean equals(Object o) { if (this == o) return true; if (!(o instanceof DeleteServiceInstanceBindingRequest)) return false; if (!super.equals(o)) return false; DeleteServiceInstanceBindingRequest that = (DeleteServiceInstanceBindingRequest) o; return that.canEqual(this) && Objects.equals(serviceInstanceId, that.serviceInstanceId) && Objects.equals(bindingId, that.bindingId) && Objects.equals(serviceDefinitionId, that.serviceDefinitionId) && Objects.equals(planId, that.planId) && Objects.equals(serviceDefinition, that.serviceDefinition) && Objects.equals(plan, that.plan); }
.switchIfEmpty(Mono.just(ServiceDefinition.builder().build())) .flatMap(serviceDefinition -> getServiceDefinitionPlan(serviceDefinition, planId) .map(DeleteServiceInstanceBindingRequest.builder()::plan) .switchIfEmpty(Mono.just(DeleteServiceInstanceBindingRequest.builder())) .map(builder -> builder .serviceInstanceId(serviceInstanceId)
@Test public void deleteBindingFiltersPlansSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceBindingService(DeleteServiceInstanceBindingResponse.builder() .build()); client.delete().uri(buildDeleteUrl(PLATFORM_INSTANCE_ID, false)) .header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION) .header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()) .exchange() .expectStatus().isOk() .expectBody() .json("{}"); verify(serviceInstanceBindingService).deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class)); DeleteServiceInstanceBindingRequest actualRequest = verifyDeleteBinding(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false); assertThat(actualRequest.getPlan().getId()).isEqualTo(actualRequest.getPlanId()); assertHeaderValuesSet(actualRequest); }
@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 deleteBindingWithoutAsyncAndHeadersSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceBindingService(DeleteServiceInstanceBindingResponse.builder() .build()); client.delete().uri(buildDeleteUrl(PLATFORM_INSTANCE_ID, false)) .header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION) .header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()) .exchange() .expectStatus().isOk() .expectBody() .json("{}"); verify(serviceInstanceBindingService).deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class)); DeleteServiceInstanceBindingRequest actualRequest = verifyDeleteBinding(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false); assertHeaderValuesSet(actualRequest); }
@Override public Mono<Void> error(CreateServiceInstanceBindingRequest request, Throwable t) { return results.setErrorCreate("error create " + request.getServiceInstanceId()); } }))
@Override public Mono<DeleteServiceInstanceBindingResponse> deleteServiceInstanceBinding(DeleteServiceInstanceBindingRequest request) { if (request.getBindingId() == null) { return Mono.error(new ServiceInstanceBindingDoesNotExistException("bar")); } return Mono.just(DeleteServiceInstanceBindingResponse.builder().build()); }
@Test(expected = UnsupportedOperationException.class) public void deleteServiceInstanceBinding() { service.deleteServiceInstanceBinding(DeleteServiceInstanceBindingRequest.builder().build()) .block(); }
@Test public void deleteBindingFiltersPlansSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceBindingService(DeleteServiceInstanceBindingResponse .builder() .build()); MvcResult mvcResult = mockMvc .perform(delete(buildDeleteUrl(PLATFORM_INSTANCE_ID, false)) .header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION) .header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()) .contentType(MediaType.APPLICATION_JSON)) .andExpect(request().asyncStarted()) .andExpect(status().isOk()) .andReturn(); mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isOk()) .andExpect(content().string("{}")); verify(serviceInstanceBindingService).deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class)); DeleteServiceInstanceBindingRequest actualRequest = verifyDeleteBinding(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false); assertThat(actualRequest.getPlan().getId()).isEqualTo(actualRequest.getPlanId()); assertHeaderValuesSet(actualRequest); }
@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); }
@Override public Mono<Void> initialize(CreateServiceInstanceBindingRequest request) { return results.setBeforeCreate("before create " + request.getServiceInstanceId()); @Override public Mono<Void> complete(CreateServiceInstanceBindingRequest request, CreateServiceInstanceBindingResponse response) { return results.setAfterCreate("after create " + request.getServiceInstanceId());
@Test public void requestWithAllValuesIsBuilt() { Context originatingIdentity = PlatformContext.builder() .platform("test-platform") .build(); DeleteServiceInstanceBindingRequest request = DeleteServiceInstanceBindingRequest.builder() .serviceInstanceId("service-instance-id") .serviceDefinitionId("service-definition-id") .planId("plan-id") .bindingId("binding-id") .asyncAccepted(true) .platformInstanceId("platform-instance-id") .apiInfoLocation("https://api.example.com") .originatingIdentity(originatingIdentity) .build(); assertThat(request.getServiceInstanceId()).isEqualTo("service-instance-id"); assertThat(request.getServiceDefinitionId()).isEqualTo("service-definition-id"); assertThat(request.getPlanId()).isEqualTo("plan-id"); assertThat(request.getBindingId()).isEqualTo("binding-id"); assertThat(request.isAsyncAccepted()).isEqualTo(true); assertThat(request.getPlatformInstanceId()).isEqualTo("platform-instance-id"); assertThat(request.getApiInfoLocation()).isEqualTo("https://api.example.com"); assertThat(request.getOriginatingIdentity()).isEqualTo(originatingIdentity); }
Plan plan = getServiceDefinitionPlan(serviceDefinition, planId); DeleteServiceInstanceBindingRequest request = DeleteServiceInstanceBindingRequest .builder() .serviceInstanceId(serviceInstanceId) .bindingId(bindingId)
@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); }
/** * Construct a {@link DeleteServiceInstanceBindingRequest} from the provided values. * * @return the newly constructed {@literal DeleteServiceInstanceBindingRequest} */ public DeleteServiceInstanceBindingRequest build() { return new DeleteServiceInstanceBindingRequest(serviceInstanceId, serviceDefinitionId, planId, bindingId, serviceDefinition, plan, asyncAccepted, platformInstanceId, apiInfoLocation, originatingIdentity); } }
@Override public final boolean equals(Object o) { if (this == o) return true; if (!(o instanceof DeleteServiceInstanceBindingRequest)) return false; if (!super.equals(o)) return false; DeleteServiceInstanceBindingRequest that = (DeleteServiceInstanceBindingRequest) o; return that.canEqual(this) && Objects.equals(serviceInstanceId, that.serviceInstanceId) && Objects.equals(bindingId, that.bindingId) && Objects.equals(serviceDefinitionId, that.serviceDefinitionId) && Objects.equals(planId, that.planId) && Objects.equals(serviceDefinition, that.serviceDefinition) && Objects.equals(plan, that.plan); }
@Test public void deleteServiceInstanceBindingFails() { prepareBindingFlows(); StepVerifier .create(serviceInstanceBindingEventService.deleteServiceInstanceBinding( DeleteServiceInstanceBindingRequest.builder() .serviceInstanceId("foo") .build())) .expectError() .verify(); assertThat(this.results.getBeforeCreate()).isNullOrEmpty(); assertThat(this.results.getAfterCreate()).isNullOrEmpty(); assertThat(this.results.getErrorCreate()).isNullOrEmpty(); assertThat(this.results.getBeforeDelete()).isEqualTo("before delete foo"); assertThat(this.results.getAfterDelete()).isNullOrEmpty(); assertThat(this.results.getErrorDelete()).isEqualTo("error delete foo"); }
@Test public void deleteBindingWithoutAsyncAndHeadersSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceBindingService(DeleteServiceInstanceBindingResponse.builder() .build()); MvcResult mvcResult = mockMvc.perform(delete(buildDeleteUrl(PLATFORM_INSTANCE_ID, false)) .header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION) .header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()) .contentType(MediaType.APPLICATION_JSON)) .andExpect(request().asyncStarted()) .andExpect(status().isOk()) .andReturn(); mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isOk()) .andExpect(content().string("{}")); verify(serviceInstanceBindingService).deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class)); DeleteServiceInstanceBindingRequest actualRequest = verifyDeleteBinding(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false); assertHeaderValuesSet(actualRequest); }