org.springframework.cloud.servicebroker.model.instance.GetServiceInstanceRequest Java Examples
The following examples show how to use
org.springframework.cloud.servicebroker.model.instance.GetServiceInstanceRequest.
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: MailServiceInstanceServiceUnitTest.java From tutorials with MIT License | 6 votes |
@Test public void givenServiceInstanceExists_whenGetServiceInstance_thenExistingServiceInstanceIsRetrieved() { // given service instance exists MailServiceInstance serviceInstance = new MailServiceInstance(MAIL_SERVICE_INSTANCE_ID, MAIL_SERVICE_DEFINITION_ID, MAIL_SERVICE_PLAN_ID, MAIL_DASHBOARD_URL); when(mailService.getServiceInstance(MAIL_SERVICE_INSTANCE_ID)).thenReturn(Mono.just(serviceInstance)); // when get service instance GetServiceInstanceRequest request = GetServiceInstanceRequest.builder() .serviceInstanceId(MAIL_SERVICE_INSTANCE_ID) .build(); // then the existing service instance is retrieved StepVerifier.create(mailServiceInstanceService.getServiceInstance(request)) .consumeNextWith(response -> { assertEquals(MAIL_SERVICE_DEFINITION_ID, response.getServiceDefinitionId()); assertEquals(MAIL_SERVICE_PLAN_ID, response.getPlanId()); assertEquals(MAIL_DASHBOARD_URL, response.getDashboardUrl()); }) .verifyComplete(); }
Example #2
Source File: BookstoreServiceInstanceServiceTests.java From bookstore-service-broker with Apache License 2.0 | 6 votes |
@Test public void getServiceInstanceWhenInstanceExists() { ServiceInstance serviceInstance = new ServiceInstance(SERVICE_INSTANCE_ID, "service-definition-id", "plan-id", new HashMap<>()); when(repository.findById(SERVICE_INSTANCE_ID)) .thenReturn(Mono.just(serviceInstance)); GetServiceInstanceRequest request = GetServiceInstanceRequest.builder() .serviceInstanceId(SERVICE_INSTANCE_ID) .build(); StepVerifier.create(service.getServiceInstance(request)) .consumeNextWith(response -> { assertThat(response.getServiceDefinitionId()).isEqualTo(serviceInstance.getServiceDefinitionId()); assertThat(response.getPlanId()).isEqualTo(serviceInstance.getPlanId()); assertThat(response.getParameters()).isEqualTo(serviceInstance.getParameters()); }) .verifyComplete(); verify(repository).findById(SERVICE_INSTANCE_ID); verifyNoMoreInteractions(repository); }
Example #3
Source File: ServiceInstanceControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void getServiceInstanceSucceeds() throws Exception { setupServiceInstanceService(GetServiceInstanceResponse.builder() .build()); MvcResult mvcResult = mockMvc.perform(get(buildCreateUpdateUrl(PLATFORM_INSTANCE_ID, false)) .header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION) .header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()) .contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON)) .andExpect(request().asyncStarted()) .andReturn(); mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isOk()); GetServiceInstanceRequest actualRequest = verifyGetServiceInstance(); assertHeaderValuesSet(actualRequest); }
Example #4
Source File: ServiceInstanceControllerResponseCodeTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
private void validateGetServiceInstanceWithResponseStatus(GetServiceInstanceResponse response, HttpStatus expectedStatus) { Mono<GetServiceInstanceResponse> responseMono; if (response == null) { responseMono = Mono.empty(); } else { responseMono = Mono.just(response); } given(serviceInstanceService.getServiceInstance(any(GetServiceInstanceRequest.class))) .willReturn(responseMono); ResponseEntity<GetServiceInstanceResponse> responseEntity = controller .getServiceInstance(pathVariables, null, null, null, null) .block(); assertThat(responseEntity).isNotNull(); assertThat(responseEntity.getStatusCode()).isEqualTo(expectedStatus); assertThat(responseEntity.getBody()).isEqualTo(response); }
Example #5
Source File: ServiceInstanceControllerRequestTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void getServiceInstanceParametersAreMappedToRequest() { GetServiceInstanceRequest expectedRequest = GetServiceInstanceRequest.builder() .serviceInstanceId("service-instance-id") .platformInstanceId("platform-instance-id") .apiInfoLocation("api-info-location") .originatingIdentity(identityContext) .requestIdentity("request-id") .build(); ServiceInstanceController controller = createControllerUnderTest(expectedRequest); controller.getServiceInstance(pathVariables, "service-instance-id", "api-info-location", encodeOriginatingIdentity(identityContext), "request-id") .block(); }
Example #6
Source File: ExampleServiceInstanceService.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Override public Mono<GetServiceInstanceResponse> getServiceInstance(GetServiceInstanceRequest request) { String serviceInstanceId = request.getServiceInstanceId(); // // retrieve the details of the specified service instance // String dashboardUrl = ""; /* retrieve dashboard URL */ return Mono.just(GetServiceInstanceResponse.builder() .dashboardUrl(dashboardUrl) .build()); }
Example #7
Source File: MailServiceInstanceServiceUnitTest.java From tutorials with MIT License | 5 votes |
@Test public void givenServiceInstanceDoesNotExist_whenGetServiceInstance_thenException() { // given service instance does not exist when(mailService.getServiceInstance(MAIL_SERVICE_INSTANCE_ID)).thenReturn(Mono.empty()); // when get service instance GetServiceInstanceRequest request = GetServiceInstanceRequest.builder() .serviceInstanceId(MAIL_SERVICE_INSTANCE_ID) .build(); // then ServiceInstanceDoesNotExistException is thrown StepVerifier.create(mailServiceInstanceService.getServiceInstance(request)) .expectErrorMatches(ex -> ex instanceof ServiceInstanceDoesNotExistException) .verify(); }
Example #8
Source File: MailServiceInstanceService.java From tutorials with MIT License | 5 votes |
@Override public Mono<GetServiceInstanceResponse> getServiceInstance(GetServiceInstanceRequest request) { return Mono.just(request.getServiceInstanceId()) .flatMap(instanceId -> mailService.getServiceInstance(instanceId) .switchIfEmpty(Mono.error(new ServiceInstanceDoesNotExistException(instanceId))) .flatMap(serviceInstance -> Mono.just(GetServiceInstanceResponse.builder() .serviceDefinitionId(serviceInstance.getServiceDefinitionId()) .planId(serviceInstance.getPlanId()) .dashboardUrl(serviceInstance.getDashboardUrl()) .build()))); }
Example #9
Source File: ServiceInstanceControllerResponseCodeTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Test void getServiceInstanceWithMissingInstanceGivesExpectedStatus() { given(serviceInstanceService.getServiceInstance(any(GetServiceInstanceRequest.class))) .willReturn(Mono.error(new ServiceInstanceDoesNotExistException("instance does not exist"))); ResponseEntity<GetServiceInstanceResponse> responseEntity = controller .getServiceInstance(pathVariables, null, "service-definition-id", null, null) .block(); assertThat(responseEntity).isNotNull(); assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); }
Example #10
Source File: ServiceInstanceController.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
/** * REST controller for getting a service instance * * @param pathVariables the path variables * @param serviceInstanceId the service instance ID * @param apiInfoLocation location of the API info endpoint of the platform instance * @param originatingIdentityString identity of the user that initiated the request from the platform * @param requestIdentity identity of the request sent from the platform * @return the response */ @GetMapping({PLATFORM_PATH_MAPPING, PATH_MAPPING}) public Mono<ResponseEntity<GetServiceInstanceResponse>> getServiceInstance( @PathVariable Map<String, String> pathVariables, @PathVariable(ServiceBrokerRequest.INSTANCE_ID_PATH_VARIABLE) String serviceInstanceId, @RequestHeader(value = ServiceBrokerRequest.API_INFO_LOCATION_HEADER, required = false) String apiInfoLocation, @RequestHeader(value = ServiceBrokerRequest.ORIGINATING_IDENTITY_HEADER, required = false) String originatingIdentityString, @RequestHeader(value = ServiceBrokerRequest.REQUEST_IDENTITY_HEADER, required = false) String requestIdentity) { return Mono.just(GetServiceInstanceRequest.builder() .serviceInstanceId(serviceInstanceId) .platformInstanceId(pathVariables.get(ServiceBrokerRequest.PLATFORM_INSTANCE_ID_VARIABLE)) .apiInfoLocation(apiInfoLocation) .originatingIdentity(parseOriginatingIdentity(originatingIdentityString)) .requestIdentity(requestIdentity) .build()) .flatMap(request -> service.getServiceInstance(request) .doOnRequest(v -> { LOG.info("Getting service instance"); LOG.debug(DEBUG_REQUEST, request); }) .doOnSuccess(response -> { LOG.info("Getting service instance succeeded"); LOG.debug(DEBUG_RESPONSE, serviceInstanceId, response); }) .doOnError(e -> LOG.error("Error getting service instance. error=" + e.getMessage(), e))) .map(response -> new ResponseEntity<>(response, HttpStatus.OK)) .switchIfEmpty(Mono.just(new ResponseEntity<>(HttpStatus.OK))) .onErrorResume(e -> { if (e instanceof ServiceInstanceDoesNotExistException) { return Mono.just(new ResponseEntity<>(HttpStatus.NOT_FOUND)); } else { return Mono.error(e); } }); }
Example #11
Source File: TestServiceInstanceService.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Override public Mono<GetServiceInstanceResponse> getServiceInstance(GetServiceInstanceRequest request) { if (IN_PROGRESS_SERVICE_INSTANCE_ID.equals(request.getServiceInstanceId())) { return Mono.error(new ServiceBrokerOperationInProgressException("task_10")); } return Mono.just(GetServiceInstanceResponse.builder() .build()); }
Example #12
Source File: ServiceInstanceControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Test void getServiceInstanceSucceeds() throws Exception { setupServiceInstanceService(GetServiceInstanceResponse.builder() .build()); client.get().uri(buildCreateUpdateUrl(PLATFORM_INSTANCE_ID, false)) .header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION) .header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()) .accept(MediaType.APPLICATION_JSON) .exchange() .expectStatus().isOk(); GetServiceInstanceRequest actualRequest = verifyGetServiceInstance(); assertHeaderValuesSet(actualRequest); }
Example #13
Source File: BookstoreServiceInstanceServiceTests.java From bookstore-service-broker with Apache License 2.0 | 5 votes |
@Test public void getServiceInstanceWhenInstanceDoesNotExists() { when(repository.findById(SERVICE_INSTANCE_ID)) .thenReturn(Mono.empty()); GetServiceInstanceRequest request = GetServiceInstanceRequest.builder() .serviceInstanceId(SERVICE_INSTANCE_ID) .build(); StepVerifier.create(service.getServiceInstance(request)) .expectErrorMatches(e -> e instanceof ServiceInstanceDoesNotExistException) .verify(); }
Example #14
Source File: BookStoreServiceInstanceService.java From bookstore-service-broker with Apache License 2.0 | 5 votes |
@Override public Mono<GetServiceInstanceResponse> getServiceInstance(GetServiceInstanceRequest request) { return Mono.just(request.getServiceInstanceId()) .flatMap(instanceId -> instanceRepository.findById(instanceId) .switchIfEmpty(Mono.error(new ServiceInstanceDoesNotExistException(instanceId))) .flatMap(serviceInstance -> Mono.just(GetServiceInstanceResponse.builder() .serviceDefinitionId(serviceInstance.getServiceDefinitionId()) .planId(serviceInstance.getPlanId()) .parameters(serviceInstance.getParameters()) .build()))); }
Example #15
Source File: NoOpServiceInstanceService.java From spring-cloud-open-service-broker with Apache License 2.0 | 4 votes |
@Override public Mono<GetServiceInstanceResponse> getServiceInstance(GetServiceInstanceRequest request) { return Mono.empty(); }
Example #16
Source File: WorkflowServiceInstanceService.java From spring-cloud-app-broker with Apache License 2.0 | 4 votes |
@Override public Mono<GetServiceInstanceResponse> getServiceInstance(GetServiceInstanceRequest request) { //TODO add functionality return Mono.empty(); }
Example #17
Source File: ServiceInstanceEventService.java From spring-cloud-open-service-broker with Apache License 2.0 | 4 votes |
@Override public Mono<GetServiceInstanceResponse> getServiceInstance(GetServiceInstanceRequest request) { return service.getServiceInstance(request); }
Example #18
Source File: AbstractServiceInstanceControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 4 votes |
protected GetServiceInstanceRequest verifyGetServiceInstance() { ArgumentCaptor<GetServiceInstanceRequest> argumentCaptor = ArgumentCaptor .forClass(GetServiceInstanceRequest.class); Mockito.verify(serviceInstanceService).getServiceInstance(argumentCaptor.capture()); return argumentCaptor.getValue(); }
Example #19
Source File: ServiceInstanceControllerRequestTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 4 votes |
@Override public Mono<GetServiceInstanceResponse> getServiceInstance(GetServiceInstanceRequest request) { assertThat(request).isEqualTo(expectedRequest); return Mono.empty(); }
Example #20
Source File: AbstractServiceInstanceControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 4 votes |
protected void setupServiceInstanceService(ServiceBrokerOperationInProgressException exception) { given(serviceInstanceService.getServiceInstance(any(GetServiceInstanceRequest.class))) .willReturn(Mono.error(exception)); }
Example #21
Source File: AbstractServiceInstanceControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 4 votes |
protected void setupServiceInstanceService(GetServiceInstanceResponse response) { given(serviceInstanceService.getServiceInstance(any(GetServiceInstanceRequest.class))) .willReturn(Mono.just(response)); }
Example #22
Source File: NoOpServiceInstanceService.java From spring-cloud-open-service-broker with Apache License 2.0 | 4 votes |
@Override public Mono<GetServiceInstanceResponse> getServiceInstance(GetServiceInstanceRequest request) { return Mono.empty(); }
Example #23
Source File: ServiceInstanceService.java From spring-cloud-open-service-broker with Apache License 2.0 | 3 votes |
/** * Get the details of a service instance. * * @param request containing the details of the request * @return a {@link GetServiceInstanceResponse} on successful processing of the request * @throws ServiceInstanceDoesNotExistException if a service instance with the given ID is not known to the * broker * @throws ServiceBrokerOperationInProgressException if a service instance provisioning is still in progress * @throws ServiceBrokerConcurrencyException if a service instance is being updated and therefore cannot be * fetched */ default Mono<GetServiceInstanceResponse> getServiceInstance(GetServiceInstanceRequest request) { return Mono.error(new UnsupportedOperationException( "This service broker does not support retrieving service instances. " + "The service broker should set 'instances_retrievable:false' in the service catalog, " + "or provide an implementation of the fetch instance API.")); }