org.springframework.cloud.servicebroker.model.instance.CreateServiceInstanceResponse Java Examples

The following examples show how to use org.springframework.cloud.servicebroker.model.instance.CreateServiceInstanceResponse. 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: ServiceInstanceControllerIntegrationTest.java    From spring-cloud-open-service-broker with Apache License 2.0 6 votes vote down vote up
@Test
void createServiceInstanceResponseShouldNotContainEmptyValuesWhenEmpty() {
	setupCatalogService();

	setupServiceInstanceService(CreateServiceInstanceResponse.builder()
			.operation("")
			.dashboardUrl("")
			.build());

	client.put().uri(buildCreateUpdateUrl())
			.contentType(MediaType.APPLICATION_JSON)
			.bodyValue(createRequestBody)
			.accept(MediaType.APPLICATION_JSON)
			.exchange()
			.expectStatus().isCreated()
			.expectBody()
			.jsonPath("$.dashboard_url").doesNotExist()
			.jsonPath("$.operation").doesNotExist();
}
 
Example #2
Source File: MailServiceInstanceService.java    From tutorials with MIT License 6 votes vote down vote up
@Override
public Mono<CreateServiceInstanceResponse> createServiceInstance(CreateServiceInstanceRequest request) {
    return Mono.just(request.getServiceInstanceId())
        .flatMap(instanceId -> Mono.just(CreateServiceInstanceResponse.builder())
            .flatMap(responseBuilder -> mailService.serviceInstanceExists(instanceId)
                .flatMap(exists -> {
                    if (exists) {
                        return mailService.getServiceInstance(instanceId)
                            .flatMap(mailServiceInstance -> Mono.just(responseBuilder
                                .instanceExisted(true)
                                .dashboardUrl(mailServiceInstance.getDashboardUrl())
                                .build()));
                    } else {
                        return mailService.createServiceInstance(
                            instanceId, request.getServiceDefinitionId(), request.getPlanId())
                            .flatMap(mailServiceInstance -> Mono.just(responseBuilder
                                .instanceExisted(false)
                                .dashboardUrl(mailServiceInstance.getDashboardUrl())
                                .build()));
                    }
                })));
}
 
Example #3
Source File: ServiceInstanceEventServiceTest.java    From spring-cloud-open-service-broker with Apache License 2.0 6 votes vote down vote up
@Test
void createServiceInstanceSucceeds() {
	prepareCreateEventFlows();

	StepVerifier
			.create(serviceInstanceEventService.createServiceInstance(
					CreateServiceInstanceRequest.builder()
							.serviceInstanceId("service-instance-id")
							.serviceDefinitionId("service-def-id")
							.build()))
			.expectNext(CreateServiceInstanceResponse.builder().build())
			.verifyComplete();

	assertThat(this.results.getBeforeCreate()).isEqualTo("before service-instance-id");
	assertThat(this.results.getAfterCreate()).isEqualTo("after service-instance-id");
	assertThat(this.results.getErrorCreate()).isNullOrEmpty();
}
 
Example #4
Source File: ExampleServiceInstanceService.java    From spring-cloud-open-service-broker with Apache License 2.0 6 votes vote down vote up
@Override
public Mono<CreateServiceInstanceResponse> createServiceInstance(CreateServiceInstanceRequest request) {
	String serviceInstanceId = request.getServiceInstanceId();
	String planId = request.getPlanId();
	Map<String, Object> parameters = request.getParameters();

	//
	// perform the steps necessary to initiate the asynchronous
	// provisioning of all necessary resources
	//

	String dashboardUrl = ""; /* construct a dashboard URL */

	return Mono.just(CreateServiceInstanceResponse.builder()
			.dashboardUrl(dashboardUrl)
			.async(true)
			.build());
}
 
Example #5
Source File: TestServiceInstanceService.java    From spring-cloud-open-service-broker with Apache License 2.0 6 votes vote down vote up
@Override
public Mono<CreateServiceInstanceResponse> createServiceInstance(CreateServiceInstanceRequest 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(CreateServiceInstanceResponse.builder()
				.instanceExisted(true)
				.build());
	}
	if (request.isAsyncAccepted()) {
		return Mono.just(CreateServiceInstanceResponse.builder()
				.async(true)
				.operation("working")
				.build());
	}
	else {
		return Mono.just(CreateServiceInstanceResponse.builder()
				.build());
	}
}
 
