use of org.springframework.cloud.servicebroker.model.instance.CreateServiceInstanceRequest in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceInstanceControllerResponseCodeTest method validateCreateServiceInstanceWithResponseStatus.
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);
}
use of org.springframework.cloud.servicebroker.model.instance.CreateServiceInstanceRequest in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceInstanceControllerIntegrationTest method createServiceInstanceFiltersPlanSucceeds.
@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);
}
use of org.springframework.cloud.servicebroker.model.instance.CreateServiceInstanceRequest in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceInstanceControllerIntegrationTest method createServiceInstanceWithAsyncAndHeadersOperationInProgress.
@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);
}
use of org.springframework.cloud.servicebroker.model.instance.CreateServiceInstanceRequest in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceInstanceControllerIntegrationTest method createServiceInstanceWithEmptyPlatformInstanceIdSucceeds.
@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);
}
use of org.springframework.cloud.servicebroker.model.instance.CreateServiceInstanceRequest in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceInstanceControllerIntegrationTest method createServiceInstanceWithAsyncAndHeadersOperationInProgress.
@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);
}
Aggregations