Java Code Examples for org.springframework.cloud.servicebroker.model.binding.DeleteServiceInstanceBindingRequest

The following examples show how to use org.springframework.cloud.servicebroker.model.binding.DeleteServiceInstanceBindingRequest. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private Mono<Void> delete(DeleteServiceInstanceBindingRequest request,
	DeleteServiceInstanceBindingResponse response) {
	return stateRepository.saveState(request.getServiceInstanceId(), request.getBindingId(),
		OperationState.IN_PROGRESS, "delete service instance binding started")
		.thenMany(invokeDeleteWorkflows(request, response)
			.doOnRequest(l -> {
				LOG.info("Deleting service instance binding");
				LOG.debug("request={}", request);
			})
			.doOnComplete(() -> {
				LOG.info("Finish deleting service instance binding");
				LOG.debug("request={}, response={}", request, response);
			})
			.doOnError(e -> LOG.error(String.format("Error deleting service instance binding. error=%s",
				e.getMessage()), e)))
		.thenEmpty(stateRepository.saveState(request.getServiceInstanceId(), request.getBindingId(),
			OperationState.SUCCEEDED, "delete service instance binding completed")
			.then())
		.onErrorResume(
			exception -> stateRepository.saveState(request.getServiceInstanceId(), request.getBindingId(),
				OperationState.FAILED, exception.getMessage())
				.then());
}
 
Example 2
@Test
void deleteCredentialsFromCredHubWhenNotFound() {
	DeleteServiceInstanceBindingRequest request = DeleteServiceInstanceBindingRequest
		.builder()
		.bindingId("foo-binding-id")
		.serviceInstanceId("foo-instance-id")
		.serviceDefinitionId("foo-definition-id")
		.build();

	DeleteServiceInstanceBindingResponseBuilder responseBuilder =
		DeleteServiceInstanceBindingResponse.builder();

	given(this.credHubOperations.credentials())
		.willReturn(credHubCredentialOperations);

	given(this.credHubCredentialOperations.findByName(any()))
		.willReturn(Flux.fromIterable(Collections.emptyList()));

	StepVerifier
		.create(this.workflow.buildResponse(request, responseBuilder))
		.expectNext(responseBuilder)
		.verifyComplete();

	verifyNoMoreInteractions(this.credHubCredentialOperations);
	verifyNoMoreInteractions(this.credHubPermissionOperations);
}
 
Example 3
@Override
public Mono<DeleteServiceInstanceBindingResponse> deleteServiceInstanceBinding(
		DeleteServiceInstanceBindingRequest request) {
	return Mono.just(request.getBindingId())
			.flatMap(bindingId -> bindingRepository.existsById(bindingId)
					.flatMap(exists -> {
						if (exists) {
							return bindingRepository.deleteById(bindingId)
									.then(userService.deleteUser(bindingId))
									.thenReturn(DeleteServiceInstanceBindingResponse.builder().build());
						}
						else {
							return Mono.error(new ServiceInstanceBindingDoesNotExistException(bindingId));
						}
					}));
}
 
Example 4
@Test
public void deleteBindingWhenBindingDoesNotExist() {
	when(repository.existsById(SERVICE_BINDING_ID))
			.thenReturn(Mono.just(false));

	DeleteServiceInstanceBindingRequest request = DeleteServiceInstanceBindingRequest.builder()
			.serviceInstanceId(SERVICE_INSTANCE_ID)
			.bindingId(SERVICE_BINDING_ID)
			.build();

	StepVerifier.create(service.deleteServiceInstanceBinding(request))
			.expectErrorMatches(e -> e instanceof ServiceInstanceBindingDoesNotExistException)
			.verify();

	verify(repository).existsById(SERVICE_BINDING_ID);
	verifyNoMoreInteractions(repository);
}
 
Example 5
@Test
void deleteBindingWithoutAsyncAndHeadersOperationInProgress() throws Exception {
	setupCatalogService();

	setupServiceInstanceBindingService(new ServiceBrokerDeleteOperationInProgressException("task_10"));

	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().isAccepted())
			.andExpect(jsonPath("$.operation", is("task_10")));

	then(serviceInstanceBindingService)
			.should()
			.deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class));

	verifyDeleteBinding();
}
 