Example #6
Source File: ServiceInstanceControllerIntegrationTest.java    From spring-cloud-open-service-broker with Apache License 2.0 6 votes vote down vote up
@Test
void createServiceInstanceFiltersPlanSucceeds() {
	setupCatalogService();

	setupServiceInstanceService(CreateServiceInstanceResponse
			.builder()
			.build());

	client.put().uri(buildCreateUpdateUrl())
			.contentType(MediaType.APPLICATION_JSON)
			.bodyValue(createRequestBody)
			.accept(MediaType.APPLICATION_JSON)
			.exchange()
			.expectStatus().isCreated();

	CreateServiceInstanceRequest actualRequest = verifyCreateServiceInstance();
	assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false);
	assertThat(actualRequest.getPlan().getId()).isEqualTo("plan-one-id");
	assertHeaderValuesNotSet(actualRequest);
}
 
Example #7
Source File: ServiceInstanceControllerIntegrationTest.java    From spring-cloud-open-service-broker with Apache License 2.0 6 votes vote down vote up
@Test
void createServiceInstanceWithoutAsyncAndHeadersSucceeds() {
	setupCatalogService();

	setupServiceInstanceService(CreateServiceInstanceResponse.builder()
			.build());

	client.put().uri(buildCreateUpdateUrl())
			.contentType(MediaType.APPLICATION_JSON)
			.bodyValue(createRequestBody)
			.accept(MediaType.APPLICATION_JSON)
			.exchange()
			.expectStatus().isCreated();

	CreateServiceInstanceRequest actualRequest = verifyCreateServiceInstance();
	assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false);
	assertHeaderValuesNotSet(actualRequest);
}
 
Example #8
Source File: ServiceInstanceControllerIntegrationTest.java    From spring-cloud-open-service-broker with Apache License 2.0 6 votes vote down vote up
@Test
void createServiceInstanceWithEmptyPlatformInstanceIdSucceeds() {
	setupCatalogService();

	setupServiceInstanceService(CreateServiceInstanceResponse.builder()
			.async(true)
			.build());

	// force a condition where the platformInstanceId segment is present but empty
	// e.g. https://test.app.local//v2/service_instances/[guid]
	String url = "https://test.app.local/" + buildCreateUpdateUrl();
	client.put().uri(url)
			.contentType(MediaType.APPLICATION_JSON)
			.bodyValue(createRequestBody)
			.accept(MediaType.APPLICATION_JSON)
			.exchange()
			.expectStatus().isAccepted();

	CreateServiceInstanceRequest actualRequest = verifyCreateServiceInstance();
	assertHeaderValuesNotSet(actualRequest);
}
 
Example #9
Source File: ServiceInstanceControllerIntegrationTest.java    From spring-cloud-open-service-broker with Apache License 2.0 6 votes vote down vote up
@Test
void createServiceInstanceResponseShouldNotContainEmptyValuesWhenNull() {
	setupCatalogService();

	setupServiceInstanceService(CreateServiceInstanceResponse.builder()
			.operation(null)
			.dashboardUrl(null)
			.build());

	client.put().uri(buildCreateUpdateUrl())
			.contentType(MediaType.APPLICATION_JSON)
			.bodyValue(createRequestBody)
			.accept(MediaType.APPLICATION_JSON)
			.exchange()
			.expectStatus().isCreated()
			.expectBody()
			.jsonPath("$.dashboard_url").doesNotExist()
			.jsonPath("$.operation").doesNotExist();
}
 
Example #10
Source File: ServiceInstanceControllerIntegrationTest.java    From spring-cloud-open-service-broker with Apache License 2.0 6 votes vote down vote up
@Test
void createServiceInstanceWithAsyncAndHeadersSucceeds() throws Exception {
	setupCatalogService();

	setupServiceInstanceService(CreateServiceInstanceResponse.builder()
			.async(true)
			.build());

	client.put().uri(buildCreateUpdateUrl(PLATFORM_INSTANCE_ID, true))
			.contentType(MediaType.APPLICATION_JSON)
			.bodyValue(createRequestBody)
			.header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION)
			.header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader())
			.accept(MediaType.APPLICATION_JSON)
			.exchange()
			.expectStatus().isAccepted();

	CreateServiceInstanceRequest actualRequest = verifyCreateServiceInstance();
	assertThat(actualRequest.isAsyncAccepted()).isEqualTo(true);
	assertHeaderValuesSet(actualRequest);
}
 
