Search in sources :

Example 1 with UpdateServiceInstanceResponse

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);
}
Also used : UpdateServiceInstanceRequest(org.springframework.cloud.servicebroker.model.instance.UpdateServiceInstanceRequest) UpdateServiceInstanceResponse(org.springframework.cloud.servicebroker.model.instance.UpdateServiceInstanceResponse)

Example 2 with UpdateServiceInstanceResponse

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));
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) UpdateServiceInstanceResponse(org.springframework.cloud.servicebroker.model.instance.UpdateServiceInstanceResponse) ServiceDefinition(org.springframework.cloud.servicebroker.model.catalog.ServiceDefinition) PatchMapping(org.springframework.web.bind.annotation.PatchMapping)

Example 3 with UpdateServiceInstanceResponse

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);
}
Also used : UpdateServiceInstanceRequest(org.springframework.cloud.servicebroker.model.instance.UpdateServiceInstanceRequest) UpdateServiceInstanceResponse(org.springframework.cloud.servicebroker.model.instance.UpdateServiceInstanceResponse) Theory(org.junit.experimental.theories.Theory)

Aggregations

UpdateServiceInstanceResponse (org.springframework.cloud.servicebroker.model.instance.UpdateServiceInstanceResponse)3 UpdateServiceInstanceRequest (org.springframework.cloud.servicebroker.model.instance.UpdateServiceInstanceRequest)2 Theory (org.junit.experimental.theories.Theory)1 ServiceDefinition (org.springframework.cloud.servicebroker.model.catalog.ServiceDefinition)1 ResponseEntity (org.springframework.http.ResponseEntity)1 PatchMapping (org.springframework.web.bind.annotation.PatchMapping)1