Example 6
@Test
void deleteBindingWithUnknownInstanceIdFails() throws Exception {
	setupCatalogService();

	doThrow(new ServiceInstanceDoesNotExistException(SERVICE_INSTANCE_ID))
			.when(serviceInstanceBindingService)
			.deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class));

	MvcResult mvcResult = mockMvc.perform(delete(buildDeleteUrl())
			.contentType(MediaType.APPLICATION_JSON))
			.andExpect(request().asyncStarted())
			.andReturn();

	mockMvc.perform(asyncDispatch(mvcResult))
			.andExpect(status().isUnprocessableEntity())
			.andExpect(jsonPath("$.description", containsString(SERVICE_INSTANCE_ID)));
}
 
Example 7
@Test
void deleteBindingWithUnknownBindingIdFails() throws Exception {
	setupCatalogService();

	doThrow(new ServiceInstanceBindingDoesNotExistException(SERVICE_INSTANCE_BINDING_ID))
			.when(serviceInstanceBindingService)
			.deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class));

	MvcResult mvcResult = mockMvc.perform(delete(buildDeleteUrl())
			.contentType(MediaType.APPLICATION_JSON))
			.andExpect(request().asyncStarted())
			.andReturn();

	mockMvc.perform(asyncDispatch(mvcResult))
			.andExpect(status().isGone());
}
 
Example 8
@Test
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("{}");


	then(serviceInstanceBindingService)
			.should()
			.deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class));

	DeleteServiceInstanceBindingRequest actualRequest = verifyDeleteBinding();
	assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false);
	assertHeaderValuesSet(actualRequest);
}
 
Example 9
@Test
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("{}");

	then(serviceInstanceBindingService)
			.should()
			.deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class));

	DeleteServiceInstanceBindingRequest actualRequest = verifyDeleteBinding();
	assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false);
	assertThat(actualRequest.getPlan().getId()).isEqualTo(actualRequest.getPlanId());
	assertHeaderValuesSet(actualRequest);
}
 
Example 10
@Test
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");

	then(serviceInstanceBindingService)
			.should()
			.deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class));

	DeleteServiceInstanceBindingRequest actualRequest = verifyDeleteBinding();
	assertThat(actualRequest.isAsyncAccepted()).isEqualTo(true);
	assertHeaderValuesSet(actualRequest);
}
 
Example 11
@Test
void deleteBindingWithUnknownInstanceIdFails() {
	setupCatalogService();

	given(serviceInstanceBindingService
			.deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class)))
			.willThrow(new ServiceInstanceDoesNotExistException(SERVICE_INSTANCE_ID));

	client.delete().uri(buildDeleteUrl())
			.exchange()
			.expectStatus().is4xxClientError()
			.expectStatus().isEqualTo(HttpStatus.UNPROCESSABLE_ENTITY)
			.expectBody()
			.jsonPath("$.description").isNotEmpty()
			.consumeWith(result -> assertDescriptionContains(result, SERVICE_INSTANCE_ID));
}
 
Example 12
@Override
public Mono<DeleteServiceInstanceBindingResponse> deleteServiceInstanceBinding(
		DeleteServiceInstanceBindingRequest request) {
	if (IN_PROGRESS_SERVICE_INSTANCE_ID.equals(request.getServiceInstanceId())) {
		return Mono.error(new ServiceBrokerDeleteOperationInProgressException("task_10"));
	}
	if (UNKNOWN_SERVICE_INSTANCE_ID.equals(request.getServiceInstanceId())) {
		return Mono.error(new ServiceInstanceDoesNotExistException(request.getServiceInstanceId()));
	}
	if (UNKNOWN_BINDING_ID.equals(request.getBindingId())) {
		return Mono.error(new ServiceInstanceBindingDoesNotExistException(request.getBindingId()));
	}
	if (request.isAsyncAccepted()) {
		return Mono.just(DeleteServiceInstanceBindingResponse.builder()
				.async(true)
				.operation("working")
				.build());
	}
	else {
		return Mono.just(DeleteServiceInstanceBindingResponse.builder()
				.build());
	}
}
 
