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

The following examples show how to use org.springframework.cloud.servicebroker.model.instance.CreateServiceInstanceRequest. 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 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 #2
Source File: AbstractServiceInstanceControllerIntegrationTest.java    From spring-cloud-open-service-broker with Apache License 2.0 6 votes vote down vote up
@BeforeEach
public void setUpCommonFixtures() {
	this.createRequestBody = JsonUtils.toJson(CreateServiceInstanceRequest.builder()
			.serviceDefinitionId(serviceDefinition.getId())
			.planId("plan-one-id")
			.build());

	this.updateRequestBody = JsonUtils.toJson(UpdateServiceInstanceRequest.builder()
			.serviceDefinitionId(serviceDefinition.getId())
			.build());

	this.updateRequestBodyWithPlan = JsonUtils.toJson(UpdateServiceInstanceRequest.builder()
			.serviceDefinitionId(serviceDefinition.getId())
			.planId("plan-three-id")
			.build());
}
 
Example #3
Source File: ServiceInstanceControllerRequestTest.java    From spring-cloud-open-service-broker with Apache License 2.0 6 votes vote down vote up
@Test
void createServiceInstanceParametersAreMappedToRequest() {
	CreateServiceInstanceRequest parsedRequest = buildCreateRequest().build();

	CreateServiceInstanceRequest expectedRequest = buildCreateRequest()
			.asyncAccepted(true)
			.serviceInstanceId("service-instance-id")
			.platformInstanceId("platform-instance-id")
			.apiInfoLocation("api-info-location")
			.originatingIdentity(identityContext)
			.requestIdentity("request-id")
			.serviceDefinition(serviceDefinition)
			.plan(plan)
			.build();

	ServiceInstanceController controller = createControllerUnderTest(expectedRequest);

	controller.createServiceInstance(pathVariables, "service-instance-id", true,
			"api-info-location", encodeOriginatingIdentity(identityContext), "request-id", parsedRequest)
			.block();
}
 
Example #4
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 #5
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 #6
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 #7
Source File: ServiceInstanceControllerIntegrationTest.java    From spring-cloud-open-service-broker with Apache License 2.0 6 votes vote down vote up
@Test
void createServiceInstanceWithAsyncAndHeadersOperationInProgress() throws Exception {
	setupCatalogService();

	setupServiceInstanceService(new ServiceBrokerCreateOperationInProgressException("task_10"));

	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()
			.expectBody()
			.jsonPath("$.operation").isEqualTo("task_10");

	CreateServiceInstanceRequest actualRequest = verifyCreateServiceInstance();
	assertThat(actualRequest.isAsyncAccepted()).isEqualTo(true);
	assertHeaderValuesSet(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 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 #9
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 #10
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 #11
Source File: AppDeploymentCreateServiceInstanceWorkflowTest.java    From spring-cloud-app-broker with Apache License 2.0 6 votes vote down vote up
private void setupMocks(CreateServiceInstanceRequest request) {
	given(this.appDeploymentService.deploy(eq(backingApps), eq(request.getServiceInstanceId())))
		.willReturn(Flux.just("app1", "app2"));
	given(this.servicesProvisionService.createServiceInstance(eq(backingServices)))
		.willReturn(Flux.just("my-service-instance"));

	given(
		this.appsParametersTransformationService.transformParameters(eq(backingApps), eq(request.getParameters())))
		.willReturn(Mono.just(backingApps));
	given(this.servicesParametersTransformationService
		.transformParameters(eq(backingServices), eq(request.getParameters())))
		.willReturn(Mono.just(backingServices));

	given(this.credentialProviderService.addCredentials(eq(backingApps), eq(request.getServiceInstanceId())))
		.willReturn(Mono.just(backingApps));

	given(this.targetService
		.addToBackingApplications(eq(backingApps), eq(targetSpec), eq(request.getServiceInstanceId())))
		.willReturn(Mono.just(backingApps));
	given(this.targetService
		.addToBackingServices(eq(backingServices), eq(targetSpec), eq(request.getServiceInstanceId())))
		.willReturn(Mono.just(backingServices));
}
 
Example #12
Source File: AppDeploymentCreateServiceInstanceWorkflowTest.java    From spring-cloud-app-broker with Apache License 2.0 6 votes vote down vote up
private CreateServiceInstanceRequest buildRequest(String serviceName, String planName,
	Map<String, Object> parameters) {
	return CreateServiceInstanceRequest
		.builder()
		.serviceInstanceId("service-instance-id")
		.serviceDefinitionId(serviceName + "-id")
		.planId(planName + "-id")
		.serviceDefinition(ServiceDefinition
			.builder()
			.id(serviceName + "-id")
			.name(serviceName)
			.plans(Plan.builder()
				.id(planName + "-id")
				.name(planName)
				.build())
			.build())
		.plan(Plan.builder()
			.id(planName + "-id")
			.name(planName)
			.build())
		.parameters(parameters == null ? new HashMap<>() : parameters)
		.build();
}
 
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 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 #14
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 #15
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 #16
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 #17
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 #18
Source File: ServiceInstanceControllerIntegrationTest.java    From spring-cloud-open-service-broker with Apache License 2.0 6 votes vote down vote up
@Test
void createServiceInstanceWithAsyncAndHeadersOperationInProgress() throws Exception {
	setupCatalogService();

	setupServiceInstanceService(new ServiceBrokerCreateOperationInProgressException("task_10"));

	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")));

	CreateServiceInstanceRequest actualRequest = verifyCreateServiceInstance();
	assertThat(actualRequest.isAsyncAccepted()).isEqualTo(true);
	assertHeaderValuesSet(actualRequest);
}
 
Example #19
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 #20
Source File: ExampleServiceInstanceEventFlowsConfiguration2.java    From spring-cloud-open-service-broker with Apache License 2.0 5 votes vote down vote up
@Bean
public CreateServiceInstanceInitializationFlow createServiceInstanceInitializationFlow() {
	return new CreateServiceInstanceInitializationFlow() {
		@Override
		public Mono<Void> initialize(CreateServiceInstanceRequest request) {
			//
			// do something before the instance is created
			//
			return Mono.empty();
		}
	};
}
 
Example #21
Source File: ServiceInstanceEventServiceTest.java    From spring-cloud-open-service-broker with Apache License 2.0 5 votes vote down vote up
@Test
void createServiceInstanceFails() {
	prepareCreateEventFlows();

	StepVerifier.create(serviceInstanceEventService.createServiceInstance(
			CreateServiceInstanceRequest.builder()
					.serviceInstanceId("service-instance-id")
					.build()))
			.expectError()
			.verify();

	assertThat(this.results.getBeforeCreate()).isEqualTo("before service-instance-id");
	assertThat(this.results.getAfterCreate()).isNullOrEmpty();
	assertThat(this.results.getErrorCreate()).isEqualTo("error service-instance-id");
}
 
Example #22
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());

	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()
			.expectBody()
			.jsonPath("$.operation").isEqualTo("task_10")
			.jsonPath("$.dashboard_url").isEqualTo("https://dashboard.app.local");

	CreateServiceInstanceRequest actualRequest = verifyCreateServiceInstance();
	assertThat(actualRequest.isAsyncAccepted()).isEqualTo(true);
	assertHeaderValuesSet(actualRequest);
}
 