Example #11
Source File: ServiceInstanceControllerIntegrationTest.java    From spring-cloud-open-service-broker with Apache License 2.0 6 votes vote down vote up
@Test
void createServiceInstanceFiltersPlansSucceeds() throws Exception {
	setupCatalogService();

	setupServiceInstanceService(CreateServiceInstanceResponse
			.builder()
			.build());

	MvcResult mvcResult = mockMvc
			.perform(put(buildCreateUpdateUrl())
					.content(createRequestBody)
					.contentType(MediaType.APPLICATION_JSON)
					.accept(MediaType.APPLICATION_JSON))
			.andExpect(request().asyncStarted())
			.andReturn();

	mockMvc.perform(asyncDispatch(mvcResult))
			.andExpect(status().isCreated());

	CreateServiceInstanceRequest actualRequest = verifyCreateServiceInstance();
	assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false);
	assertThat(actualRequest.getPlan().getId()).isEqualTo(actualRequest.getPlanId());
	assertHeaderValuesNotSet(actualRequest);
}
 
Example #12
Source File: ServiceInstanceControllerIntegrationTest.java    From spring-cloud-open-service-broker with Apache License 2.0 6 votes vote down vote up
@Test
void createServiceInstanceWithExistingInstanceSucceeds() throws Exception {
	setupCatalogService();

	setupServiceInstanceService(CreateServiceInstanceResponse.builder()
			.instanceExisted(true)
			.build());

	MvcResult mvcResult = mockMvc.perform(put(buildCreateUpdateUrl())
			.content(createRequestBody)
			.contentType(MediaType.APPLICATION_JSON)
			.accept(MediaType.APPLICATION_JSON))
			.andExpect(request().asyncStarted())
			.andReturn();

	mockMvc.perform(asyncDispatch(mvcResult))
			.andExpect(status().isOk());
}
 
Example #13
Source File: ServiceInstanceControllerIntegrationTest.java    From spring-cloud-open-service-broker with Apache License 2.0 6 votes vote down vote up
@Test
void createServiceInstanceWithoutAsyncAndHeadersSucceeds() throws Exception {
	setupCatalogService();

	setupServiceInstanceService(CreateServiceInstanceResponse.builder()
			.build());

	MvcResult mvcResult = mockMvc.perform(put(buildCreateUpdateUrl())
			.content(createRequestBody)
			.contentType(MediaType.APPLICATION_JSON)
			.accept(MediaType.APPLICATION_JSON))
			.andExpect(request().asyncStarted())
			.andReturn();

	mockMvc.perform(asyncDispatch(mvcResult))
			.andExpect(status().isCreated());

	CreateServiceInstanceRequest actualRequest = verifyCreateServiceInstance();
	assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false);
	assertHeaderValuesNotSet(actualRequest);
}
 
Example #14
Source File: ServiceInstanceControllerIntegrationTest.java    From spring-cloud-open-service-broker with Apache License 2.0 6 votes vote down vote up
@Test
void createServiceInstanceWithEmptyPlatformInstanceIdSucceeds() throws Exception {
	setupCatalogService();

	setupServiceInstanceService(CreateServiceInstanceResponse.builder()
			.async(true)
			.build());

	// force a condition where the platformInstanceId segment is present but empty
	// e.g. https://test.app.local//v2/service_instances/[guid]
	String url = "https://test.app.local/" + buildCreateUpdateUrl();
	MvcResult mvcResult = mockMvc.perform(put(url)
			.content(createRequestBody)
			.contentType(MediaType.APPLICATION_JSON)
			.accept(MediaType.APPLICATION_JSON))
			.andExpect(request().asyncStarted())
			.andReturn();

	mockMvc.perform(asyncDispatch(mvcResult))
			.andExpect(status().isAccepted());

	CreateServiceInstanceRequest actualRequest = verifyCreateServiceInstance();
	assertHeaderValuesNotSet(actualRequest);
}
 
