org.springframework.cloud.servicebroker.exception.ServiceInstanceDoesNotExistException Java Examples
The following examples show how to use
org.springframework.cloud.servicebroker.exception.ServiceInstanceDoesNotExistException.
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: TestServiceInstanceService.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Override public Mono<UpdateServiceInstanceResponse> updateServiceInstance(UpdateServiceInstanceRequest request) { if (IN_PROGRESS_SERVICE_INSTANCE_ID.equals(request.getServiceInstanceId())) { return Mono.error(new ServiceBrokerUpdateOperationInProgressException("task_10")); } if (UNKNOWN_SERVICE_INSTANCE_ID.equals(request.getServiceInstanceId())) { return Mono.error(new ServiceInstanceDoesNotExistException(UNKNOWN_SERVICE_INSTANCE_ID)); } if (request.isAsyncAccepted()) { return Mono.just(UpdateServiceInstanceResponse.builder() .async(true) .operation("working") .dashboardUrl("https://dashboard.example.local") .build()); } else { return Mono.just(UpdateServiceInstanceResponse.builder() .dashboardUrl("https://dashboard.example.local") .build()); } }
Example #2
Source File: TestServiceInstanceService.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Override public Mono<DeleteServiceInstanceResponse> deleteServiceInstance(DeleteServiceInstanceRequest 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(UNKNOWN_SERVICE_INSTANCE_ID)); } if (request.isAsyncAccepted()) { return Mono.just(DeleteServiceInstanceResponse.builder() .async(true) .operation("working") .build()); } else { return Mono.just(DeleteServiceInstanceResponse.builder() .build()); } }
Example #3
Source File: TestServiceInstanceBindingService.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@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 #4
Source File: ServiceInstanceBindingControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@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 #5
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 #6
Source File: ServiceInstanceBindingControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@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
Source File: ServiceInstanceBindingControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void createBindingWithUnknownServiceInstanceIdFails() throws Exception { setupCatalogService(); given(serviceInstanceBindingService .createServiceInstanceBinding(any(CreateServiceInstanceBindingRequest.class))) .willThrow(new ServiceInstanceDoesNotExistException(SERVICE_INSTANCE_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().isUnprocessableEntity()) .andExpect(jsonPath("$.description", containsString(SERVICE_INSTANCE_ID))); }
Example #8
Source File: NamespaceBindingWorkflow.java From ecs-cf-service-broker with Apache License 2.0 | 6 votes |
@Override public Map<String, Object> getCredentials(String secretKey, Map<String, Object> parameters) throws IOException, EcsManagementClientException { ServiceInstance instance = instanceRepository.find(instanceId); if (instance == null) throw new ServiceInstanceDoesNotExistException(instanceId); if (instance.getName() == null) instance.setName(instance.getServiceInstanceId()); String namespaceName = instance.getName(); Map<String, Object> credentials = super.getCredentials(secretKey); // Get custom endpoint for namespace String endpoint = ecs.getNamespaceURL(ecs.prefix(namespaceName), createRequest.getParameters(), instance.getServiceSettings()); credentials.put("endpoint", endpoint); // Add s3 URL credentials.put("s3Url", getS3Url(endpoint, secretKey)); return credentials; }
Example #9
Source File: ServiceInstanceBindingControllerResponseCodeTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Test void getServiceBindingWithMissingServiceInstanceGivesExpectedStatus() { given(bindingService.getServiceInstanceBinding(any(GetServiceInstanceBindingRequest.class))) .willThrow(new ServiceInstanceDoesNotExistException("nonexistent-service-id")); ResponseEntity<GetServiceInstanceBindingResponse> responseEntity = controller .getServiceInstanceBinding(pathVariables, "nonexistent-service-id", "nonexistent-binding-id", null, 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: ServiceInstanceBindingController.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
/** * REST controller for getting a service instance binding * * @param pathVariables the path variables * @param serviceInstanceId the service instance ID * @param bindingId the service binding 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<GetServiceInstanceBindingResponse>> getServiceInstanceBinding( @PathVariable Map<String, String> pathVariables, @PathVariable(ServiceBrokerRequest.INSTANCE_ID_PATH_VARIABLE) String serviceInstanceId, @PathVariable(ServiceBrokerRequest.BINDING_ID_PATH_VARIABLE) String bindingId, @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(GetServiceInstanceBindingRequest.builder() .serviceInstanceId(serviceInstanceId) .bindingId(bindingId) .platformInstanceId(pathVariables.get(ServiceBrokerRequest.PLATFORM_INSTANCE_ID_VARIABLE)) .apiInfoLocation(apiInfoLocation) .originatingIdentity(parseOriginatingIdentity(originatingIdentityString)) .requestIdentity(requestIdentity) .build()) .flatMap(req -> service.getServiceInstanceBinding(req) .doOnRequest(v -> { LOG.info("Getting a service instance binding"); LOG.debug(DEBUG_REQUEST, req); }) .doOnSuccess(response -> { LOG.info("Getting a service instance binding succeeded"); LOG.debug("bindingId={}", bindingId); }) .doOnError(e -> LOG.error("Error getting service instance binding. error=" + e.getMessage(), e))) .map(response -> new ResponseEntity<>(response, HttpStatus.OK)) .switchIfEmpty(Mono.just(new ResponseEntity<>(HttpStatus.OK))) .onErrorResume(e -> { if (e instanceof ServiceInstanceBindingDoesNotExistException || e instanceof ServiceInstanceDoesNotExistException) { return Mono.just(new ResponseEntity<>(HttpStatus.NOT_FOUND)); } else { return Mono.error(e); } }); }
Example #12
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 #13
Source File: ServiceInstanceControllerResponseCodeTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Test void deleteServiceInstanceWithMissingInstanceGivesExpectedStatus() { given(serviceInstanceService.deleteServiceInstance(any(DeleteServiceInstanceRequest.class))) .willReturn(Mono.error(new ServiceInstanceDoesNotExistException("instance does not exist"))); ResponseEntity<DeleteServiceInstanceResponse> responseEntity = controller .deleteServiceInstance(pathVariables, null, "service-definition-id", "service-definition-plan-id", false, null, null, null) .block(); assertThat(responseEntity).isNotNull(); assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.GONE); }
Example #14
Source File: TestServiceInstanceBindingService.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Override public Mono<CreateServiceInstanceBindingResponse> createServiceInstanceBinding( CreateServiceInstanceBindingRequest request) { if (IN_PROGRESS_SERVICE_INSTANCE_ID.equals(request.getServiceInstanceId())) { return Mono.error(new ServiceBrokerCreateOperationInProgressException("task_10")); } if (EXISTING_SERVICE_INSTANCE_ID.equals(request.getServiceInstanceId())) { return Mono.just(CreateServiceInstanceAppBindingResponse.builder() .bindingExisted(true) .build()); } if (UNKNOWN_SERVICE_INSTANCE_ID.equals(request.getServiceInstanceId())) { return Mono.error(new ServiceInstanceDoesNotExistException(request.getServiceInstanceId())); } if (request.isAsyncAccepted()) { return Mono.just(CreateServiceInstanceAppBindingResponse.builder() .async(true) .operation("working") .bindingExisted(false) .build()); } else { return Mono.just(CreateServiceInstanceAppBindingResponse.builder() .bindingExisted(false) .build()); } }
Example #15
Source File: ServiceBrokerExceptionHandlerTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Test void serviceInstanceDoesNotExistException() { ServiceInstanceDoesNotExistException exception = new ServiceInstanceDoesNotExistException("service-instance-id"); ErrorMessage errorMessage = exceptionHandler.handleException(exception); assertThat(errorMessage.getError()).isNull(); assertThat(errorMessage.getMessage()).contains("id=service-instance-id"); }
Example #16
Source File: ServiceInstanceEventServiceTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Override public Mono<DeleteServiceInstanceResponse> deleteServiceInstance( DeleteServiceInstanceRequest request) { if (request.getServiceDefinitionId() == null) { return Mono.error(new ServiceInstanceDoesNotExistException("service-instance-id")); } return Mono.just(DeleteServiceInstanceResponse.builder().build()); }
Example #17
Source File: ServiceInstanceBindingEventServiceTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Override public Mono<GetServiceInstanceBindingResponse> getServiceInstanceBinding( GetServiceInstanceBindingRequest request) { if (request.getBindingId() == null) { return Mono.error(new ServiceInstanceDoesNotExistException("service-instance-id")); } return Mono.just(GetServiceInstanceAppBindingResponse.builder().build()); }
Example #18
Source File: MongoServiceInstanceService.java From cloudfoundry-service-broker with Apache License 2.0 | 5 votes |
@Override public DeleteServiceInstanceResponse deleteServiceInstance(DeleteServiceInstanceRequest request) throws MongoServiceException { String instanceId = request.getServiceInstanceId(); ServiceInstance instance = repository.findOne(instanceId); if (instance == null) { throw new ServiceInstanceDoesNotExistException(instanceId); } mongo.deleteDatabase(instanceId); repository.delete(instanceId); return new DeleteServiceInstanceResponse(); }
Example #19
Source File: MongoServiceInstanceService.java From cloudfoundry-service-broker with Apache License 2.0 | 5 votes |
@Override public UpdateServiceInstanceResponse updateServiceInstance(UpdateServiceInstanceRequest request) { String instanceId = request.getServiceInstanceId(); ServiceInstance instance = repository.findOne(instanceId); if (instance == null) { throw new ServiceInstanceDoesNotExistException(instanceId); } repository.delete(instanceId); ServiceInstance updatedInstance = new ServiceInstance(request); repository.save(updatedInstance); return new UpdateServiceInstanceResponse(); }
Example #20
Source File: MongoServiceInstanceServiceTest.java From cloudfoundry-service-broker with Apache License 2.0 | 5 votes |
@Test(expected = ServiceInstanceDoesNotExistException.class) public void unknownServiceInstanceDeleteCallSuccessful() throws Exception { when(repository.findOne(any(String.class))).thenReturn(null); DeleteServiceInstanceRequest request = buildDeleteRequest(); DeleteServiceInstanceResponse response = service.deleteServiceInstance(request); assertNotNull(response); assertFalse(response.isAsync()); verify(mongo).deleteDatabase(request.getServiceInstanceId()); verify(repository).delete(request.getServiceInstanceId()); }
Example #21
Source File: MailServiceInstanceBindingService.java From tutorials with MIT License | 5 votes |
@Override public Mono<CreateServiceInstanceBindingResponse> createServiceInstanceBinding( CreateServiceInstanceBindingRequest request) { return Mono.just(CreateServiceInstanceAppBindingResponse.builder()) .flatMap(responseBuilder -> mailService.serviceBindingExists( request.getServiceInstanceId(), request.getBindingId()) .flatMap(exists -> { if (exists) { return mailService.getServiceBinding( request.getServiceInstanceId(), request.getBindingId()) .flatMap(serviceBinding -> Mono.just(responseBuilder .bindingExisted(true) .credentials(serviceBinding.getCredentials()) .build())); } else { return mailService.createServiceBinding( request.getServiceInstanceId(), request.getBindingId()) .switchIfEmpty(Mono.error( new ServiceInstanceDoesNotExistException( request.getServiceInstanceId()))) .flatMap(mailServiceBinding -> Mono.just(responseBuilder .bindingExisted(false) .credentials(mailServiceBinding.getCredentials()) .build())); } })); }
Example #22
Source File: MailServiceInstanceService.java From tutorials with MIT License | 5 votes |
@Override public Mono<DeleteServiceInstanceResponse> deleteServiceInstance(DeleteServiceInstanceRequest request) { return Mono.just(request.getServiceInstanceId()) .flatMap(instanceId -> mailService.serviceInstanceExists(instanceId) .flatMap(exists -> { if (exists) { return mailService.deleteServiceInstance(instanceId) .thenReturn(DeleteServiceInstanceResponse.builder().build()); } else { return Mono.error(new ServiceInstanceDoesNotExistException(instanceId)); } })); }
Example #23
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 #24
Source File: MailServiceInstanceServiceUnitTest.java From tutorials with MIT License | 5 votes |
@Test public void givenServiceInstanceDoesNotExist_whenDeleteServiceInstance_thenException() { // given service instance does not exist when(mailService.serviceInstanceExists(MAIL_SERVICE_INSTANCE_ID)).thenReturn(Mono.just(false)); // when delete service instance DeleteServiceInstanceRequest request = DeleteServiceInstanceRequest.builder() .serviceInstanceId(MAIL_SERVICE_INSTANCE_ID) .build(); // then ServiceInstanceDoesNotExistException is thrown StepVerifier.create(mailServiceInstanceService.deleteServiceInstance(request)) .expectErrorMatches(ex -> ex instanceof ServiceInstanceDoesNotExistException) .verify(); }
Example #25
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 #26
Source File: BucketBindingWorkflow.java From ecs-cf-service-broker with Apache License 2.0 | 5 votes |
@Override public String createBindingUser() throws EcsManagementClientException, IOException, JAXBException { UserSecretKey userSecretKey = ecs.createUser(bindingId); Map<String, Object> parameters = createRequest.getParameters(); ServiceInstance instance = instanceRepository.find(instanceId); if (instance == null) throw new ServiceInstanceDoesNotExistException(instanceId); if (instance.getName() == null) instance.setName(instance.getServiceInstanceId()); String bucketName = instance.getName(); String export = ""; List<String> permissions = null; if (parameters != null) { permissions = (List<String>) parameters.get("permissions"); export = (String) parameters.getOrDefault("export", null); } if (permissions == null) { ecs.addUserToBucket(bucketName, bindingId); } else { ecs.addUserToBucket(bucketName, bindingId, permissions); } if (ecs.getBucketFileEnabled(bucketName)) { volumeMounts = createVolumeExport(export, new URL(ecs.getObjectEndpoint()), parameters); } return userSecretKey.getSecretKey(); }
Example #27
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 #28
Source File: BookStoreServiceInstanceService.java From bookstore-service-broker with Apache License 2.0 | 5 votes |
@Override public Mono<DeleteServiceInstanceResponse> deleteServiceInstance(DeleteServiceInstanceRequest request) { return Mono.just(request.getServiceInstanceId()) .flatMap(instanceId -> instanceRepository.existsById(instanceId) .flatMap(exists -> { if (exists) { return storeService.deleteBookStore(instanceId) .then(instanceRepository.deleteById(instanceId)) .thenReturn(DeleteServiceInstanceResponse.builder().build()); } else { return Mono.error(new ServiceInstanceDoesNotExistException(instanceId)); } })); }
Example #29
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 #30
Source File: BookstoreServiceInstanceServiceTests.java From bookstore-service-broker with Apache License 2.0 | 5 votes |
@Test public void deleteServiceInstanceWhenInstanceDoesNotExist() { when(repository.existsById(SERVICE_INSTANCE_ID)) .thenReturn(Mono.just(false)); DeleteServiceInstanceRequest request = DeleteServiceInstanceRequest.builder() .serviceInstanceId(SERVICE_INSTANCE_ID) .build(); StepVerifier.create(service.deleteServiceInstance(request)) .expectErrorMatches(e -> e instanceof ServiceInstanceDoesNotExistException) .verify(); }