org.springframework.cloud.servicebroker.model.instance.OperationState Java Examples
The following examples show how to use
org.springframework.cloud.servicebroker.model.instance.OperationState.
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: WorkflowServiceInstanceBindingService.java From spring-cloud-app-broker with Apache License 2.0 | 6 votes |
private Mono<Void> delete(DeleteServiceInstanceBindingRequest request, DeleteServiceInstanceBindingResponse response) { return stateRepository.saveState(request.getServiceInstanceId(), request.getBindingId(), OperationState.IN_PROGRESS, "delete service instance binding started") .thenMany(invokeDeleteWorkflows(request, response) .doOnRequest(l -> { LOG.info("Deleting service instance binding"); LOG.debug("request={}", request); }) .doOnComplete(() -> { LOG.info("Finish deleting service instance binding"); LOG.debug("request={}, response={}", request, response); }) .doOnError(e -> LOG.error(String.format("Error deleting service instance binding. error=%s", e.getMessage()), e))) .thenEmpty(stateRepository.saveState(request.getServiceInstanceId(), request.getBindingId(), OperationState.SUCCEEDED, "delete service instance binding completed") .then()) .onErrorResume( exception -> stateRepository.saveState(request.getServiceInstanceId(), request.getBindingId(), OperationState.FAILED, exception.getMessage()) .then()); }
Example #2
Source File: InMemoryServiceInstanceStateRepositoryTest.java From spring-cloud-app-broker with Apache License 2.0 | 6 votes |
@Test void saveAndRemove() { StepVerifier.create(stateRepository.saveState("foo", OperationState.IN_PROGRESS, "bar")) .assertNext(serviceInstanceState -> { assertThat(serviceInstanceState.getOperationState()).isEqualTo(OperationState.IN_PROGRESS); assertThat(serviceInstanceState.getDescription()).isEqualTo("bar"); assertThat(serviceInstanceState.getLastUpdated()) .isEqualToIgnoringSeconds(Calendar.getInstance().getTime()); }) .verifyComplete(); StepVerifier.create(stateRepository.removeState("foo")) .assertNext(serviceInstanceState -> { assertThat(serviceInstanceState.getOperationState()).isEqualTo(OperationState.IN_PROGRESS); assertThat(serviceInstanceState.getDescription()).isEqualTo("bar"); assertThat(serviceInstanceState.getLastUpdated()) .isEqualToIgnoringSeconds(Calendar.getInstance().getTime()); }) .verifyComplete(); StepVerifier.create(stateRepository.getState("foo")) .expectError(IllegalArgumentException.class) .verify(); }
Example #3
Source File: DeleteInstanceWithServicesComponentTest.java From spring-cloud-app-broker with Apache License 2.0 | 6 votes |
@Test void deleteServicesWhenTheyExist() { cloudControllerFixture.stubGetBackingServiceInstance(BACKING_SI_NAME, BACKING_SERVICE_NAME, BACKING_PLAN_NAME); cloudControllerFixture.stubServiceBindingsDoNotExist(BACKING_SI_NAME); cloudControllerFixture.stubDeleteServiceInstance(BACKING_SI_NAME); // when the service instance is deleted given(brokerFixture.serviceInstanceRequest()) .when() .delete(brokerFixture.deleteServiceInstanceUrl(), "instance-id") .then() .statusCode(HttpStatus.ACCEPTED.value()); // when the "last_operation" API is polled given(brokerFixture.serviceInstanceRequest()) .when() .get(brokerFixture.getLastInstanceOperationUrl(), "instance-id") .then() .statusCode(HttpStatus.OK.value()) .body("state", is(equalTo(OperationState.IN_PROGRESS.toString()))); String state = brokerFixture.waitForAsyncOperationComplete("instance-id"); assertThat(state).isEqualTo(OperationState.SUCCEEDED.toString()); }
Example #4
Source File: ServiceInstanceBindingControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void lastOperationHasFailedStatus() throws Exception { setupServiceInstanceBindingService(GetLastServiceBindingOperationResponse.builder() .operationState(OperationState.FAILED) .description("not so good") .build()); MvcResult mvcResult = mockMvc.perform(get(buildLastOperationUrl())) .andExpect(request().asyncStarted()) .andExpect(status().isOk()) .andReturn(); mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isOk()) .andExpect(jsonPath("$.state", is(OperationState.FAILED.toString()))) .andExpect(jsonPath("$.description", is("not so good"))); }
Example #5
Source File: ServiceInstanceControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void lastOperationHasInProgressStatus() { setupServiceInstanceService(GetLastServiceOperationResponse.builder() .operationState(OperationState.IN_PROGRESS) .description("working on it") .build()); client.get().uri(buildLastOperationUrl()) .exchange() .expectStatus().isOk() .expectBody() .jsonPath("$.state").isEqualTo(OperationState.IN_PROGRESS.toString()) .jsonPath("$.description").isEqualTo("working on it"); GetLastServiceOperationRequest actualRequest = verifyLastOperation(); assertHeaderValuesNotSet(actualRequest); }
Example #6
Source File: ServiceInstanceBindingControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void lastOperationHasSucceededStatus() throws Exception { setupServiceInstanceBindingService(GetLastServiceBindingOperationResponse.builder() .operationState(OperationState.SUCCEEDED) .description("all good") .build()); MvcResult mvcResult = mockMvc.perform(get(buildLastOperationUrl(PLATFORM_INSTANCE_ID)) .header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION) .header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader())) .andExpect(request().asyncStarted()) .andExpect(status().isOk()) .andReturn(); mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isOk()) .andExpect(jsonPath("$.state", is(OperationState.SUCCEEDED.toString()))) .andExpect(jsonPath("$.description", is("all good"))); GetLastServiceBindingOperationRequest actualRequest = verifyLastOperation(); assertHeaderValuesSet(actualRequest); }
Example #7
Source File: ServiceInstanceControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void lastOperationHasFailedStatus() throws Exception { setupServiceInstanceService(GetLastServiceOperationResponse.builder() .operationState(OperationState.FAILED) .description("not so good") .build()); MvcResult mvcResult = mockMvc.perform(get(buildLastOperationUrl())) .andExpect(request().asyncStarted()) .andReturn(); mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isOk()) .andExpect(jsonPath("$.state", is(OperationState.FAILED.toString()))) .andExpect(jsonPath("$.description", is("not so good"))); }
Example #8
Source File: InMemoryServiceInstanceBindingStateRepositoryTest.java From spring-cloud-app-broker with Apache License 2.0 | 6 votes |
@Test void saveAndRemove() { StepVerifier .create(stateRepository.saveState("foo-service", "foo-binding", OperationState.IN_PROGRESS, "bar")) .assertNext(serviceInstanceState -> { assertThat(serviceInstanceState.getOperationState()).isEqualTo(OperationState.IN_PROGRESS); assertThat(serviceInstanceState.getDescription()).isEqualTo("bar"); assertThat(serviceInstanceState.getLastUpdated()) .isInSameMinuteWindowAs(Calendar.getInstance().getTime()); }) .verifyComplete(); StepVerifier.create(stateRepository.removeState("foo-service", "foo-binding")) .assertNext(serviceInstanceState -> { assertThat(serviceInstanceState.getOperationState()).isEqualTo(OperationState.IN_PROGRESS); assertThat(serviceInstanceState.getDescription()).isEqualTo("bar"); assertThat(serviceInstanceState.getLastUpdated()) .isInSameMinuteWindowAs(Calendar.getInstance().getTime()); }) .verifyComplete(); StepVerifier.create(stateRepository.getState("foo-service", "foo-binding")) .expectError(IllegalArgumentException.class) .verify(); }
Example #9
Source File: ServiceInstanceBindingControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void lastOperationHasFailedStatus() { setupServiceInstanceBindingService(GetLastServiceBindingOperationResponse.builder() .operationState(OperationState.FAILED) .description("not so good") .build()); client.get().uri(buildLastOperationUrl()) .exchange() .expectStatus().isOk() .expectBody() .jsonPath("$.state").isEqualTo(OperationState.FAILED.toString()) .jsonPath("$.description").isEqualTo("not so good"); then(serviceInstanceBindingService) .should() .getLastOperation(any(GetLastServiceBindingOperationRequest.class)); GetLastServiceBindingOperationRequest actualRequest = verifyLastOperation(); assertHeaderValuesNotSet(actualRequest); }
Example #10
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 #11
Source File: InMemoryServiceInstanceStateRepositoryTest.java From spring-cloud-app-broker with Apache License 2.0 | 6 votes |
@Test void saveAndGet() { StepVerifier.create(stateRepository.saveState("foo", OperationState.IN_PROGRESS, "bar")) .assertNext(serviceInstanceState -> { assertThat(serviceInstanceState.getOperationState()).isEqualTo(OperationState.IN_PROGRESS); assertThat(serviceInstanceState.getDescription()).isEqualTo("bar"); assertThat(serviceInstanceState.getLastUpdated()) .isEqualToIgnoringSeconds(Calendar.getInstance().getTime()); }) .verifyComplete(); StepVerifier.create(stateRepository.getState("foo")) .assertNext(serviceInstanceState -> { assertThat(serviceInstanceState.getOperationState()).isEqualTo(OperationState.IN_PROGRESS); assertThat(serviceInstanceState.getDescription()).isEqualTo("bar"); assertThat(serviceInstanceState.getLastUpdated()) .isEqualToIgnoringSeconds(Calendar.getInstance().getTime()); }) .verifyComplete(); }
Example #12
Source File: WorkflowServiceInstanceService.java From spring-cloud-app-broker with Apache License 2.0 | 6 votes |
private Mono<Void> update(UpdateServiceInstanceRequest request, UpdateServiceInstanceResponse response) { return stateRepository.saveState(request.getServiceInstanceId(), OperationState.IN_PROGRESS, "update service instance started") .thenMany(invokeUpdateWorkflows(request, response) .doOnRequest(l -> { LOG.info("Updating service instance"); LOG.debug("request={}", request); }) .doOnComplete(() -> { LOG.info("Finish updating service instance"); LOG.debug("request={}, response={}", request, response); }) .doOnError(e -> LOG.error(String.format("Error updating service instance. error=%s", e.getMessage()), e))) .thenEmpty(stateRepository.saveState(request.getServiceInstanceId(), OperationState.SUCCEEDED, "update service instance completed") .then()) .onErrorResume(exception -> stateRepository.saveState(request.getServiceInstanceId(), OperationState.FAILED, exception.getMessage()) .then()); }
Example #13
Source File: ServiceInstanceControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void lastOperationHasSucceededStatusWithDeletionComplete() { setupServiceInstanceService(GetLastServiceOperationResponse.builder() .operationState(OperationState.SUCCEEDED) .description("all gone") .deleteOperation(true) .build()); client.get().uri(buildLastOperationUrl()) .exchange() .expectStatus().is4xxClientError() .expectStatus().isEqualTo(HttpStatus.GONE) .expectBody() .jsonPath("$.state").isEqualTo(OperationState.SUCCEEDED.toString()) .jsonPath("$.description").isEqualTo("all gone"); }
Example #14
Source File: WorkflowServiceInstanceService.java From spring-cloud-app-broker with Apache License 2.0 | 6 votes |
private Mono<Void> delete(DeleteServiceInstanceRequest request, DeleteServiceInstanceResponse response) { return stateRepository.saveState(request.getServiceInstanceId(), OperationState.IN_PROGRESS, "delete service instance started") .thenMany(invokeDeleteWorkflows(request, response) .doOnRequest(l -> { LOG.info("Deleting service instance"); LOG.debug("request={}", request); }) .doOnComplete(() -> { LOG.info("Finish deleting service instance"); LOG.debug("request={}, response={}", request, response); }) .doOnError(e -> LOG.error(String.format("Error deleting service instance. error=%s", e.getMessage()), e))) .thenEmpty(stateRepository.saveState(request.getServiceInstanceId(), OperationState.SUCCEEDED, "delete service instance completed") .then()) .onErrorResume(e -> stateRepository.saveState(request.getServiceInstanceId(), OperationState.FAILED, e.getMessage()) .then()); }
Example #15
Source File: ServiceInstanceBindingControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void lastOperationHasSucceededStatus() throws Exception { setupServiceInstanceBindingService(GetLastServiceBindingOperationResponse.builder() .operationState(OperationState.SUCCEEDED) .description("all good") .build()); client.get().uri(buildLastOperationUrl(PLATFORM_INSTANCE_ID)) .header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION) .header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()) .exchange() .expectStatus().isOk() .expectBody() .jsonPath("$.state").isEqualTo(OperationState.SUCCEEDED.toString()) .jsonPath("$.description", is("all good")); then(serviceInstanceBindingService) .should() .getLastOperation(any(GetLastServiceBindingOperationRequest.class)); GetLastServiceBindingOperationRequest actualRequest = verifyLastOperation(); assertHeaderValuesSet(actualRequest); }
Example #16
Source File: UpdateInstanceComponentTest.java From spring-cloud-app-broker with Apache License 2.0 | 6 votes |
@Test void updateAppsWhenTheyExist() { cloudControllerFixture.stubAppExists(APP_NAME_1); cloudControllerFixture.stubUpdateApp(APP_NAME_1); cloudControllerFixture.stubAppExists(APP_NAME_2); cloudControllerFixture.stubUpdateApp(APP_NAME_2); // when a service instance is created given(brokerFixture.serviceInstanceRequest()) .when() .patch(brokerFixture.createServiceInstanceUrl(), "instance-id") .then() .statusCode(HttpStatus.ACCEPTED.value()); // when the "last_operation" API is polled given(brokerFixture.serviceInstanceRequest()) .when() .get(brokerFixture.getLastInstanceOperationUrl(), "instance-id") .then() .statusCode(HttpStatus.OK.value()) .body("state", is(equalTo(OperationState.IN_PROGRESS.toString()))); String state = brokerFixture.waitForAsyncOperationComplete("instance-id"); assertThat(state).isEqualTo(OperationState.SUCCEEDED.toString()); }
Example #17
Source File: DeleteInstanceComponentTest.java From spring-cloud-app-broker with Apache License 2.0 | 6 votes |
@Test void deleteAppsWhenTheyDoNotExist() { cloudControllerFixture.stubAppDoesNotExist(APP_NAME_1); cloudControllerFixture.stubAppDoesNotExist(APP_NAME_2); // when the service instance is deleted given(brokerFixture.serviceInstanceRequest()) .when() .delete(brokerFixture.deleteServiceInstanceUrl(), "instance-id") .then() .statusCode(HttpStatus.ACCEPTED.value()); // when the "last_operation" API is polled given(brokerFixture.serviceInstanceRequest()) .when() .get(brokerFixture.getLastInstanceOperationUrl(), "instance-id") .then() .statusCode(HttpStatus.OK.value()) .body("state", is(equalTo(OperationState.IN_PROGRESS.toString()))); String state = brokerFixture.waitForAsyncOperationComplete("instance-id"); assertThat(state).isEqualTo(OperationState.SUCCEEDED.toString()); }
Example #18
Source File: ServiceInstanceBindingControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void lastOperationHasSucceededStatusWithDeletionComplete() throws Exception { setupServiceInstanceBindingService(GetLastServiceBindingOperationResponse.builder() .operationState(OperationState.SUCCEEDED) .description("all gone") .deleteOperation(true) .build()); MvcResult mvcResult = mockMvc.perform(get(buildLastOperationUrl())) .andExpect(request().asyncStarted()) .andExpect(status().isOk()) .andReturn(); mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isGone()) .andExpect(jsonPath("$.state", is(OperationState.SUCCEEDED.toString()))) .andExpect(jsonPath("$.description", is("all gone"))); }
Example #19
Source File: ServiceInstanceBindingControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void lastOperationHasInProgressStatus() throws Exception { setupServiceInstanceBindingService(GetLastServiceBindingOperationResponse.builder() .operationState(OperationState.IN_PROGRESS) .description("working on it") .build()); MvcResult mvcResult = mockMvc.perform(get(buildLastOperationUrl()) .contentType(MediaType.APPLICATION_JSON)) .andExpect(request().asyncStarted()) .andReturn(); mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isOk()) .andExpect(jsonPath("$.state", is(OperationState.IN_PROGRESS.toString()))) .andExpect(jsonPath("$.description", is("working on it"))); GetLastServiceBindingOperationRequest actualRequest = verifyLastOperation(); assertHeaderValuesNotSet(actualRequest); }
Example #20
Source File: LastOperationSerializer.java From ecs-cf-service-broker with Apache License 2.0 | 6 votes |
@Override public OperationState deserialize(JsonParser jp, DeserializationContext deserializationContext) throws IOException, JsonProcessingException { JsonNode node = jp.getCodec().readTree(jp); String inValue = node.textValue(); try { return OperationState.valueOf(inValue); } catch (IllegalArgumentException e) { if (inValue != null) { for (OperationState value : OperationState.values()) { if (inValue.equals(value.getValue())) { return value; } } } } return null; }
Example #21
Source File: ServiceInstanceControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void lastOperationHasSucceededStatus() throws Exception { setupServiceInstanceService(GetLastServiceOperationResponse.builder() .operationState(OperationState.SUCCEEDED) .description("all good") .build()); client.get().uri(buildLastOperationUrl(PLATFORM_INSTANCE_ID)) .header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION) .header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()) .exchange() .expectStatus().isOk() .expectBody() .jsonPath("$.state").isEqualTo(OperationState.SUCCEEDED.toString()) .jsonPath("$.description").isEqualTo("all good"); GetLastServiceOperationRequest actualRequest = verifyLastOperation(); assertHeaderValuesSet(actualRequest); }
Example #22
Source File: ExampleServiceInstanceBindingStateRepository.java From spring-cloud-app-broker with Apache License 2.0 | 6 votes |
@Override public Mono<ServiceInstanceState> saveState(String serviceInstanceId, String bindingId, OperationState state, String description) { return serviceInstanceBindingStateCrudRepository .findByServiceInstanceIdAndBindingId(serviceInstanceId, bindingId) .switchIfEmpty(Mono.just(new ServiceInstanceBinding())) .flatMap(binding -> { binding.setServiceInstanceId(serviceInstanceId); binding.setBindingId(bindingId); binding.setOperationState(state); binding.setDescription(description); return Mono.just(binding); }) .flatMap(serviceInstanceBindingStateCrudRepository::save) .map(ExampleServiceInstanceBindingStateRepository::toServiceInstanceState); }
Example #23
Source File: ServiceInstanceControllerIntegrationTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 6 votes |
@Test void lastOperationHasSucceededStatusWithDeletionComplete() throws Exception { setupServiceInstanceService(GetLastServiceOperationResponse.builder() .operationState(OperationState.SUCCEEDED) .description("all gone") .deleteOperation(true) .build()); MvcResult mvcResult = mockMvc.perform(get(buildLastOperationUrl())) .andExpect(request().asyncStarted()) .andReturn(); mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isGone()) .andExpect(jsonPath("$.state", is(OperationState.SUCCEEDED.toString()))) .andExpect(jsonPath("$.description", is("all gone"))); }
Example #24
Source File: ServiceInstanceController.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
/** * REST controller for getting the last operation of a service instance * * @param pathVariables the path variables * @param serviceInstanceId the service instance ID * @param serviceDefinitionId the service definition ID * @param planId the plan ID * @param operation description of the operation being performed * @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 + "/last_operation", PATH_MAPPING + "/last_operation"}) public Mono<ResponseEntity<GetLastServiceOperationResponse>> getServiceInstanceLastOperation( @PathVariable Map<String, String> pathVariables, @PathVariable(ServiceBrokerRequest.INSTANCE_ID_PATH_VARIABLE) String serviceInstanceId, @RequestParam(value = ServiceBrokerRequest.SERVICE_ID_PARAMETER, required = false) String serviceDefinitionId, @RequestParam(value = ServiceBrokerRequest.PLAN_ID_PARAMETER, required = false) String planId, @RequestParam(value = "operation", required = false) String operation, @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(GetLastServiceOperationRequest.builder() .serviceDefinitionId(serviceDefinitionId) .serviceInstanceId(serviceInstanceId) .planId(planId) .operation(operation) .platformInstanceId(pathVariables.get(ServiceBrokerRequest.PLATFORM_INSTANCE_ID_VARIABLE)) .apiInfoLocation(apiInfoLocation) .originatingIdentity(parseOriginatingIdentity(originatingIdentityString)) .requestIdentity(requestIdentity) .build()) .flatMap(request -> service.getLastOperation(request) .doOnRequest(v -> { LOG.info("Getting service instance last operation"); LOG.debug(DEBUG_REQUEST, request); }) .doOnSuccess(response -> { LOG.info("Getting service instance last operation succeeded"); LOG.debug(DEBUG_RESPONSE, serviceInstanceId, response); }) .doOnError(e -> LOG.error("Error getting service instance last operation. error=" + e.getMessage(), e))) .map(response -> { boolean isSuccessfulDelete = response.getState().equals(OperationState.SUCCEEDED) && response .isDeleteOperation(); return new ResponseEntity<>(response, isSuccessfulDelete ? HttpStatus.GONE : HttpStatus.OK); }); }
Example #25
Source File: ServiceInstanceControllerResponseCodeTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Test void getLastOperationWithDeleteSucceededResponseGivesExpectedStatus() { validateGetLastOperationWithResponseStatus(GetLastServiceOperationResponse.builder() .operationState(OperationState.SUCCEEDED) .deleteOperation(true) .build(), HttpStatus.GONE); }
Example #26
Source File: WorkflowServiceInstanceServiceTest.java From spring-cloud-app-broker with Apache License 2.0 | 5 votes |
@Test void updateServiceInstanceWithNoAcceptsDoesNothing() { given(serviceInstanceStateRepository.saveState(anyString(), any(OperationState.class), anyString())) .willReturn( Mono.just( new ServiceInstanceState(OperationState.IN_PROGRESS, "update service instance started", new Timestamp(Instant.now().minusSeconds(60).toEpochMilli())))) .willReturn( Mono.just( new ServiceInstanceState(OperationState.SUCCEEDED, "update service instance completed", new Timestamp(Instant.now().minusSeconds(30).toEpochMilli())))); UpdateServiceInstanceRequest request = UpdateServiceInstanceRequest.builder() .serviceInstanceId("foo") .build(); given(updateServiceInstanceWorkflow1.accept(request)) .willReturn(Mono.just(false)); given(updateServiceInstanceWorkflow2.accept(request)) .willReturn(Mono.just(false)); StepVerifier.create(workflowServiceInstanceService.updateServiceInstance(request)) .assertNext(response -> { InOrder repoOrder = inOrder(serviceInstanceStateRepository); repoOrder.verify(serviceInstanceStateRepository) .saveState(eq("foo"), eq(OperationState.IN_PROGRESS), eq("update service instance started")); repoOrder.verify(serviceInstanceStateRepository) .saveState(eq("foo"), eq(OperationState.SUCCEEDED), eq("update service instance completed")); repoOrder.verifyNoMoreInteractions(); then(updateServiceInstanceWorkflow1).shouldHaveNoMoreInteractions(); then(updateServiceInstanceWorkflow2).shouldHaveNoMoreInteractions(); assertThat(response).isNotNull(); }) .verifyComplete(); }
Example #27
Source File: ExampleServiceInstanceStateRepository.java From spring-cloud-app-broker with Apache License 2.0 | 5 votes |
@Override public Mono<ServiceInstanceState> saveState(String serviceInstanceId, OperationState state, String description) { return serviceInstanceStateCrudRepository.findByServiceInstanceId(serviceInstanceId) .switchIfEmpty(Mono.just(new ServiceInstance())) .flatMap(serviceInstance -> { serviceInstance.setServiceInstanceId(serviceInstanceId); serviceInstance.setOperationState(state); serviceInstance.setDescription(description); return Mono.just(serviceInstance); }) .flatMap(serviceInstanceStateCrudRepository::save) .map(ExampleServiceInstanceStateRepository::toServiceInstanceState); }
Example #28
Source File: ServiceInstanceControllerResponseCodeTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Test void getLastOperationWithInProgressResponseGivesExpectedStatus() { validateGetLastOperationWithResponseStatus(GetLastServiceOperationResponse.builder() .operationState(OperationState.IN_PROGRESS) .description("in progress") .build(), HttpStatus.OK); }
Example #29
Source File: ServiceInstanceControllerResponseCodeTest.java From spring-cloud-open-service-broker with Apache License 2.0 | 5 votes |
@Test void getLastOperationWithSucceededResponseGivesExpectedStatus() { validateGetLastOperationWithResponseStatus(GetLastServiceOperationResponse.builder() .operationState(OperationState.SUCCEEDED) .deleteOperation(false) .build(), HttpStatus.OK); }
Example #30
Source File: WorkflowServiceInstanceBindingServiceTest.java From spring-cloud-app-broker with Apache License 2.0 | 5 votes |
@Test void deleteServiceInstanceBindingWithNoAcceptsDoesNothing() { given(stateRepository.saveState(anyString(), anyString(), any(OperationState.class), anyString())) .willReturn(Mono.just( new ServiceInstanceState(OperationState.IN_PROGRESS, "delete service instance binding started", new Timestamp(Instant.now().minusSeconds(60).toEpochMilli())))) .willReturn(Mono.just( new ServiceInstanceState(OperationState.SUCCEEDED, "delete service instance binding completed", new Timestamp(Instant.now().minusSeconds(30).toEpochMilli())))); DeleteServiceInstanceBindingRequest request = DeleteServiceInstanceBindingRequest.builder() .serviceInstanceId("foo-service") .bindingId("foo-binding") .build(); given(deleteServiceInstanceBindingWorkflow1.accept(request)) .willReturn(Mono.just(false)); given(deleteServiceInstanceBindingWorkflow2.accept(request)) .willReturn(Mono.just(false)); StepVerifier.create(workflowServiceInstanceBindingService.deleteServiceInstanceBinding(request)) .assertNext(response -> { InOrder repoOrder = inOrder(stateRepository); repoOrder.verify(stateRepository) .saveState(eq("foo-service"), eq("foo-binding"), eq(OperationState.IN_PROGRESS), eq("delete service instance binding started")); repoOrder.verify(stateRepository) .saveState(eq("foo-service"), eq("foo-binding"), eq(OperationState.SUCCEEDED), eq("delete service instance binding completed")); repoOrder.verifyNoMoreInteractions(); then(deleteServiceInstanceBindingWorkflow1).shouldHaveNoMoreInteractions(); then(deleteServiceInstanceBindingWorkflow2).shouldHaveNoMoreInteractions(); assertThat(response).isNotNull(); }) .verifyComplete(); }