Example #15
Source File: ServiceInstanceControllerIntegrationTest.java    From spring-cloud-open-service-broker with Apache License 2.0 6 votes vote down vote up
@Test
void createServiceInstanceResponseShouldNotContainEmptyValuesWhenEmpty() throws Exception {
	setupCatalogService();

	setupServiceInstanceService(CreateServiceInstanceResponse.builder()
			.operation("")
			.dashboardUrl("")
			.build());

	MvcResult mvcResult = mockMvc.perform(put(buildCreateUpdateUrl())
			.content(createRequestBody)
			.contentType(MediaType.APPLICATION_JSON)
			.accept(MediaType.APPLICATION_JSON))
			.andExpect(request().asyncStarted())
			.andReturn();

	mockMvc.perform(asyncDispatch(mvcResult))
			.andExpect(status().isCreated())
			.andExpect(jsonPath("$.dashboard_url").doesNotExist())
			.andExpect(jsonPath("$.operation").doesNotExist());
}
 
Example #16
Source File: ServiceInstanceControllerIntegrationTest.java    From spring-cloud-open-service-broker with Apache License 2.0 6 votes vote down vote up
@Test
void createServiceInstanceResponseShouldNotContainEmptyValuesWhenNull() throws Exception {
	setupCatalogService();

	setupServiceInstanceService(CreateServiceInstanceResponse.builder()
			.operation(null)
			.dashboardUrl(null)
			.build());

	MvcResult mvcResult = mockMvc.perform(put(buildCreateUpdateUrl())
			.content(createRequestBody)
			.contentType(MediaType.APPLICATION_JSON)
			.accept(MediaType.APPLICATION_JSON))
			.andExpect(request().asyncStarted())
			.andReturn();

	mockMvc.perform(asyncDispatch(mvcResult))
			.andExpect(status().isCreated())
			.andExpect(jsonPath("$.dashboard_url").doesNotExist())
			.andExpect(jsonPath("$.operation").doesNotExist());
}
 
Example #17
Source File: ServiceInstanceControllerIntegrationTest.java    From spring-cloud-open-service-broker with Apache License 2.0 6 votes vote down vote up
@Test
void createServiceInstanceWithAsyncAndHeadersSucceeds() throws Exception {
	setupCatalogService();

	setupServiceInstanceService(CreateServiceInstanceResponse.builder()
			.async(true)
			.build());

	MvcResult mvcResult = mockMvc.perform(put(buildCreateUpdateUrl(PLATFORM_INSTANCE_ID, true))
			.content(createRequestBody)
			.contentType(MediaType.APPLICATION_JSON)
			.header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION)
			.header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader())
			.accept(MediaType.APPLICATION_JSON))
			.andExpect(request().asyncStarted())
			.andReturn();

	mockMvc.perform(asyncDispatch(mvcResult))
			.andExpect(status().isAccepted());

	CreateServiceInstanceRequest actualRequest = verifyCreateServiceInstance();
	assertThat(actualRequest.isAsyncAccepted()).isEqualTo(true);
	assertHeaderValuesSet(actualRequest);
}
 
Example #18
Source File: AppDeploymentCreateServiceInstanceWorkflowTest.java    From spring-cloud-app-broker with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings({"unchecked", "UnassignedFluxMonoInstance"})
void createServiceInstanceSucceeds() {
	CreateServiceInstanceRequest request = buildRequest("service1", "plan1");
	CreateServiceInstanceResponse response = CreateServiceInstanceResponse.builder().build();

	setupMocks(request);

	StepVerifier
		.create(createServiceInstanceWorkflow.create(request, response))
		.expectNext()
		.expectNext()
		.verifyComplete();

	verify(appDeploymentService).deploy(backingApps, request.getServiceInstanceId());
	verify(servicesProvisionService).createServiceInstance(backingServices);

	final String expectedServiceId = "service-instance-id";
	verify(targetService).addToBackingServices(backingServices, targetSpec, expectedServiceId);
	verify(targetService).addToBackingApplications(backingApps, targetSpec, expectedServiceId);

	verifyNoMoreInteractionsWithServices();
}
 
Example #19
Source File: WorkflowServiceInstanceService.java    From spring-cloud-app-broker with Apache License 2.0 6 votes vote down vote up
private Mono<Void> create(CreateServiceInstanceRequest request, CreateServiceInstanceResponse response) {
	return stateRepository.saveState(request.getServiceInstanceId(),
		OperationState.IN_PROGRESS,
		"create service instance started")
		.thenMany(invokeCreateWorkflows(request, response)
			.doOnRequest(l -> {
				LOG.info("Creating service instance");
				LOG.debug("request={}", request);
			})
			.doOnComplete(() -> {
				LOG.info("Finish creating service instance");
				LOG.debug("request={}, response={}", request, response);
			})
			.doOnError(e -> LOG.error(String.format("Error creating service instance. error=%s",
				e.getMessage()), e)))
		.thenEmpty(stateRepository.saveState(request.getServiceInstanceId(),
			OperationState.SUCCEEDED, "create service instance completed")
			.then())
		.onErrorResume(exception -> stateRepository.saveState(request.getServiceInstanceId(),
			OperationState.FAILED, exception.getMessage())
			.then());
}
 
