use of org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceBindingRequest in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceInstanceBindingControllerIntegrationTest method createBindingToAppSucceeds.
@Test
public void createBindingToAppSucceeds() throws Exception {
setupCatalogService();
setupServiceInstanceBindingService(CreateServiceInstanceAppBindingResponse.builder().bindingExisted(false).build());
mockMvc.perform(put(buildCreateUrl(PLATFORM_INSTANCE_ID)).content(createRequestBody).header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION).header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()).accept(MediaType.APPLICATION_JSON).contentType(MediaType.APPLICATION_JSON)).andExpect(status().isCreated());
CreateServiceInstanceBindingRequest actualRequest = verifyCreateBinding();
assertHeaderValuesSet(actualRequest);
}
use of org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceBindingRequest in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceInstanceBindingControllerResponseCodeTest method createServiceBindingWithResponseGivesExpectedStatus.
@Theory
public void createServiceBindingWithResponseGivesExpectedStatus(CreateResponseAndExpectedStatus data) {
when(bindingService.createServiceInstanceBinding(any(CreateServiceInstanceBindingRequest.class))).thenReturn(data.response);
CreateServiceInstanceBindingRequest createRequest = CreateServiceInstanceBindingRequest.builder().serviceDefinitionId("service-definition-id").build();
ResponseEntity<CreateServiceInstanceBindingResponse> responseEntity = controller.createServiceInstanceBinding(pathVariables, null, null, null, null, createRequest);
assertThat(responseEntity.getStatusCode()).isEqualTo(data.expectedStatus);
assertThat(responseEntity.getBody()).isEqualTo(data.response);
}
use of org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceBindingRequest in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceInstanceBindingIntegrationTest method setupBase.
@BeforeEach
void setupBase() {
CreateServiceInstanceBindingRequest request = CreateServiceInstanceBindingRequest.builder().serviceDefinitionId(serviceDefinition.getId()).planId("plan-one-id").build();
createRequestBody = JsonUtils.toJson(request);
}
use of org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceBindingRequest in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceInstanceBindingControllerResponseCodeTest method validateCreateServiceBindingResponseStatus.
private void validateCreateServiceBindingResponseStatus(CreateServiceInstanceBindingResponse response, HttpStatus httpStatus) {
Mono<CreateServiceInstanceBindingResponse> responseMono;
if (response == null) {
responseMono = Mono.empty();
} else {
responseMono = Mono.just(response);
}
given(bindingService.createServiceInstanceBinding(any(CreateServiceInstanceBindingRequest.class))).willReturn(responseMono);
CreateServiceInstanceBindingRequest createRequest = CreateServiceInstanceBindingRequest.builder().serviceDefinitionId("service-definition-id").planId("service-definition-plan-id").build();
ResponseEntity<CreateServiceInstanceBindingResponse> responseEntity = controller.createServiceInstanceBinding(pathVariables, null, null, false, null, null, null, createRequest).block();
assertThat(responseEntity).isNotNull();
assertThat(responseEntity.getStatusCode()).isEqualTo(httpStatus);
assertThat(responseEntity.getBody()).isEqualTo(response);
}
use of org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceBindingRequest in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceInstanceBindingControllerRequestTest method createServiceBindingWithInvalidPlanIdThrowsException.
@Test
void createServiceBindingWithInvalidPlanIdThrowsException() {
CreateServiceInstanceBindingRequest createRequest = CreateServiceInstanceBindingRequest.builder().serviceDefinitionId("service-definition-id").planId("unknown-plan-id").build();
ServiceInstanceBindingController controller = createControllerUnderTest();
assertThrows(ServiceDefinitionPlanDoesNotExistException.class, () -> controller.createServiceInstanceBinding(pathVariables, null, null, false, null, encodeOriginatingIdentity(identityContext), "request-id", createRequest).block());
}
Aggregations