org.springframework.cloud.servicebroker.model.binding.BindResource Java Examples
The following examples show how to use
org.springframework.cloud.servicebroker.model.binding.BindResource.
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: 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 #2
Source File: WorkflowServiceInstanceBindingServiceTest.java From spring-cloud-app-broker with Apache License 2.0 | 5 votes |
@Test void createServiceInstanceAppBindingWithNoWorkflows() { given(stateRepository.saveState(anyString(), anyString(), any(OperationState.class), anyString())) .willReturn(Mono.just( new ServiceInstanceState(OperationState.IN_PROGRESS, "create service instance binding started", new Timestamp(Instant.now().minusSeconds(60).toEpochMilli())))) .willReturn(Mono.just( new ServiceInstanceState(OperationState.SUCCEEDED, "create service instance binding completed", new Timestamp(Instant.now().minusSeconds(30).toEpochMilli())))); this.workflowServiceInstanceBindingService = new WorkflowServiceInstanceBindingService( this.stateRepository, null, null, null); CreateServiceInstanceBindingRequest request = CreateServiceInstanceBindingRequest.builder() .serviceInstanceId("foo-service") .bindingId("foo-binding") .bindResource(BindResource.builder() .appGuid("foo-guid") .build()) .build(); StepVerifier.create(workflowServiceInstanceBindingService.createServiceInstanceBinding(request)) .assertNext(response -> { InOrder repoOrder = inOrder(stateRepository); repoOrder.verify(stateRepository) .saveState(eq("foo-service"), eq("foo-binding"), eq(OperationState.IN_PROGRESS), eq("create service instance binding started")); repoOrder.verify(stateRepository) .saveState(eq("foo-service"), eq("foo-binding"), eq(OperationState.SUCCEEDED), eq("create service instance binding completed")); repoOrder.verifyNoMoreInteractions(); assertThat(response).isNotNull(); assertThat(response).isInstanceOf(CreateServiceInstanceAppBindingResponse.class); }) .verifyComplete(); }
Example #3
Source File: WorkflowServiceInstanceBindingServiceTest.java From spring-cloud-app-broker with Apache License 2.0 | 5 votes |
@Test void createServiceInstanceRouteBindingWithNoWorkflows() { given(stateRepository.saveState(anyString(), anyString(), any(OperationState.class), anyString())) .willReturn(Mono.just( new ServiceInstanceState(OperationState.IN_PROGRESS, "create service instance binding started", new Timestamp(Instant.now().minusSeconds(60).toEpochMilli())))) .willReturn(Mono.just( new ServiceInstanceState(OperationState.SUCCEEDED, "create service instance binding completed", new Timestamp(Instant.now().minusSeconds(30).toEpochMilli())))); this.workflowServiceInstanceBindingService = new WorkflowServiceInstanceBindingService( this.stateRepository, null, null, null); CreateServiceInstanceBindingRequest request = CreateServiceInstanceBindingRequest.builder() .serviceInstanceId("foo-service") .bindingId("foo-binding") .bindResource(BindResource.builder() .route("foo-route") .build()) .build(); StepVerifier.create(workflowServiceInstanceBindingService.createServiceInstanceBinding(request)) .assertNext(response -> { InOrder repoOrder = inOrder(stateRepository); repoOrder.verify(stateRepository) .saveState(eq("foo-service"), eq("foo-binding"), eq(OperationState.IN_PROGRESS), eq("create service instance binding started")); repoOrder.verify(stateRepository) .saveState(eq("foo-service"), eq("foo-binding"), eq(OperationState.SUCCEEDED), eq("create service instance binding completed")); repoOrder.verifyNoMoreInteractions(); assertThat(response).isNotNull(); assertThat(response).isInstanceOf(CreateServiceInstanceRouteBindingResponse.class); }) .verifyComplete(); }
Example #4
Source File: WorkflowServiceInstanceBindingServiceTest.java From spring-cloud-app-broker with Apache License 2.0 | 5 votes |
@Test void createServiceInstanceAppBindingWithResponseError() { CreateServiceInstanceBindingRequest request = CreateServiceInstanceBindingRequest.builder() .serviceInstanceId("foo-id") .bindResource(BindResource.builder() .appGuid("foo-guid") .build()) .build(); CreateServiceInstanceAppBindingResponseBuilder responseBuilder = CreateServiceInstanceAppBindingResponse .builder(); given(createServiceInstanceAppBindingWorkflow1.accept(request)) .willReturn(Mono.just(true)); given(createServiceInstanceAppBindingWorkflow1 .buildResponse(eq(request), any(CreateServiceInstanceAppBindingResponseBuilder.class))) .willReturn(Mono.error(new ServiceBrokerException("create foo error"))); given(createServiceInstanceAppBindingWorkflow2.accept(request)) .willReturn(Mono.just(true)); given(createServiceInstanceAppBindingWorkflow2 .buildResponse(eq(request), any(CreateServiceInstanceAppBindingResponseBuilder.class))) .willReturn(Mono.just(responseBuilder)); StepVerifier.create(workflowServiceInstanceBindingService.createServiceInstanceBinding(request)) .expectErrorSatisfies(e -> assertThat(e) .isInstanceOf(ServiceBrokerException.class) .hasMessage("create foo error")) .verify(); }
Example #5
Source File: WorkflowServiceInstanceBindingServiceTest.java From spring-cloud-app-broker with Apache License 2.0 | 5 votes |
@Test void createServiceInstanceRouteBindingWithResponseError() { CreateServiceInstanceBindingRequest request = CreateServiceInstanceBindingRequest.builder() .serviceInstanceId("foo-id") .bindResource(BindResource.builder() .route("foo-route") .build()) .build(); CreateServiceInstanceRouteBindingResponseBuilder responseBuilder = CreateServiceInstanceRouteBindingResponse .builder(); given(createServiceInstanceRouteBindingWorkflow1.accept(request)) .willReturn(Mono.just(true)); given(createServiceInstanceRouteBindingWorkflow1 .buildResponse(eq(request), any(CreateServiceInstanceRouteBindingResponseBuilder.class))) .willReturn(Mono.error(new ServiceBrokerException("create foo error"))); given(createServiceInstanceRouteBindingWorkflow2.accept(request)) .willReturn(Mono.just(true)); given(createServiceInstanceRouteBindingWorkflow2 .buildResponse(eq(request), any(CreateServiceInstanceRouteBindingResponseBuilder.class))) .willReturn(Mono.just(responseBuilder)); StepVerifier.create(workflowServiceInstanceBindingService.createServiceInstanceBinding(request)) .expectErrorSatisfies(e -> assertThat(e) .isInstanceOf(ServiceBrokerException.class) .hasMessage("create foo error")) .verify(); }
Example #6
Source File: ServiceInstanceBindingControllerRequestTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
private CreateServiceInstanceBindingRequestBuilder buildCreateRequest() { return CreateServiceInstanceBindingRequest.builder() .serviceDefinitionId(serviceDefinition.getId()) .planId("plan-id") .bindResource(BindResource.builder().build()) .parameters("create-param-1", "value1") .parameters("create-param-2", "value2") .context(requestContext); }
Example #7
Source File: WorkflowServiceInstanceBindingServiceTest.java From spring-cloud-app-broker with Apache License 2.0 | 4 votes |
@Test void createServiceInstanceAppBinding() { given(stateRepository.saveState(anyString(), anyString(), any(OperationState.class), anyString())) .willReturn(Mono.just( new ServiceInstanceState(OperationState.IN_PROGRESS, "create service instance binding started", new Timestamp(Instant.now().minusSeconds(60).toEpochMilli())))) .willReturn(Mono.just( new ServiceInstanceState(OperationState.SUCCEEDED, "create service instance binding completed", new Timestamp(Instant.now().minusSeconds(30).toEpochMilli())))); CreateServiceInstanceBindingRequest request = CreateServiceInstanceBindingRequest.builder() .serviceInstanceId("foo-service") .bindingId("foo-binding") .bindResource(BindResource.builder() .appGuid("foo-guid") .build()) .build(); CreateServiceInstanceAppBindingResponseBuilder responseBuilder = CreateServiceInstanceAppBindingResponse .builder(); CreateServiceInstanceAppBindingResponse builtResponse = CreateServiceInstanceAppBindingResponse.builder() .async(true) .credentials("foo", "bar") .operation("working2") .build(); TestPublisher<Void> lowerOrderFlow = TestPublisher.create(); TestPublisher<Void> higherOrderFlow = TestPublisher.create(); given(createServiceInstanceAppBindingWorkflow1.accept(request)) .willReturn(Mono.just(true)); given(createServiceInstanceAppBindingWorkflow1.create(eq(request), eq(builtResponse))) .willReturn(lowerOrderFlow.mono()); given(createServiceInstanceAppBindingWorkflow1 .buildResponse(eq(request), any(CreateServiceInstanceAppBindingResponseBuilder.class))) .willReturn(Mono.just(responseBuilder .async(true) .operation("working1"))); given(createServiceInstanceAppBindingWorkflow2.accept(request)) .willReturn(Mono.just(true)); given(createServiceInstanceAppBindingWorkflow2.create(eq(request), eq(builtResponse))) .willReturn(higherOrderFlow.mono()); given(createServiceInstanceAppBindingWorkflow2 .buildResponse(eq(request), any(CreateServiceInstanceAppBindingResponseBuilder.class))) .willReturn(Mono.just(responseBuilder .credentials("foo", "bar") .operation("working2"))); StepVerifier.create(workflowServiceInstanceBindingService.createServiceInstanceBinding(request)) .assertNext(response -> { InOrder repoOrder = inOrder(stateRepository); repoOrder.verify(stateRepository) .saveState(eq("foo-service"), eq("foo-binding"), eq(OperationState.IN_PROGRESS), eq("create service instance binding started")); repoOrder.verify(stateRepository) .saveState(eq("foo-service"), eq("foo-binding"), eq(OperationState.SUCCEEDED), eq("create service instance binding completed")); repoOrder.verifyNoMoreInteractions(); lowerOrderFlow.complete(); lowerOrderFlow.assertWasNotRequested(); higherOrderFlow.complete(); lowerOrderFlow.assertWasRequested(); InOrder createOrder = inOrder(createServiceInstanceAppBindingWorkflow1, createServiceInstanceAppBindingWorkflow2); createOrder.verify(createServiceInstanceAppBindingWorkflow2).buildResponse(eq(request), any(CreateServiceInstanceAppBindingResponseBuilder.class)); createOrder.verify(createServiceInstanceAppBindingWorkflow1).buildResponse(eq(request), any(CreateServiceInstanceAppBindingResponseBuilder.class)); createOrder.verify(createServiceInstanceAppBindingWorkflow2).create(request, responseBuilder.build()); createOrder.verify(createServiceInstanceAppBindingWorkflow1).create(request, responseBuilder.build()); createOrder.verifyNoMoreInteractions(); CreateServiceInstanceAppBindingResponse r = (CreateServiceInstanceAppBindingResponse) response; assertThat(r).isNotNull(); assertThat(r.getCredentials()).containsOnly(entry("foo", "bar")); assertThat(r.isAsync()).isTrue(); assertThat(r.getOperation()).isEqualTo("working2"); }) .verifyComplete(); }
Example #8
Source File: WorkflowServiceInstanceBindingServiceTest.java From spring-cloud-app-broker with Apache License 2.0 | 4 votes |
@Test void createServiceInstanceRouteBinding() { given(stateRepository.saveState(anyString(), anyString(), any(OperationState.class), anyString())) .willReturn(Mono.just( new ServiceInstanceState(OperationState.IN_PROGRESS, "create service instance binding started", new Timestamp(Instant.now().minusSeconds(60).toEpochMilli())))) .willReturn(Mono.just( new ServiceInstanceState(OperationState.SUCCEEDED, "create service instance binding completed", new Timestamp(Instant.now().minusSeconds(30).toEpochMilli())))); CreateServiceInstanceBindingRequest request = CreateServiceInstanceBindingRequest.builder() .serviceInstanceId("foo-service") .bindingId("foo-binding") .bindResource(BindResource.builder() .route("foo-route") .build()) .build(); CreateServiceInstanceRouteBindingResponseBuilder responseBuilder = CreateServiceInstanceRouteBindingResponse .builder(); CreateServiceInstanceRouteBindingResponse builtResponse = CreateServiceInstanceRouteBindingResponse.builder() .async(true) .routeServiceUrl("foo-url") .operation("working2") .build(); TestPublisher<Void> lowerOrderFlow = TestPublisher.create(); TestPublisher<Void> higherOrderFlow = TestPublisher.create(); given(createServiceInstanceRouteBindingWorkflow1.accept(request)) .willReturn(Mono.just(true)); given(createServiceInstanceRouteBindingWorkflow1.create(eq(request), eq(builtResponse))) .willReturn(lowerOrderFlow.mono()); given(createServiceInstanceRouteBindingWorkflow1 .buildResponse(eq(request), any(CreateServiceInstanceRouteBindingResponseBuilder.class))) .willReturn(Mono.just(responseBuilder .async(true) .operation("working1"))); given(createServiceInstanceRouteBindingWorkflow2.accept(request)) .willReturn(Mono.just(true)); given(createServiceInstanceRouteBindingWorkflow2.create(eq(request), eq(builtResponse))) .willReturn(higherOrderFlow.mono()); given(createServiceInstanceRouteBindingWorkflow2 .buildResponse(eq(request), any(CreateServiceInstanceRouteBindingResponseBuilder.class))) .willReturn(Mono.just(responseBuilder .routeServiceUrl("foo-url") .operation("working2"))); StepVerifier.create(workflowServiceInstanceBindingService.createServiceInstanceBinding(request)) .assertNext(response -> { InOrder repoOrder = inOrder(stateRepository); repoOrder.verify(stateRepository) .saveState(eq("foo-service"), eq("foo-binding"), eq(OperationState.IN_PROGRESS), eq("create service instance binding started")); repoOrder.verify(stateRepository) .saveState(eq("foo-service"), eq("foo-binding"), eq(OperationState.SUCCEEDED), eq("create service instance binding completed")); repoOrder.verifyNoMoreInteractions(); lowerOrderFlow.complete(); lowerOrderFlow.assertWasNotRequested(); higherOrderFlow.complete(); lowerOrderFlow.assertWasRequested(); InOrder createOrder = inOrder(createServiceInstanceRouteBindingWorkflow1, createServiceInstanceRouteBindingWorkflow2); createOrder.verify(createServiceInstanceRouteBindingWorkflow2).buildResponse(eq(request), any(CreateServiceInstanceRouteBindingResponseBuilder.class)); createOrder.verify(createServiceInstanceRouteBindingWorkflow1).buildResponse(eq(request), any(CreateServiceInstanceRouteBindingResponseBuilder.class)); createOrder.verify(createServiceInstanceRouteBindingWorkflow2).create(request, responseBuilder.build()); createOrder.verify(createServiceInstanceRouteBindingWorkflow1).create(request, responseBuilder.build()); createOrder.verifyNoMoreInteractions(); assertThat(response).isNotNull(); assertThat(response).isInstanceOf(CreateServiceInstanceRouteBindingResponse.class); assertThat(((CreateServiceInstanceRouteBindingResponse) response).getRouteServiceUrl()) .isEqualTo("foo-url"); assertThat(response.isAsync()).isTrue(); assertThat(response.getOperation()).isEqualTo("working2"); }) .verifyComplete(); }
Example #9
Source File: WorkflowServiceInstanceBindingServiceTest.java From spring-cloud-app-broker with Apache License 2.0 | 4 votes |
@Test void createServiceInstanceAppBindingWithAsyncError() { given(stateRepository.saveState(anyString(), anyString(), any(OperationState.class), anyString())) .willReturn(Mono.just( new ServiceInstanceState(OperationState.IN_PROGRESS, "create service instance binding started", new Timestamp(Instant.now().minusSeconds(60).toEpochMilli())))) .willReturn( Mono.just(new ServiceInstanceState(OperationState.FAILED, "create service instance binding failed", new Timestamp(Instant.now().minusSeconds(30).toEpochMilli())))); CreateServiceInstanceBindingRequest request = CreateServiceInstanceBindingRequest.builder() .serviceInstanceId("foo-service") .bindingId("foo-binding") .bindResource(BindResource.builder() .appGuid("foo-guid") .build()) .build(); CreateServiceInstanceAppBindingResponseBuilder responseBuilder = CreateServiceInstanceAppBindingResponse .builder(); given(createServiceInstanceAppBindingWorkflow1.accept(request)) .willReturn(Mono.just(true)); given(createServiceInstanceAppBindingWorkflow1.create(request, responseBuilder.build())) .willReturn(Mono.error(new RuntimeException("create foo error"))); given(createServiceInstanceAppBindingWorkflow1 .buildResponse(eq(request), any(CreateServiceInstanceAppBindingResponseBuilder.class))) .willReturn(Mono.just(responseBuilder)); given(createServiceInstanceAppBindingWorkflow2.accept(request)) .willReturn(Mono.just(true)); given(createServiceInstanceAppBindingWorkflow2.create(request, responseBuilder.build())) .willReturn(Mono.empty()); given(createServiceInstanceAppBindingWorkflow2 .buildResponse(eq(request), any(CreateServiceInstanceAppBindingResponseBuilder.class))) .willReturn(Mono.just(responseBuilder)); StepVerifier.create(workflowServiceInstanceBindingService.createServiceInstanceBinding(request)) .assertNext(response -> { InOrder repoOrder = inOrder(stateRepository); repoOrder.verify(stateRepository) .saveState(eq("foo-service"), eq("foo-binding"), eq(OperationState.IN_PROGRESS), eq("create service instance binding started")); repoOrder.verify(stateRepository) .saveState(eq("foo-service"), eq("foo-binding"), eq(OperationState.FAILED), eq("create foo error")); repoOrder.verifyNoMoreInteractions(); InOrder createOrder = inOrder(createServiceInstanceAppBindingWorkflow1, createServiceInstanceAppBindingWorkflow2); createOrder.verify(createServiceInstanceAppBindingWorkflow2).buildResponse(eq(request), any(CreateServiceInstanceAppBindingResponseBuilder.class)); createOrder.verify(createServiceInstanceAppBindingWorkflow1).buildResponse(eq(request), any(CreateServiceInstanceAppBindingResponseBuilder.class)); createOrder.verify(createServiceInstanceAppBindingWorkflow2).create(request, responseBuilder.build()); createOrder.verify(createServiceInstanceAppBindingWorkflow1).create(request, responseBuilder.build()); createOrder.verifyNoMoreInteractions(); assertThat(response).isNotNull(); assertThat(response).isInstanceOf(CreateServiceInstanceAppBindingResponse.class); }) .verifyComplete(); }
Example #10
Source File: WorkflowServiceInstanceBindingServiceTest.java From spring-cloud-app-broker with Apache License 2.0 | 4 votes |
@Test void createServiceInstanceRouteBindingWithAsyncError() { given(stateRepository.saveState(anyString(), anyString(), any(OperationState.class), anyString())) .willReturn(Mono.just( new ServiceInstanceState(OperationState.IN_PROGRESS, "create service instance binding started", new Timestamp(Instant.now().minusSeconds(60).toEpochMilli())))) .willReturn( Mono.just(new ServiceInstanceState(OperationState.FAILED, "create service instance binding failed", new Timestamp(Instant.now().minusSeconds(30).toEpochMilli())))); CreateServiceInstanceBindingRequest request = CreateServiceInstanceBindingRequest.builder() .serviceInstanceId("foo-service") .bindingId("foo-binding") .bindResource(BindResource.builder() .route("foo-route") .build()) .build(); CreateServiceInstanceRouteBindingResponseBuilder responseBuilder = CreateServiceInstanceRouteBindingResponse .builder(); given(createServiceInstanceRouteBindingWorkflow1.accept(request)) .willReturn(Mono.just(true)); given(createServiceInstanceRouteBindingWorkflow1.create(request, responseBuilder.build())) .willReturn(Mono.error(new RuntimeException("create foo error"))); given(createServiceInstanceRouteBindingWorkflow1 .buildResponse(eq(request), any(CreateServiceInstanceRouteBindingResponseBuilder.class))) .willReturn(Mono.just(responseBuilder)); given(createServiceInstanceRouteBindingWorkflow2.accept(request)) .willReturn(Mono.just(true)); given(createServiceInstanceRouteBindingWorkflow2.create(request, responseBuilder.build())) .willReturn(Mono.empty()); given(createServiceInstanceRouteBindingWorkflow2 .buildResponse(eq(request), any(CreateServiceInstanceRouteBindingResponseBuilder.class))) .willReturn(Mono.just(responseBuilder)); StepVerifier.create(workflowServiceInstanceBindingService.createServiceInstanceBinding(request)) .assertNext(response -> { InOrder repoOrder = inOrder(stateRepository); repoOrder.verify(stateRepository) .saveState(eq("foo-service"), eq("foo-binding"), eq(OperationState.IN_PROGRESS), eq("create service instance binding started")); repoOrder.verify(stateRepository) .saveState(eq("foo-service"), eq("foo-binding"), eq(OperationState.FAILED), eq("create foo error")); repoOrder.verifyNoMoreInteractions(); InOrder createOrder = inOrder(createServiceInstanceRouteBindingWorkflow1, createServiceInstanceRouteBindingWorkflow2); createOrder.verify(createServiceInstanceRouteBindingWorkflow2).buildResponse(eq(request), any(CreateServiceInstanceRouteBindingResponseBuilder.class)); createOrder.verify(createServiceInstanceRouteBindingWorkflow1).buildResponse(eq(request), any(CreateServiceInstanceRouteBindingResponseBuilder.class)); createOrder.verify(createServiceInstanceRouteBindingWorkflow2).create(request, responseBuilder.build()); createOrder.verify(createServiceInstanceRouteBindingWorkflow1).create(request, responseBuilder.build()); createOrder.verifyNoMoreInteractions(); assertThat(response).isNotNull(); assertThat(response).isInstanceOf(CreateServiceInstanceRouteBindingResponse.class); }) .verifyComplete(); }
Example #11
Source File: WorkflowServiceInstanceBindingServiceTest.java From spring-cloud-app-broker with Apache License 2.0 | 4 votes |
@Test void createServiceInstanceAppBindingWithNoAcceptsDoesNothing() { given(stateRepository.saveState(anyString(), anyString(), any(OperationState.class), anyString())) .willReturn( Mono.just(new ServiceInstanceState(OperationState.IN_PROGRESS, "create service instance started", new Timestamp(Instant.now().minusSeconds(60).toEpochMilli())))) .willReturn( Mono.just(new ServiceInstanceState(OperationState.SUCCEEDED, "create service instance completed", new Timestamp(Instant.now().minusSeconds(30).toEpochMilli())))); CreateServiceInstanceBindingRequest request = CreateServiceInstanceBindingRequest.builder() .serviceInstanceId("foo-service") .bindingId("foo-binding") .bindResource(BindResource.builder() .appGuid("foo-guid") .build()) .build(); given(createServiceInstanceAppBindingWorkflow1.accept(request)) .willReturn(Mono.just(false)); given(createServiceInstanceAppBindingWorkflow2.accept(request)) .willReturn(Mono.just(false)); StepVerifier.create(workflowServiceInstanceBindingService.createServiceInstanceBinding(request)) .assertNext(response -> { InOrder repoOrder = inOrder(stateRepository); repoOrder.verify(stateRepository) .saveState(eq("foo-service"), eq("foo-binding"), eq(OperationState.IN_PROGRESS), eq("create service instance binding started")); repoOrder.verify(stateRepository) .saveState(eq("foo-service"), eq("foo-binding"), eq(OperationState.SUCCEEDED), eq("create service instance binding completed")); repoOrder.verifyNoMoreInteractions(); then(createServiceInstanceAppBindingWorkflow1).shouldHaveNoMoreInteractions(); then(createServiceInstanceAppBindingWorkflow2).shouldHaveNoMoreInteractions(); assertThat(response).isNotNull(); assertThat(response).isInstanceOf(CreateServiceInstanceAppBindingResponse.class); }) .verifyComplete(); }
Example #12
Source File: WorkflowServiceInstanceBindingServiceTest.java From spring-cloud-app-broker with Apache License 2.0 | 4 votes |
@Test void createServiceInstanceRouteBindingWithNoAcceptsDoesNothing() { given(stateRepository.saveState(anyString(), anyString(), any(OperationState.class), anyString())) .willReturn( Mono.just(new ServiceInstanceState(OperationState.IN_PROGRESS, "create service instance started", new Timestamp(Instant.now().minusSeconds(60).toEpochMilli())))) .willReturn( Mono.just(new ServiceInstanceState(OperationState.SUCCEEDED, "create service instance completed", new Timestamp(Instant.now().minusSeconds(30).toEpochMilli())))); CreateServiceInstanceBindingRequest request = CreateServiceInstanceBindingRequest.builder() .serviceInstanceId("foo-service") .bindingId("foo-binding") .bindResource(BindResource.builder() .route("foo-route") .build()) .build(); given(createServiceInstanceRouteBindingWorkflow1.accept(request)) .willReturn(Mono.just(false)); given(createServiceInstanceRouteBindingWorkflow2.accept(request)) .willReturn(Mono.just(false)); StepVerifier.create(workflowServiceInstanceBindingService.createServiceInstanceBinding(request)) .assertNext(response -> { InOrder repoOrder = inOrder(stateRepository); repoOrder.verify(stateRepository) .saveState(eq("foo-service"), eq("foo-binding"), eq(OperationState.IN_PROGRESS), eq("create service instance binding started")); repoOrder.verify(stateRepository) .saveState(eq("foo-service"), eq("foo-binding"), eq(OperationState.SUCCEEDED), eq("create service instance binding completed")); repoOrder.verifyNoMoreInteractions(); then(createServiceInstanceRouteBindingWorkflow1).shouldHaveNoMoreInteractions(); then(createServiceInstanceRouteBindingWorkflow2).shouldHaveNoMoreInteractions(); assertThat(response).isNotNull(); assertThat(response).isInstanceOf(CreateServiceInstanceRouteBindingResponse.class); }) .verifyComplete(); }
Example #13
Source File: CredHubPersistingCreateServiceInstanceAppBindingWorkflowTest.java From spring-cloud-app-broker with Apache License 2.0 | 4 votes |
@Test @SuppressWarnings("serial") void storeCredentialsInCredHub() { CredentialName credentialName = ServiceInstanceCredentialName.builder() .serviceBrokerName("test-app-name") .serviceOfferingName("foo-definition-id") .serviceBindingId("foo-binding-id") .credentialName("credentials-json") .build(); CreateServiceInstanceBindingRequest request = CreateServiceInstanceBindingRequest .builder() .bindingId("foo-binding-id") .serviceInstanceId("foo-instance-id") .serviceDefinitionId("foo-definition-id") .bindResource(BindResource.builder() .appGuid("app-id") .properties("credential_client_id", "client-id") .build()) .build(); Map<String, Object> credentials = new HashMap<String, Object>() {{ put("credential4", "value4"); put("credential5", "value5"); }}; CreateServiceInstanceAppBindingResponseBuilder responseBuilder = CreateServiceInstanceAppBindingResponse .builder() .bindingExisted(true) .credentials("credential1", "value1") .credentials("credential2", 2) .credentials("credential3", true) .credentials(credentials) .syslogDrainUrl("https://logs.example.local") .volumeMounts(VolumeMount.builder().build()) .volumeMounts(VolumeMount.builder().build()) .volumeMounts(Arrays.asList( VolumeMount.builder().build(), VolumeMount.builder().build() )); given(this.credHubOperations.credentials()) .willReturn(credHubCredentialOperations); given(this.credHubOperations.permissionsV2()) .willReturn(credHubPermissionOperations); given(this.credHubCredentialOperations.write(any())) .willReturn(Mono.just(new CredentialDetails<>())); given(this.credHubPermissionOperations.addPermissions(any(), any())) .willReturn(Mono.just(Mockito.mock(CredentialPermission.class))); StepVerifier .create(this.workflow.buildResponse(request, responseBuilder)) .assertNext(createServiceInstanceAppBindingResponseBuilder -> { CreateServiceInstanceAppBindingResponse response = createServiceInstanceAppBindingResponseBuilder .build(); assertThat(response.isBindingExisted()).isEqualTo(true); assertThat(response.getCredentials()).hasSize(1); assertThat(response.getCredentials().get("credhub-ref")).isEqualTo(credentialName.getName()); assertThat(response.getSyslogDrainUrl()).isEqualTo("https://logs.example.local"); assertThat(response.getVolumeMounts()).hasSize(4); }) .verifyComplete(); verify(this.credHubCredentialOperations, times(1)) .write(any()); verify(this.credHubPermissionOperations, times(1)) .addPermissions(any(), any()); verifyNoMoreInteractions(this.credHubCredentialOperations); }
Example #14
Source File: ServiceInstanceBinding.java From ecs-cf-service-broker with Apache License 2.0 | 4 votes |
public BindResource getBindResource() { return bindResource; }
Example #15
Source File: ServiceInstanceBinding.java From ecs-cf-service-broker with Apache License 2.0 | 4 votes |
public void setBindResource(BindResource bindResource) { this.bindResource = bindResource; }