Example 13
@Test
void deleteServiceBindingParametersAreMappedToRequest() {
	DeleteServiceInstanceBindingRequest expectedRequest = DeleteServiceInstanceBindingRequest.builder()
			.asyncAccepted(true)
			.serviceInstanceId("service-instance-id")
			.serviceDefinitionId(serviceDefinition.getId())
			.planId("plan-id")
			.bindingId("binding-id")
			.platformInstanceId("platform-instance-id")
			.apiInfoLocation("api-info-location")
			.originatingIdentity(identityContext)
			.requestIdentity("request-id")
			.serviceDefinition(serviceDefinition)
			.plan(plan)
			.build();

	ServiceInstanceBindingController controller = createControllerUnderTest(expectedRequest);

	controller.deleteServiceInstanceBinding(pathVariables, "service-instance-id", "binding-id",
			serviceDefinition.getId(), "plan-id", true,
			"api-info-location", encodeOriginatingIdentity(identityContext), "request-id");
}
 
Example 14
private void validateDeleteServiceBindingWithResponseStatus(DeleteServiceInstanceBindingResponse response,
		HttpStatus expectedStatus) {
	Mono<DeleteServiceInstanceBindingResponse> responseMono;
	if (response == null) {
		responseMono = Mono.empty();
	}
	else {
		responseMono = Mono.just(response);
	}
	given(bindingService.deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class)))
			.willReturn(responseMono);

	ResponseEntity<DeleteServiceInstanceBindingResponse> responseEntity = controller
			.deleteServiceInstanceBinding(pathVariables, null, null, "service-definition-id",
					"service-definition-plan-id", false, null, null, null)
			.block();

	assertThat(responseEntity).isNotNull();
	assertThat(responseEntity.getStatusCode()).isEqualTo(expectedStatus);
	assertThat(responseEntity.getBody()).isEqualTo(response);

	then(bindingService)
			.should()
			.deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class));
}
 
Example 15
@Test
void deleteServiceInstanceBindingSucceeds() {
	prepareBindingFlows();

	StepVerifier
			.create(serviceInstanceBindingEventService.deleteServiceInstanceBinding(
					DeleteServiceInstanceBindingRequest.builder()
							.serviceInstanceId("service-instance-id")
							.bindingId("service-binding-id")
							.build()))
			.expectNext(DeleteServiceInstanceBindingResponse.builder().build())
			.verifyComplete();

	assertThat(this.results.getBeforeCreate()).isNullOrEmpty();
	assertThat(this.results.getAfterCreate()).isNullOrEmpty();
	assertThat(this.results.getErrorCreate()).isNullOrEmpty();
	assertThat(this.results.getBeforeDelete()).isEqualTo("before delete service-instance-id");
	assertThat(this.results.getAfterDelete()).isEqualTo("after delete service-instance-id");
	assertThat(this.results.getErrorDelete()).isNullOrEmpty();
}
 
