Search in sources :

Example 1 with GetServiceInstanceBindingResponse

use of org.springframework.cloud.servicebroker.model.binding.GetServiceInstanceBindingResponse in project spring-cloud-open-service-broker by spring-cloud.

the class ServiceInstanceBindingController method getServiceInstanceBinding.

@GetMapping(value = { "/{platformInstanceId}/v2/service_instances/{instanceId}/service_bindings/{bindingId}", "/v2/service_instances/{instanceId}/service_bindings/{bindingId}" })
public ResponseEntity<GetServiceInstanceBindingResponse> getServiceInstanceBinding(@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) {
    GetServiceInstanceBindingRequest request = GetServiceInstanceBindingRequest.builder().serviceInstanceId(serviceInstanceId).bindingId(bindingId).platformInstanceId(pathVariables.get(PLATFORM_INSTANCE_ID_VARIABLE)).apiInfoLocation(apiInfoLocation).originatingIdentity(parseOriginatingIdentity(originatingIdentityString)).build();
    LOGGER.debug("Getting a service instance binding: request={}", request);
    GetServiceInstanceBindingResponse response = serviceInstanceBindingService.getServiceInstanceBinding(request);
    LOGGER.debug("Getting a service instance binding succeeded: bindingId={}", bindingId);
    return new ResponseEntity<>(response, HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) GetServiceInstanceBindingRequest(org.springframework.cloud.servicebroker.model.binding.GetServiceInstanceBindingRequest) GetServiceInstanceBindingResponse(org.springframework.cloud.servicebroker.model.binding.GetServiceInstanceBindingResponse) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 2 with GetServiceInstanceBindingResponse

use of org.springframework.cloud.servicebroker.model.binding.GetServiceInstanceBindingResponse in project spring-cloud-open-service-broker by spring-cloud.

the class ServiceInstanceBindingControllerResponseCodeTest method getServiceBindingWithMissingServiceInstanceGivesExpectedStatus.

@Test
void getServiceBindingWithMissingServiceInstanceGivesExpectedStatus() {
    given(bindingService.getServiceInstanceBinding(any(GetServiceInstanceBindingRequest.class))).willThrow(new ServiceInstanceDoesNotExistException("nonexistent-service-id"));
    ResponseEntity<GetServiceInstanceBindingResponse> responseEntity = controller.getServiceInstanceBinding(pathVariables, "nonexistent-service-id", "nonexistent-binding-id", null, null, null, null, null).block();
    assertThat(responseEntity).isNotNull();
    assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
}
Also used : ServiceInstanceDoesNotExistException(org.springframework.cloud.servicebroker.exception.ServiceInstanceDoesNotExistException) GetServiceInstanceBindingRequest(org.springframework.cloud.servicebroker.model.binding.GetServiceInstanceBindingRequest) GetServiceInstanceBindingResponse(org.springframework.cloud.servicebroker.model.binding.GetServiceInstanceBindingResponse) Test(org.junit.jupiter.api.Test)

Example 3 with GetServiceInstanceBindingResponse

use of org.springframework.cloud.servicebroker.model.binding.GetServiceInstanceBindingResponse in project spring-cloud-open-service-broker by spring-cloud.

the class ExampleServiceBindingService method getServiceInstanceBinding.

@Override
public Mono<GetServiceInstanceBindingResponse> getServiceInstanceBinding(GetServiceInstanceBindingRequest request) {
    String serviceInstanceId = request.getServiceInstanceId();
    String bindingId = request.getBindingId();
    // 
    // retrieve the details of the specified service binding
    // 
    String url = new String();
    String bindingUsername = new String();
    String bindingPassword = new String();
    GetServiceInstanceBindingResponse response = GetServiceInstanceAppBindingResponse.builder().credentials("username", bindingUsername).credentials("password", bindingPassword).credentials("url", url).build();
    return Mono.just(response);
}
Also used : GetServiceInstanceBindingResponse(org.springframework.cloud.servicebroker.model.binding.GetServiceInstanceBindingResponse)

Example 4 with GetServiceInstanceBindingResponse

use of org.springframework.cloud.servicebroker.model.binding.GetServiceInstanceBindingResponse in project spring-cloud-open-service-broker by spring-cloud.

the class ServiceInstanceBindingControllerResponseCodeTest method getServiceBindingWithResponseGivesExpectedStatus2.

@Test
void getServiceBindingWithResponseGivesExpectedStatus2() {
    GetServiceInstanceBindingResponse response = GetServiceInstanceAppBindingResponse.builder().build();
    validateGetServiceBindingResponseStatus(response, HttpStatus.OK);
}
Also used : GetServiceInstanceBindingResponse(org.springframework.cloud.servicebroker.model.binding.GetServiceInstanceBindingResponse) Test(org.junit.jupiter.api.Test)

Example 5 with GetServiceInstanceBindingResponse

use of org.springframework.cloud.servicebroker.model.binding.GetServiceInstanceBindingResponse in project spring-cloud-open-service-broker by spring-cloud.

the class ServiceInstanceBindingControllerResponseCodeTest method getServiceBindingWithMissingBindingGivesExpectedStatus.

@Test
void getServiceBindingWithMissingBindingGivesExpectedStatus() {
    given(bindingService.getServiceInstanceBinding(any(GetServiceInstanceBindingRequest.class))).willThrow(new ServiceInstanceBindingDoesNotExistException("binding-id"));
    ResponseEntity<GetServiceInstanceBindingResponse> responseEntity = controller.getServiceInstanceBinding(pathVariables, null, null, null, null, null, null, null).block();
    assertThat(responseEntity).isNotNull();
    assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
}
Also used : ServiceInstanceBindingDoesNotExistException(org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingDoesNotExistException) GetServiceInstanceBindingRequest(org.springframework.cloud.servicebroker.model.binding.GetServiceInstanceBindingRequest) GetServiceInstanceBindingResponse(org.springframework.cloud.servicebroker.model.binding.GetServiceInstanceBindingResponse) Test(org.junit.jupiter.api.Test)

Aggregations

GetServiceInstanceBindingResponse (org.springframework.cloud.servicebroker.model.binding.GetServiceInstanceBindingResponse)5 Test (org.junit.jupiter.api.Test)3 GetServiceInstanceBindingRequest (org.springframework.cloud.servicebroker.model.binding.GetServiceInstanceBindingRequest)3 ServiceInstanceBindingDoesNotExistException (org.springframework.cloud.servicebroker.exception.ServiceInstanceBindingDoesNotExistException)1 ServiceInstanceDoesNotExistException (org.springframework.cloud.servicebroker.exception.ServiceInstanceDoesNotExistException)1 ResponseEntity (org.springframework.http.ResponseEntity)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1