Example #20
Source File: BookStoreServiceInstanceService.java    From bookstore-service-broker with Apache License 2.0 6 votes vote down vote up
@Override
public Mono<CreateServiceInstanceResponse> createServiceInstance(CreateServiceInstanceRequest request) {
	return Mono.just(request.getServiceInstanceId())
			.flatMap(instanceId -> Mono.just(CreateServiceInstanceResponse.builder())
					.flatMap(responseBuilder -> instanceRepository.existsById(instanceId)
							.flatMap(exists -> {
								if (exists) {
									return Mono.just(responseBuilder.instanceExisted(true)
											.build());
								}
								else {
									return storeService.createBookStore(instanceId)
											.then(instanceRepository.save(new ServiceInstance(instanceId,
													request.getServiceDefinitionId(),
													request.getPlanId(), request.getParameters())))
											.thenReturn(responseBuilder.build());
								}
							})));
}
 
Example #21
Source File: ServiceInstanceControllerIntegrationTest.java    From spring-cloud-open-service-broker with Apache License 2.0 5 votes vote down vote up
@Test
void createServiceInstanceWithAsyncOperationAndHeadersSucceeds() throws Exception {
	setupCatalogService();

	// alternatively throw a ServiceBrokerCreateOperationInProgressException when a request is received for
	// an operation in progress. See test: createServiceInstanceWithAsyncAndHeadersOperationInProgress
	setupServiceInstanceService(CreateServiceInstanceResponse.builder()
			.async(true)
			.operation("task_10")
			.dashboardUrl("https://dashboard.app.local")
			.build());

	MvcResult mvcResult = mockMvc.perform(put(buildCreateUpdateUrl(PLATFORM_INSTANCE_ID, true))
			.content(createRequestBody)
			.contentType(MediaType.APPLICATION_JSON)
			.header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION)
			.header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader())
			.accept(MediaType.APPLICATION_JSON))
			.andExpect(request().asyncStarted())
			.andExpect(status().isOk())
			.andReturn();

	mockMvc.perform(asyncDispatch(mvcResult))
			.andExpect(status().isAccepted())
			.andExpect(jsonPath("$.operation", is("task_10")))
			.andExpect(jsonPath("$.dashboard_url", is("https://dashboard.app.local")));

	CreateServiceInstanceRequest actualRequest = verifyCreateServiceInstance();
	assertThat(actualRequest.isAsyncAccepted()).isEqualTo(true);
	assertHeaderValuesSet(actualRequest);
}
 
Example #22
Source File: ServiceInstanceEventServiceTest.java    From spring-cloud-open-service-broker with Apache License 2.0 5 votes vote down vote up
@Override
public Mono<CreateServiceInstanceResponse> createServiceInstance(
		CreateServiceInstanceRequest request) {
	if (request.getServiceDefinitionId() == null) {
		return Mono.error(new ServiceBrokerInvalidParametersException("arrrr"));
	}
	return Mono.just(CreateServiceInstanceResponse.builder().build());
}
 
Example #23
Source File: AsyncServiceBrokerResponseTest.java    From spring-cloud-open-service-broker with Apache License 2.0 5 votes vote down vote up
@Test
void equalsAndHashCode() {
	EqualsVerifier
			.forClass(AsyncServiceBrokerResponse.class)
			.withRedefinedSubclass(CreateServiceInstanceResponse.class)
			.withRedefinedSubclass(UpdateServiceInstanceResponse.class)
			.withRedefinedSubclass(CreateServiceInstanceBindingResponse.class)
			.withRedefinedSubclass(DeleteServiceInstanceBindingResponse.class)
			.verify();
}
 
