use of org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceBindingResponse in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceInstanceBindingController method createServiceInstanceBinding.
@PutMapping(value = { "/{platformInstanceId}/v2/service_instances/{instanceId}/service_bindings/{bindingId}", "/v2/service_instances/{instanceId}/service_bindings/{bindingId}" })
public ResponseEntity<CreateServiceInstanceBindingResponse> createServiceInstanceBinding(@PathVariable Map<String, String> pathVariables, @PathVariable(INSTANCE_ID_PATH_VARIABLE) String serviceInstanceId, @PathVariable(BINDING_ID_PATH_VARIABLE) String bindingId, @RequestHeader(value = API_INFO_LOCATION_HEADER, required = false) String apiInfoLocation, @RequestHeader(value = ORIGINATING_IDENTITY_HEADER, required = false) String originatingIdentityString, @Valid @RequestBody CreateServiceInstanceBindingRequest request) {
request.setServiceInstanceId(serviceInstanceId);
request.setBindingId(bindingId);
request.setServiceDefinition(getRequiredServiceDefinition(request.getServiceDefinitionId()));
setCommonRequestFields(request, pathVariables.get(PLATFORM_INSTANCE_ID_VARIABLE), apiInfoLocation, originatingIdentityString);
LOGGER.debug("Creating a service instance binding: request={}", request);
CreateServiceInstanceBindingResponse response = serviceInstanceBindingService.createServiceInstanceBinding(request);
LOGGER.debug("Creating a service instance binding succeeded: serviceInstanceId={}, bindingId={}, response={}", serviceInstanceId, bindingId, response);
return new ResponseEntity<>(response, getCreateResponseCode(response));
}
use of org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceBindingResponse 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.CreateServiceInstanceBindingResponse in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceInstanceBindingControllerResponseCodeTest method createServiceBindingWithExistingBindingResponseGivesExpectedStatus.
@Test
void createServiceBindingWithExistingBindingResponseGivesExpectedStatus() {
CreateServiceInstanceBindingResponse response = CreateServiceInstanceAppBindingResponse.builder().bindingExisted(true).build();
validateCreateServiceBindingResponseStatus(response, HttpStatus.OK);
}
use of org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceBindingResponse in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceInstanceBindingControllerResponseCodeTest method createServiceBindingWithNoExistingBindingResponseGivesExpectedStatus.
@Test
void createServiceBindingWithNoExistingBindingResponseGivesExpectedStatus() {
CreateServiceInstanceBindingResponse response = CreateServiceInstanceAppBindingResponse.builder().bindingExisted(false).build();
validateCreateServiceBindingResponseStatus(response, HttpStatus.CREATED);
}
use of org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceBindingResponse 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);
}
Aggregations