use of org.springframework.cloud.servicebroker.model.instance.UpdateServiceInstanceResponse in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceInstanceControllerResponseCodeTest method validateUpdateServiceInstanceWithResponseStatus.
private void validateUpdateServiceInstanceWithResponseStatus(UpdateServiceInstanceResponse response, HttpStatus expectedStatus) {
Mono<UpdateServiceInstanceResponse> responseMono;
if (response == null) {
responseMono = Mono.empty();
} else {
responseMono = Mono.just(response);
}
given(serviceInstanceService.updateServiceInstance(any(UpdateServiceInstanceRequest.class))).willReturn(responseMono);
UpdateServiceInstanceRequest updateRequest = UpdateServiceInstanceRequest.builder().serviceDefinitionId("service-definition-id").build();
ResponseEntity<UpdateServiceInstanceResponse> responseEntity = controller.updateServiceInstance(pathVariables, null, false, null, null, null, updateRequest).block();
assertThat(responseEntity).isNotNull();
assertThat(responseEntity.getStatusCode()).isEqualTo(expectedStatus);
assertThat(responseEntity.getBody()).isEqualTo(response);
}
use of org.springframework.cloud.servicebroker.model.instance.UpdateServiceInstanceResponse in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceInstanceController method updateServiceInstance.
@PatchMapping(value = { "/{platformInstanceId}/v2/service_instances/{instanceId}", "/v2/service_instances/{instanceId}" })
public ResponseEntity<UpdateServiceInstanceResponse> updateServiceInstance(@PathVariable Map<String, String> pathVariables, @PathVariable(INSTANCE_ID_PATH_VARIABLE) String serviceInstanceId, @RequestParam(value = ASYNC_REQUEST_PARAMETER, required = false) boolean acceptsIncomplete, @RequestHeader(value = API_INFO_LOCATION_HEADER, required = false) String apiInfoLocation, @RequestHeader(value = ORIGINATING_IDENTITY_HEADER, required = false) String originatingIdentityString, @Valid @RequestBody UpdateServiceInstanceRequest request) {
ServiceDefinition serviceDefinition = getRequiredServiceDefinition(request.getServiceDefinitionId());
request.setServiceInstanceId(serviceInstanceId);
request.setServiceDefinition(serviceDefinition);
setCommonRequestFields(request, pathVariables.get(PLATFORM_INSTANCE_ID_VARIABLE), apiInfoLocation, originatingIdentityString, acceptsIncomplete);
LOGGER.debug("Updating a service instance: request={}", request);
UpdateServiceInstanceResponse response = service.updateServiceInstance(request);
LOGGER.debug("Updating a service instance succeeded: serviceInstanceId={}, response={}", serviceInstanceId, response);
return new ResponseEntity<>(response, getAsyncResponseCode(response));
}
use of org.springframework.cloud.servicebroker.model.instance.UpdateServiceInstanceResponse in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceInstanceControllerResponseCodeTest method updateServiceInstanceWithResponseGivesExpectedStatus.
@Theory
public void updateServiceInstanceWithResponseGivesExpectedStatus(UpdateResponseAndExpectedStatus data) {
when(serviceInstanceService.updateServiceInstance(any(UpdateServiceInstanceRequest.class))).thenReturn(data.response);
UpdateServiceInstanceRequest updateRequest = UpdateServiceInstanceRequest.builder().serviceDefinitionId("service-definition-id").build();
ResponseEntity<UpdateServiceInstanceResponse> responseEntity = controller.updateServiceInstance(pathVariables, null, false, null, null, updateRequest);
assertThat(responseEntity.getStatusCode()).isEqualTo(data.expectedStatus);
assertThat(responseEntity.getBody()).isEqualTo(data.response);
}
Aggregations