Example #24
Source File: ServiceInstanceControllerResponseCodeTest.java    From spring-cloud-open-service-broker with Apache License 2.0 5 votes vote down vote up
private void validateCreateServiceInstanceWithResponseStatus(CreateServiceInstanceResponse response,
		HttpStatus expectedStatus) {
	Mono<CreateServiceInstanceResponse> responseMono;
	if (response == null) {
		responseMono = Mono.empty();
	}
	else {
		responseMono = Mono.just(response);
	}
	given(serviceInstanceService.createServiceInstance(any(CreateServiceInstanceRequest.class)))
			.willReturn(responseMono);

	CreateServiceInstanceRequest createRequest = CreateServiceInstanceRequest.builder()
			.serviceDefinitionId("service-definition-id")
			.planId("service-definition-plan-id")
			.build();

	ResponseEntity<CreateServiceInstanceResponse> responseEntity = controller
			.createServiceInstance(pathVariables, null, false, null, null, null,
					createRequest)
			.block();

	then(serviceInstanceService)
			.should()
			.createServiceInstance(any(CreateServiceInstanceRequest.class));
	assertThat(responseEntity).isNotNull();
	assertThat(responseEntity.getStatusCode()).isEqualTo(expectedStatus);
	assertThat(responseEntity.getBody()).isEqualTo(response);
}
 
Example #25
Source File: WorkflowServiceInstanceService.java    From spring-cloud-app-broker with Apache License 2.0 5 votes vote down vote up
private Mono<CreateServiceInstanceResponse> invokeCreateResponseBuilders(CreateServiceInstanceRequest request) {
	AtomicReference<CreateServiceInstanceResponseBuilder> responseBuilder =
		new AtomicReference<>(CreateServiceInstanceResponse.builder());

	return Flux.fromIterable(createServiceInstanceWorkflows)
		.filterWhen(workflow -> workflow.accept(request))
		.flatMap(workflow -> workflow.buildResponse(request, responseBuilder.get())
			.doOnNext(responseBuilder::set))
		.last(responseBuilder.get())
		.map(CreateServiceInstanceResponseBuilder::build);
}
 
Example #26
Source File: ServiceInstanceControllerResponseCodeTest.java    From spring-cloud-open-service-broker with Apache License 2.0 5 votes vote down vote up
@Test
void createServiceInstanceWithResponseAsyncInstanceExistGivesExpectedStatus() {
	validateCreateServiceInstanceWithResponseStatus(CreateServiceInstanceResponse.builder()
			.async(true)
			.instanceExisted(true)
			.build(), HttpStatus.ACCEPTED);
}
 
Example #27
Source File: ServiceInstanceControllerResponseCodeTest.java    From spring-cloud-open-service-broker with Apache License 2.0 5 votes vote down vote up
@Test
void createServiceInstanceWithAsyncResponseGivesExpectedStatus() {
	validateCreateServiceInstanceWithResponseStatus(CreateServiceInstanceResponse.builder()
			.async(true)
			.instanceExisted(false)
			.operation("creating")
			.build(), HttpStatus.ACCEPTED);
}
 
Example #28
Source File: ServiceInstanceControllerResponseCodeTest.java    From spring-cloud-open-service-broker with Apache License 2.0 5 votes vote down vote up
@Test
void createServiceInstanceWithInstanceExistResponseGivesExpectedStatus() {
	validateCreateServiceInstanceWithResponseStatus(CreateServiceInstanceResponse.builder()
			.async(false)
			.instanceExisted(true)
			.build(), HttpStatus.OK);
}
 
Example #29
Source File: ServiceInstanceControllerResponseCodeTest.java    From spring-cloud-open-service-broker with Apache License 2.0 5 votes vote down vote up
@Test
void createServiceInstanceWithResponseGivesExpectedStatus() {
	validateCreateServiceInstanceWithResponseStatus(CreateServiceInstanceResponse.builder()
			.async(false)
			.instanceExisted(false)
			.dashboardUrl("https://dashboard.app.local")
			.build(), HttpStatus.CREATED);
}
 
Example #30
Source File: ServiceInstanceEventService.java    From spring-cloud-open-service-broker with Apache License 2.0 5 votes vote down vote up
@Override
public Mono<CreateServiceInstanceResponse> createServiceInstance(CreateServiceInstanceRequest request) {
	return flows.getCreateInstanceRegistry().getInitializationFlows(request)
			.then(service.createServiceInstance(request))
			.onErrorResume(e -> flows.getCreateInstanceRegistry().getErrorFlows(request, e)
					.then(Mono.error(e)))
			.flatMap(response -> flows.getCreateInstanceRegistry().getCompletionFlows(request, response)
					.then(Mono.just(response)));
}