org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceBindingRequest Java Examples
The following examples show how to use
org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceBindingRequest.
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
Source File: ServiceInstanceBindingControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void createBindingToAppWithAsyncAndHeadersSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceBindingService(CreateServiceInstanceAppBindingResponse.builder() .async(true) .operation("working") .bindingExisted(false) .build()); client.put().uri(buildCreateUrl(PLATFORM_INSTANCE_ID, true)) .contentType(MediaType.APPLICATION_JSON) .bodyValue(createRequestBody) .header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION) .header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()) .accept(MediaType.APPLICATION_JSON) .exchange() .expectStatus().isAccepted() .expectBody() .jsonPath("$.operation").isEqualTo("working"); CreateServiceInstanceBindingRequest actualRequest = verifyCreateBinding(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(true); assertHeaderValuesSet(actualRequest); }
Example #2
Source File: ServiceInstanceBindingControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void createBindingToAppWithoutAsyncAndHeadersSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceBindingService(CreateServiceInstanceAppBindingResponse.builder() .bindingExisted(false) .build()); MvcResult mvcResult = mockMvc.perform(put(buildCreateUrl(PLATFORM_INSTANCE_ID, false)) .content(createRequestBody) .header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION) .header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()) .accept(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)) .andExpect(request().asyncStarted()) .andReturn(); mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isCreated()); CreateServiceInstanceBindingRequest actualRequest = verifyCreateBinding(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false); assertHeaderValuesSet(actualRequest); }
Example #3
Source File: ServiceInstanceBindingControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void createBindingToAppWithExistingSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceBindingService(CreateServiceInstanceAppBindingResponse.builder() .bindingExisted(true) .build()); MvcResult mvcResult = mockMvc.perform(put(buildCreateUrl()) .content(createRequestBody) .accept(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)) .andExpect(request().asyncStarted()) .andExpect(status().isOk()) .andReturn(); mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isOk()); CreateServiceInstanceBindingRequest actualRequest = verifyCreateBinding(); assertHeaderValuesNotSet(actualRequest); }
Example #4
Source File: WorkflowServiceInstanceBindingService.java From spring-cloud-app-broker with Apache License 2.0 | 6 votes |
private Flux<Void> invokeCreateWorkflows(CreateServiceInstanceBindingRequest request, CreateServiceInstanceBindingResponse response) { return Flux.defer(() -> { if (isAppBindingRequest(request)) { return Flux.fromIterable(createServiceInstanceAppBindingWorkflows) .filterWhen(workflow -> workflow.accept(request)) .concatMap(workflow -> workflow.create(request, (CreateServiceInstanceAppBindingResponse) response)); } else if (isRouteBindingRequest(request)) { return Flux.fromIterable(createServiceInstanceRouteBindingWorkflows) .filterWhen(workflow -> workflow.accept(request)) .concatMap(workflow -> workflow.create(request, (CreateServiceInstanceRouteBindingResponse) response)); } return Flux.empty(); }); }
Example #5
Source File: WorkflowServiceInstanceBindingService.java From spring-cloud-app-broker with Apache License 2.0 | 6 votes |
private Mono<Void> create(CreateServiceInstanceBindingRequest request, CreateServiceInstanceBindingResponse response) { return stateRepository.saveState(request.getServiceInstanceId(), request.getBindingId(), OperationState.IN_PROGRESS, "create service instance binding started") .thenMany(invokeCreateWorkflows(request, response) .doOnRequest(l -> { LOG.info("Creating service instance binding"); LOG.debug("request={}", request); }) .doOnComplete(() -> { LOG.debug("Finish creating service instance binding"); LOG.debug("request={}, response={}", request, response); }) .doOnError(e -> LOG.error(String.format("Error creating service instance binding. error=%s", e.getMessage()), e))) .thenEmpty(stateRepository.saveState(request.getServiceInstanceId(), request.getBindingId(), OperationState.SUCCEEDED, "create service instance binding completed") .then()) .onErrorResume( exception -> stateRepository.saveState(request.getServiceInstanceId(), request.getBindingId(), OperationState.FAILED, exception.getMessage()) .then()); }
Example #6
Source File: ServiceInstanceBindingControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void createBindingToRouteWithoutAsyncHeadersSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceBindingService(CreateServiceInstanceRouteBindingResponse.builder() .bindingExisted(false) .build()); MvcResult mvcResult = mockMvc.perform(put(buildCreateUrl()) .content(createRequestBody) .accept(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)) .andExpect(request().asyncStarted()) .andExpect(status().isOk()) .andReturn(); mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isCreated()); CreateServiceInstanceBindingRequest actualRequest = verifyCreateBinding(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false); assertHeaderValuesNotSet(actualRequest); }
Example #7
Source File: MailServiceInstanceBindingServiceUnitTest.java From tutorials with MIT License | 6 votes |
@Test public void givenServiceBindingExists_whenCreateServiceBinding_thenExistingBindingIsRetrieved() { // given service binding exists when(mailService.serviceBindingExists(MAIL_SERVICE_INSTANCE_ID, MAIL_SERVICE_BINDING_ID)).thenReturn(Mono.just(true)); Map<String, Object> credentials = generateCredentials(); MailServiceBinding serviceBinding = new MailServiceBinding(MAIL_SERVICE_BINDING_ID, credentials); when(mailService.getServiceBinding(MAIL_SERVICE_INSTANCE_ID, MAIL_SERVICE_BINDING_ID)) .thenReturn(Mono.just(serviceBinding)); // when create service binding CreateServiceInstanceBindingRequest request = CreateServiceInstanceBindingRequest.builder() .serviceInstanceId(MAIL_SERVICE_INSTANCE_ID) .bindingId(MAIL_SERVICE_BINDING_ID) .build(); // then a new service binding is provisioned StepVerifier.create(mailServiceInstanceBindingService.createServiceInstanceBinding(request)) .consumeNextWith(response -> { assertTrue(response instanceof CreateServiceInstanceAppBindingResponse); CreateServiceInstanceAppBindingResponse bindingResponse = (CreateServiceInstanceAppBindingResponse) response; assertTrue(bindingResponse.isBindingExisted()); validateBindingCredentials(bindingResponse.getCredentials()); }) .verifyComplete(); }
Example #8
Source File: ServiceInstanceBindingEventServiceTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void createServiceInstanceBindingFails() { prepareBindingFlows(); StepVerifier .create(serviceInstanceBindingEventService.createServiceInstanceBinding( CreateServiceInstanceBindingRequest.builder() .serviceInstanceId("service-instance-id") .build())) .expectError() .verify(); assertThat(this.results.getBeforeCreate()).isEqualTo("before create service-instance-id"); assertThat(this.results.getAfterCreate()).isNullOrEmpty(); assertThat(this.results.getErrorCreate()).isEqualTo("error create service-instance-id"); assertThat(this.results.getBeforeDelete()).isNullOrEmpty(); assertThat(this.results.getAfterDelete()).isNullOrEmpty(); assertThat(this.results.getErrorDelete()).isNullOrEmpty(); }
Example #9
Source File: ServiceInstanceBindingControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void createBindingToRouteWithAsyncHeadersSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceBindingService(CreateServiceInstanceRouteBindingResponse.builder() .async(true) .operation("working") .bindingExisted(false) .build()); MvcResult mvcResult = mockMvc.perform(put(buildCreateUrl(null, true)) .content(createRequestBody) .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"))); CreateServiceInstanceBindingRequest actualRequest = verifyCreateBinding(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(true); assertHeaderValuesNotSet(actualRequest); }
Example #10
Source File: ServiceInstanceBindingEventServiceTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void createServiceInstanceBindingSucceeds() { prepareBindingFlows(); StepVerifier .create(serviceInstanceBindingEventService.createServiceInstanceBinding( CreateServiceInstanceBindingRequest.builder() .serviceInstanceId("service-instance-id") .serviceDefinitionId("service-binding-id") .build())) .expectNext(CreateServiceInstanceAppBindingResponse.builder().build()) .verifyComplete(); assertThat(this.results.getBeforeCreate()).isEqualTo("before create service-instance-id"); assertThat(this.results.getAfterCreate()).isEqualTo("after create service-instance-id"); assertThat(this.results.getErrorCreate()).isNullOrEmpty(); assertThat(this.results.getBeforeDelete()).isNullOrEmpty(); assertThat(this.results.getAfterDelete()).isNullOrEmpty(); assertThat(this.results.getErrorDelete()).isNullOrEmpty(); }
Example #11
Source File: ServiceInstanceBindingControllerResponseCodeTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
private void validateCreateServiceBindingResponseStatus(CreateServiceInstanceBindingResponse response, HttpStatus httpStatus) { Mono<CreateServiceInstanceBindingResponse> responseMono; if (response == null) { responseMono = Mono.empty(); } else { responseMono = Mono.just(response); } given(bindingService.createServiceInstanceBinding(any(CreateServiceInstanceBindingRequest.class))) .willReturn(responseMono); CreateServiceInstanceBindingRequest createRequest = CreateServiceInstanceBindingRequest.builder() .serviceDefinitionId("service-definition-id") .planId("service-definition-plan-id") .build(); ResponseEntity<CreateServiceInstanceBindingResponse> responseEntity = controller .createServiceInstanceBinding(pathVariables, null, null, false, null, null, null, createRequest) .block(); assertThat(responseEntity).isNotNull(); assertThat(responseEntity.getStatusCode()).isEqualTo(httpStatus); assertThat(responseEntity.getBody()).isEqualTo(response); }
Example #12
Source File: MailServiceInstanceBindingServiceUnitTest.java From tutorials with MIT License | 6 votes |
@Test public void givenServiceBindingDoesNotExist_whenCreateServiceBinding_thenNewBindingIsCreated() { // given service binding does not exist when(mailService.serviceBindingExists(MAIL_SERVICE_INSTANCE_ID, MAIL_SERVICE_BINDING_ID)).thenReturn(Mono.just(false)); Map<String, Object> credentials = generateCredentials(); MailServiceBinding serviceBinding = new MailServiceBinding(MAIL_SERVICE_BINDING_ID, credentials); when(mailService.createServiceBinding(MAIL_SERVICE_INSTANCE_ID, MAIL_SERVICE_BINDING_ID)) .thenReturn(Mono.just(serviceBinding)); // when create service binding CreateServiceInstanceBindingRequest request = CreateServiceInstanceBindingRequest.builder() .serviceInstanceId(MAIL_SERVICE_INSTANCE_ID) .bindingId(MAIL_SERVICE_BINDING_ID) .build(); // then a new service binding is provisioned StepVerifier.create(mailServiceInstanceBindingService.createServiceInstanceBinding(request)) .consumeNextWith(response -> { assertTrue(response instanceof CreateServiceInstanceAppBindingResponse); CreateServiceInstanceAppBindingResponse bindingResponse = (CreateServiceInstanceAppBindingResponse) response; assertFalse(bindingResponse.isBindingExisted()); validateBindingCredentials(bindingResponse.getCredentials()); }) .verifyComplete(); }
Example #13
Source File: ServiceInstanceBindingControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void createBindingWithDuplicateIdFails() { setupCatalogService(); given(serviceInstanceBindingService .createServiceInstanceBinding(any(CreateServiceInstanceBindingRequest.class))) .willThrow(new ServiceInstanceBindingExistsException(SERVICE_INSTANCE_ID, SERVICE_INSTANCE_BINDING_ID)); client.put().uri(buildCreateUrl()) .contentType(MediaType.APPLICATION_JSON) .bodyValue(createRequestBody) .accept(MediaType.APPLICATION_JSON) .exchange() .expectStatus().is4xxClientError() .expectStatus().isEqualTo(HttpStatus.CONFLICT) .expectBody() .jsonPath("$.description").isNotEmpty() .consumeWith(result -> assertDescriptionContains(result, String.format("serviceInstanceId=%s, bindingId=%s", SERVICE_INSTANCE_ID, SERVICE_INSTANCE_BINDING_ID))); }
Example #14
Source File: ServiceInstanceBindingControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void createBindingWithDuplicateIdFails() throws Exception { setupCatalogService(); given(serviceInstanceBindingService .createServiceInstanceBinding(any(CreateServiceInstanceBindingRequest.class))) .willThrow(new ServiceInstanceBindingExistsException(SERVICE_INSTANCE_ID, SERVICE_INSTANCE_BINDING_ID)); MvcResult mvcResult = mockMvc.perform(put(buildCreateUrl()) .content(createRequestBody) .accept(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)) .andExpect(request().asyncStarted()) .andReturn(); mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isConflict()) .andExpect(jsonPath("$.description", containsString(SERVICE_INSTANCE_ID))) .andExpect(jsonPath("$.description", containsString(SERVICE_INSTANCE_BINDING_ID))); }
Example #15
Source File: BookStoreServiceInstanceBindingService.java From bookstore-service-broker with Apache License 2.0 | 6 votes |
@Override public Mono<CreateServiceInstanceBindingResponse> createServiceInstanceBinding( CreateServiceInstanceBindingRequest request) { return Mono.just(CreateServiceInstanceAppBindingResponse.builder()) .flatMap(responseBuilder -> bindingRepository.existsById(request.getBindingId()) .flatMap(exists -> { if (exists) { return bindingRepository.findById(request.getBindingId()) .flatMap(serviceBinding -> Mono.just(responseBuilder .bindingExisted(true) .credentials(serviceBinding.getCredentials()) .build())); } else { return createUser(request) .flatMap(user -> buildCredentials(request.getServiceInstanceId(), user)) .flatMap(credentials -> bindingRepository .save(new ServiceBinding(request.getBindingId(), request.getParameters(), credentials)) .thenReturn(responseBuilder .bindingExisted(false) .credentials(credentials) .build())); } })); }
Example #16
Source File: ServiceInstanceBindingControllerRequestTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void createServiceBindingParametersAreMappedToRequest() { CreateServiceInstanceBindingRequest parsedRequest = buildCreateRequest().build(); CreateServiceInstanceBindingRequest expectedRequest = buildCreateRequest() .asyncAccepted(true) .serviceInstanceId("service-instance-id") .bindingId("binding-id") .serviceDefinition(serviceDefinition) .plan(plan) .platformInstanceId("platform-instance-id") .apiInfoLocation("api-info-location") .originatingIdentity(identityContext) .requestIdentity("request-id") .build(); ServiceInstanceBindingController controller = createControllerUnderTest(expectedRequest); controller.createServiceInstanceBinding(pathVariables, "service-instance-id", "binding-id", true, "api-info-location", encodeOriginatingIdentity(identityContext), "request-id", parsedRequest); }
Example #17
Source File: ServiceInstanceBindingControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void createBindingToRouteFiltersPlansSucceeds() { setupCatalogService(); setupServiceInstanceBindingService(CreateServiceInstanceRouteBindingResponse .builder() .bindingExisted(false) .build()); client.put().uri(buildCreateUrl()) .contentType(MediaType.APPLICATION_JSON) .bodyValue(createRequestBody) .accept(MediaType.APPLICATION_JSON) .exchange() .expectStatus().isCreated(); CreateServiceInstanceBindingRequest actualRequest = verifyCreateBinding(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false); assertThat(actualRequest.getPlan().getId()).isEqualTo(actualRequest.getPlanId()); assertHeaderValuesNotSet(actualRequest); }
Example #18
Source File: CredHubPersistingCreateServiceInstanceAppBindingWorkflow.java From spring-cloud-app-broker with Apache License 2.0 | 6 votes |
private Mono<Void> writePermissions(CreateServiceInstanceBindingRequest request, CredentialName credentialName) { BindResource bindResource = request.getBindResource(); return Mono.defer(() -> { if (bindResource.getAppGuid() != null) { return credHubOperations.permissionsV2() .addPermissions(credentialName, Permission.builder() .app(bindResource.getAppGuid()) .operation(Operation.READ) .build()) .then(); } if (bindResource.getProperty(CREDENTIAL_CLIENT_ID) != null) { return credHubOperations.permissionsV2() .addPermissions(credentialName, Permission.builder() .client(bindResource.getProperty(CREDENTIAL_CLIENT_ID).toString()) .operation(Operation.READ) .build()) .then(); } return Mono.empty(); }); }
Example #19
Source File: ServiceInstanceBindingControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void createBindingToAppFiltersPlansSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceBindingService(CreateServiceInstanceAppBindingResponse .builder() .bindingExisted(false) .build()); client.put().uri(buildCreateUrl(PLATFORM_INSTANCE_ID, false)) .contentType(MediaType.APPLICATION_JSON) .bodyValue(createRequestBody) .header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION) .header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()) .accept(MediaType.APPLICATION_JSON) .exchange() .expectStatus().isCreated(); CreateServiceInstanceBindingRequest actualRequest = verifyCreateBinding(); assertThat(actualRequest.getPlan().getId()).isEqualTo(actualRequest.getPlanId()); assertHeaderValuesSet(actualRequest); }
Example #20
Source File: CredHubPersistingCreateServiceInstanceAppBindingWorkflow.java From spring-cloud-app-broker with Apache License 2.0 | 6 votes |
@Override public Mono<CreateServiceInstanceAppBindingResponseBuilder> buildResponse( CreateServiceInstanceBindingRequest request, CreateServiceInstanceAppBindingResponseBuilder responseBuilder) { return Mono.just(responseBuilder.build()) .flatMap(response -> { if (!CollectionUtils.isEmpty(response.getCredentials())) { return buildCredentialName(request.getServiceDefinitionId(), request.getBindingId()) .flatMap(credentialName -> persistBindingCredentials(request, response, credentialName) .doOnRequest(l -> LOG.debug("Storing binding credentials with name '{}' in CredHub", credentialName.getName())) .doOnSuccess(r -> LOG .debug("Finished storing binding credentials with name '{}' in CredHub", credentialName.getName())) .doOnError(exception -> LOG.error(String .format("Error storing binding credentials with name '%s' in CredHub with error: '%s'", credentialName.getName(), exception.getMessage()), exception))); } return Mono.just(responseBuilder); }); }
Example #21
Source File: ServiceInstanceBindingControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void createBindingToRouteWithAsyncAndHeadersSucceeds() { setupCatalogService(); setupServiceInstanceBindingService(CreateServiceInstanceRouteBindingResponse.builder() .async(true) .operation("working") .bindingExisted(false) .build()); client.put().uri(buildCreateUrl(null, true)) .contentType(MediaType.APPLICATION_JSON) .bodyValue(createRequestBody) .accept(MediaType.APPLICATION_JSON) .exchange() .expectStatus().isAccepted() .expectBody() .jsonPath("$.operation").isEqualTo("working"); CreateServiceInstanceBindingRequest actualRequest = verifyCreateBinding(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(true); assertHeaderValuesNotSet(actualRequest); }
Example #22
Source File: ServiceInstanceBindingControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void createBindingWithUnknownServiceInstanceIdFails() { setupCatalogService(); given(serviceInstanceBindingService .createServiceInstanceBinding(any(CreateServiceInstanceBindingRequest.class))) .willThrow(new ServiceInstanceDoesNotExistException(SERVICE_INSTANCE_ID)); client.put().uri(buildCreateUrl()) .contentType(MediaType.APPLICATION_JSON) .bodyValue(createRequestBody) .accept(MediaType.APPLICATION_JSON) .exchange() .expectStatus().is4xxClientError() .expectStatus().isEqualTo(HttpStatus.UNPROCESSABLE_ENTITY) .expectBody() .jsonPath("$.description").isNotEmpty() .consumeWith(result -> assertDescriptionContains(result, String.format("id=%s", SERVICE_INSTANCE_ID))); }
Example #23
Source File: ServiceInstanceBindingControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void createBindingToAppWithoutAsyncAndHeadersSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceBindingService(CreateServiceInstanceAppBindingResponse.builder() .bindingExisted(false) .build()); client.put().uri(buildCreateUrl(PLATFORM_INSTANCE_ID, false)) .contentType(MediaType.APPLICATION_JSON) .bodyValue(createRequestBody) .header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION) .header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()) .accept(MediaType.APPLICATION_JSON) .exchange() .expectStatus().isCreated(); CreateServiceInstanceBindingRequest actualRequest = verifyCreateBinding(); assertHeaderValuesSet(actualRequest); }
Example #24
Source File: ExampleServiceBindingService.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Override public Mono<CreateServiceInstanceBindingResponse> createServiceInstanceBinding(CreateServiceInstanceBindingRequest request) { String serviceInstanceId = request.getServiceInstanceId(); String bindingId = request.getBindingId(); // // create credentials and store for later retrieval // String url = new String(/* build a URL to access the service instance */); String bindingUsername = new String(/* create a user */); String bindingPassword = new String(/* create a password */); CreateServiceInstanceBindingResponse response = CreateServiceInstanceAppBindingResponse.builder() .credentials("url", url) .credentials("username", bindingUsername) .credentials("password", bindingPassword) .bindingExisted(false) .async(true) .build(); return Mono.just(response); }
Example #25
Source File: ServiceInstanceBindingEventServiceTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Override public Mono<CreateServiceInstanceBindingResponse> createServiceInstanceBinding( CreateServiceInstanceBindingRequest request) { if (request.getServiceDefinitionId() == null) { return Mono.error(new ServiceInstanceBindingExistsException("service-instance-id", "arrrr")); } return Mono.just(CreateServiceInstanceAppBindingResponse.builder().build()); }
Example #26
Source File: CredHubPersistingCreateServiceInstanceAppBindingWorkflow.java From spring-cloud-app-broker with Apache License 2.0 | 5 votes |
private Mono<CreateServiceInstanceAppBindingResponseBuilder> persistBindingCredentials( CreateServiceInstanceBindingRequest request, CreateServiceInstanceAppBindingResponse response, CredentialName credentialName) { return writeCredential(response, credentialName) .then(writePermissions(request, credentialName)) .thenReturn(buildReplacementBindingResponse(response, credentialName)); }
Example #27
Source File: BookstoreServiceInstanceBindingServiceTests.java From bookstore-service-broker with Apache License 2.0 | 5 votes |
@Test public void createBindingWhenBindingExists() { ServiceBinding binding = new ServiceBinding(SERVICE_BINDING_ID, null, credentials); when(repository.existsById(SERVICE_BINDING_ID)) .thenReturn(Mono.just(true)); when(repository.findById(SERVICE_BINDING_ID)) .thenReturn(Mono.just(binding)); CreateServiceInstanceBindingRequest request = CreateServiceInstanceBindingRequest.builder() .serviceInstanceId(SERVICE_INSTANCE_ID) .bindingId(SERVICE_BINDING_ID) .build(); StepVerifier.create(service.createServiceInstanceBinding(request)) .consumeNextWith(response -> { assertThat(response).isInstanceOf(CreateServiceInstanceAppBindingResponse.class); CreateServiceInstanceAppBindingResponse appResponse = (CreateServiceInstanceAppBindingResponse) response; assertThat(appResponse.isBindingExisted()).isTrue(); assertThat(credentials).isEqualTo(appResponse.getCredentials()); }) .verifyComplete(); verify(repository).existsById(SERVICE_BINDING_ID); verify(repository).findById(SERVICE_BINDING_ID); verifyNoMoreInteractions(repository); }
Example #28
Source File: AbstractServiceInstanceBindingControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
protected CreateServiceInstanceBindingRequest verifyCreateBinding() { ArgumentCaptor<CreateServiceInstanceBindingRequest> argumentCaptor = ArgumentCaptor .forClass(CreateServiceInstanceBindingRequest.class); then(serviceInstanceBindingService) .should() .createServiceInstanceBinding(argumentCaptor.capture()); return argumentCaptor.getValue(); }
Example #29
Source File: EventFlowsAutoConfigurationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Bean public CreateServiceInstanceBindingInitializationFlow createInitFlow() { return new CreateServiceInstanceBindingInitializationFlow() { @Override public Mono<Void> initialize(CreateServiceInstanceBindingRequest request) { return Mono.empty(); } }; }
Example #30
Source File: EventFlowsAutoConfigurationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Bean public CreateServiceInstanceBindingErrorFlow createErrorFlow() { return new CreateServiceInstanceBindingErrorFlow() { @Override public Mono<Void> error(CreateServiceInstanceBindingRequest request, Throwable t) { return Mono.empty(); } }; }