Example 16
@Test
void deleteServiceInstanceBindingFails() {
	prepareBindingFlows();

	StepVerifier
			.create(serviceInstanceBindingEventService.deleteServiceInstanceBinding(
					DeleteServiceInstanceBindingRequest.builder()
							.serviceInstanceId("service-instance-id")
							.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 service-instance-id");
	assertThat(this.results.getAfterDelete()).isNullOrEmpty();
	assertThat(this.results.getErrorDelete()).isEqualTo("error delete service-instance-id");
}
 
Example 17
@Test
public void givenServiceBindingDoesNotExist_whenDeleteServiceBinding_thenException() {
    // given service binding does not exist
    when(mailService.serviceBindingExists(MAIL_SERVICE_INSTANCE_ID, MAIL_SERVICE_BINDING_ID)).thenReturn(Mono.just(false));

    // when delete service binding
    DeleteServiceInstanceBindingRequest request = DeleteServiceInstanceBindingRequest.builder()
        .serviceInstanceId(MAIL_SERVICE_INSTANCE_ID)
        .bindingId(MAIL_SERVICE_BINDING_ID)
        .build();

    // then ServiceInstanceBindingDoesNotExistException is thrown
    StepVerifier.create(mailServiceInstanceBindingService.deleteServiceInstanceBinding(request))
        .expectErrorMatches(ex -> ex instanceof ServiceInstanceBindingDoesNotExistException)
        .verify();
}
 
Example 18
@Test
public void givenServiceBindingExists_whenDeleteServiceBinding_thenExistingBindingIsDeleted() {
    // given service binding exists
    when(mailService.serviceBindingExists(MAIL_SERVICE_INSTANCE_ID, MAIL_SERVICE_BINDING_ID)).thenReturn(Mono.just(true));
    when(mailService.deleteServiceBinding(MAIL_SERVICE_INSTANCE_ID)).thenReturn(Mono.empty());

    // when delete service binding
    DeleteServiceInstanceBindingRequest request = DeleteServiceInstanceBindingRequest.builder()
        .serviceInstanceId(MAIL_SERVICE_INSTANCE_ID)
        .bindingId(MAIL_SERVICE_BINDING_ID)
        .build();

    // then the existing service binding is retrieved
    StepVerifier.create(mailServiceInstanceBindingService.deleteServiceInstanceBinding(request))
        .consumeNextWith(response -> {
            assertFalse(response.isAsync());
            assertNull(response.getOperation());
        })
        .verifyComplete();
}
 
Example 19
@Override
public Mono<DeleteServiceInstanceBindingResponse> deleteServiceInstanceBinding(
	DeleteServiceInstanceBindingRequest request) {
	return invokeDeleteResponseBuilders(request)
		.flatMap(response -> {
			if (response.isAsync()) {
				return Mono.just(response).publishOn(Schedulers.parallel())
					.doOnNext(r -> delete(request, r)
						.subscribe());
			}
			else {
				return delete(request, response).thenReturn(response);
			}
		});
}
 
Example 20
private Mono<DeleteServiceInstanceBindingResponse> invokeDeleteResponseBuilders(
	DeleteServiceInstanceBindingRequest request) {
	AtomicReference<DeleteServiceInstanceBindingResponseBuilder> responseBuilder =
		new AtomicReference<>(DeleteServiceInstanceBindingResponse.builder());

	return Flux.fromIterable(deleteServiceInstanceBindingWorkflows)
		.filterWhen(workflow -> workflow.accept(request))
		.flatMap(workflow -> workflow.buildResponse(request, responseBuilder.get())
			.doOnNext(responseBuilder::set))
		.last(responseBuilder.get())
		.map(DeleteServiceInstanceBindingResponseBuilder::build);
}
 
Example 21
@Test
void deleteServiceInstanceBindingsWithNoWorkflows() {
	given(stateRepository.saveState(anyString(), anyString(), any(OperationState.class), anyString()))
		.willReturn(
			Mono.just(new ServiceInstanceState(OperationState.IN_PROGRESS, "delete service instance started",
				new Timestamp(Instant.now().minusSeconds(60).toEpochMilli()))))
		.willReturn(
			Mono.just(new ServiceInstanceState(OperationState.SUCCEEDED, "delete service instance completed",
				new Timestamp(Instant.now().minusSeconds(30).toEpochMilli()))));

	this.workflowServiceInstanceBindingService = new WorkflowServiceInstanceBindingService(
		this.stateRepository, null, null, null);

	DeleteServiceInstanceBindingRequest request = DeleteServiceInstanceBindingRequest.builder()
		.serviceInstanceId("foo-service")
		.bindingId("foo-binding")
		.build();

	StepVerifier.create(workflowServiceInstanceBindingService.deleteServiceInstanceBinding(request))
		.assertNext(response -> {
			InOrder repoOrder = inOrder(stateRepository);
			repoOrder.verify(stateRepository)
				.saveState(eq("foo-service"), eq("foo-binding"), eq(OperationState.IN_PROGRESS),
					eq("delete service instance binding started"));
			repoOrder.verify(stateRepository)
				.saveState(eq("foo-service"), eq("foo-binding"), eq(OperationState.SUCCEEDED),
					eq("delete service instance binding completed"));
			repoOrder.verifyNoMoreInteractions();

			assertThat(response).isNotNull();
			assertThat(response).isInstanceOf(DeleteServiceInstanceBindingResponse.class);
		})
		.verifyComplete();
}
 
Example 22
@Test
void deleteServiceInstanceBindingWithResponseError() {
	DeleteServiceInstanceBindingRequest request = DeleteServiceInstanceBindingRequest.builder()
		.serviceInstanceId("foo")
		.bindingId("bar")
		.build();

	DeleteServiceInstanceBindingResponseBuilder responseBuilder = DeleteServiceInstanceBindingResponse.builder();

	given(deleteServiceInstanceBindingWorkflow1.accept(request))
		.willReturn(Mono.just(true));
	given(deleteServiceInstanceBindingWorkflow1
		.buildResponse(eq(request), any(DeleteServiceInstanceBindingResponseBuilder.class)))
		.willReturn(Mono.error(new ServiceBrokerException("delete foo binding error")));

	given(deleteServiceInstanceBindingWorkflow2.accept(request))
		.willReturn(Mono.just(true));
	given(deleteServiceInstanceBindingWorkflow2
		.buildResponse(eq(request), any(DeleteServiceInstanceBindingResponseBuilder.class)))
		.willReturn(Mono.just(responseBuilder));

	StepVerifier.create(workflowServiceInstanceBindingService.deleteServiceInstanceBinding(request))
		.expectErrorSatisfies(e -> assertThat(e)
			.isInstanceOf(ServiceBrokerException.class)
			.hasMessage("delete foo binding error"))
		.verify();
}
 
Example 23
@Test
void deleteServiceInstanceBindingWithNoAcceptsDoesNothing() {
	given(stateRepository.saveState(anyString(), anyString(), any(OperationState.class), anyString()))
		.willReturn(Mono.just(
			new ServiceInstanceState(OperationState.IN_PROGRESS, "delete service instance binding started",
				new Timestamp(Instant.now().minusSeconds(60).toEpochMilli()))))
		.willReturn(Mono.just(
			new ServiceInstanceState(OperationState.SUCCEEDED, "delete service instance binding completed",
				new Timestamp(Instant.now().minusSeconds(30).toEpochMilli()))));

	DeleteServiceInstanceBindingRequest request = DeleteServiceInstanceBindingRequest.builder()
		.serviceInstanceId("foo-service")
		.bindingId("foo-binding")
		.build();

	given(deleteServiceInstanceBindingWorkflow1.accept(request))
		.willReturn(Mono.just(false));

	given(deleteServiceInstanceBindingWorkflow2.accept(request))
		.willReturn(Mono.just(false));

	StepVerifier.create(workflowServiceInstanceBindingService.deleteServiceInstanceBinding(request))
		.assertNext(response -> {
			InOrder repoOrder = inOrder(stateRepository);
			repoOrder.verify(stateRepository)
				.saveState(eq("foo-service"), eq("foo-binding"), eq(OperationState.IN_PROGRESS),
					eq("delete service instance binding started"));
			repoOrder.verify(stateRepository)
				.saveState(eq("foo-service"), eq("foo-binding"), eq(OperationState.SUCCEEDED),
					eq("delete service instance binding completed"));
			repoOrder.verifyNoMoreInteractions();

			then(deleteServiceInstanceBindingWorkflow1).shouldHaveNoMoreInteractions();
			then(deleteServiceInstanceBindingWorkflow2).shouldHaveNoMoreInteractions();

			assertThat(response).isNotNull();
		})
		.verifyComplete();
}
 
Example 24
@Override
public Mono<DeleteServiceInstanceBindingResponseBuilder> buildResponse(DeleteServiceInstanceBindingRequest request,
	DeleteServiceInstanceBindingResponseBuilder responseBuilder) {
	return buildCredentialName(request.getServiceDefinitionId(), request.getBindingId())
		.filterWhen(this::credentialExists)
		.delayUntil(this::deletePermission)
		.delayUntil(this::deleteCredential)
		.thenReturn(responseBuilder);
}
 
Example 25
@Test
public void deleteBindingWhenBindingExists() {
	when(repository.existsById(SERVICE_BINDING_ID))
			.thenReturn(Mono.just(true));

	when(repository.deleteById(SERVICE_BINDING_ID))
			.thenReturn(Mono.empty());

	when(userService.deleteUser(SERVICE_BINDING_ID))
			.thenReturn(Mono.empty());

	DeleteServiceInstanceBindingRequest request = DeleteServiceInstanceBindingRequest.builder()
			.serviceInstanceId(SERVICE_INSTANCE_ID)
			.bindingId(SERVICE_BINDING_ID)
			.build();

	StepVerifier.create(service.deleteServiceInstanceBinding(request))
			.expectNextCount(1)
			.verifyComplete();

	verify(repository).existsById(SERVICE_BINDING_ID);
	verify(repository).deleteById(SERVICE_BINDING_ID);
	verifyNoMoreInteractions(repository);

	verify(userService).deleteUser(SERVICE_BINDING_ID);
	verifyNoMoreInteractions(userService);
}
 
Example 26
@Override
public Mono<DeleteServiceInstanceBindingResponse> deleteServiceInstanceBinding(DeleteServiceInstanceBindingRequest request)
        throws ServiceBrokerException {

    String bindingId = request.getBindingId();
    try {
        BindingWorkflow workflow = getWorkflow(request)
                .withDeleteRequest(request);

        LOG.info("looking up binding: " + bindingId);
        ServiceInstanceBinding binding = repository.find(bindingId);
        if (binding == null)
            throw new ServiceInstanceBindingDoesNotExistException(bindingId);
        LOG.info("binding found: " + bindingId);

        workflow.removeBinding(binding);

        LOG.info("deleting from repository" + bindingId);
        repository.delete(bindingId);
        return Mono.just(DeleteServiceInstanceBindingResponse.builder()
                .async(false)
                .build());
    } catch (Exception e) {
        LOG.error("Error deleting binding: " + e);
        throw new ServiceBrokerException(e);
    }
}
 
Example 27
private BindingWorkflow getWorkflow(DeleteServiceInstanceBindingRequest deleteRequest)
        throws EcsManagementClientException, IOException {

    if (isRemoteConnectBinding(deleteRequest))
        return new RemoteConnectBindingWorkflow(instanceRepo, ecs);

    ServiceDefinitionProxy service =
            ecs.lookupServiceDefinition(deleteRequest.getServiceDefinitionId());
    return getWorkflow(service).withDeleteRequest(deleteRequest);
}
 
Example 28
private boolean isRemoteConnectBinding(DeleteServiceInstanceBindingRequest deleteRequest) throws IOException {
    String bindingId = deleteRequest.getBindingId();
    ServiceInstanceBinding binding = repository.find(bindingId);
    if (binding == null)
        throw new ServiceInstanceBindingDoesNotExistException(bindingId);
    return isRemoteConnectBinding(binding.getParameters());
}
 
Example 29
protected DeleteServiceInstanceBindingRequest verifyDeleteBinding() {
	ArgumentCaptor<DeleteServiceInstanceBindingRequest> argumentCaptor = ArgumentCaptor
			.forClass(DeleteServiceInstanceBindingRequest.class);
	then(serviceInstanceBindingService)
			.should()
			.deleteServiceInstanceBinding(argumentCaptor.capture());
	return argumentCaptor.getValue();
}
 
Example 30
@Test
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("{}"));

	then(serviceInstanceBindingService)
			.should()
			.deleteServiceInstanceBinding(any(DeleteServiceInstanceBindingRequest.class));

	DeleteServiceInstanceBindingRequest actualRequest = verifyDeleteBinding();
	assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false);
	assertHeaderValuesSet(actualRequest);
}