Example #23
Source File: EventFlowsAutoConfigurationTest.java    From spring-cloud-open-service-broker with Apache License 2.0 5 votes vote down vote up
@Bean
public CreateServiceInstanceInitializationFlow createInitFlow2() {
	return new CreateServiceInstanceInitializationFlow() {
		@Override
		public Mono<Void> initialize(CreateServiceInstanceRequest request) {
			return Mono.empty();
		}
	};
}
 
Example #24
Source File: EventFlowsAutoConfigurationTest.java    From spring-cloud-open-service-broker with Apache License 2.0 5 votes vote down vote up
@Bean
public CreateServiceInstanceInitializationFlow createInitFlow1() {
	return new CreateServiceInstanceInitializationFlow() {
		@Override
		public Mono<Void> initialize(CreateServiceInstanceRequest request) {
			return Mono.empty();
		}
	};
}
 
Example #25
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 #26
Source File: ServiceInstanceControllerRequestTest.java    From spring-cloud-open-service-broker with Apache License 2.0 5 votes vote down vote up
private CreateServiceInstanceRequestBuilder buildCreateRequest() {
	return CreateServiceInstanceRequest.builder()
			.serviceDefinitionId("service-definition-id")
			.planId("plan-id")
			.parameters("create-param-1", "value1")
			.parameters("create-param-2", "value2")
			.context(requestContext);
}
 
Example #27
Source File: ServiceInstanceControllerRequestTest.java    From spring-cloud-open-service-broker with Apache License 2.0 5 votes vote down vote up
@Test
void createServiceInstanceWithInvalidServiceDefinitionIdThrowsException() {
	CreateServiceInstanceRequest createRequest = CreateServiceInstanceRequest.builder()
			.serviceDefinitionId("unknown-service-definition-id")
			.build();

	ServiceInstanceController controller = createControllerUnderTest();

	assertThrows(ServiceDefinitionDoesNotExistException.class, () ->
			controller.createServiceInstance(pathVariables, null, false,
					null, null, null, createRequest)
					.block());
}
 
Example #28
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 #29
Source File: ServiceInstanceControllerRequestTest.java    From spring-cloud-open-service-broker with Apache License 2.0 5 votes vote down vote up
@Test
void createServiceInstanceWithInvalidPlanIdThrowsException() {
	CreateServiceInstanceRequest createRequest = CreateServiceInstanceRequest.builder()
			.serviceDefinitionId("service-definition-id")
			.planId("unknown-plan-id")
			.build();

	ServiceInstanceController controller = createControllerUnderTest();

	assertThrows(ServiceDefinitionPlanDoesNotExistException.class, () ->
			controller.createServiceInstance(pathVariables, null, false,
					null, null, null, createRequest)
					.block());
}
 
Example #30
Source File: EventFlowsAutoConfigurationTest.java    From spring-cloud-open-service-broker with Apache License 2.0 5 votes vote down vote up
@Bean
public CreateServiceInstanceErrorFlow createErrorFlow() {
	return new CreateServiceInstanceErrorFlow() {
		@Override
		public Mono<Void> error(CreateServiceInstanceRequest request, Throwable t) {
			return Mono.empty();
		}
	};
}