Search in sources :

Example 1 with GetServiceInstanceBindingRequest

use of org.springframework.cloud.servicebroker.model.binding.GetServiceInstanceBindingRequest 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 GetServiceInstanceBindingRequest

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

the class ServiceInstanceBindingControllerRequestTest method getServiceBindingParametersAreMappedToRequest.

@Test
public void getServiceBindingParametersAreMappedToRequest() {
    GetServiceInstanceBindingRequest expectedRequest = GetServiceInstanceBindingRequest.builder().serviceInstanceId("service-instance-id").bindingId("binding-id").platformInstanceId("platform-instance-id").apiInfoLocation("api-info-location").originatingIdentity(identityContext).build();
    ServiceInstanceBindingController controller = createControllerUnderTest(expectedRequest);
    controller.getServiceInstanceBinding(pathVariables, "service-instance-id", "binding-id", "api-info-location", encodeOriginatingIdentity(identityContext));
}
Also used : GetServiceInstanceBindingRequest(org.springframework.cloud.servicebroker.model.binding.GetServiceInstanceBindingRequest) Test(org.junit.Test)

Example 3 with GetServiceInstanceBindingRequest

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

the class ServiceInstanceBindingControllerIntegrationTest method getBindingToRouteSucceeds.

@Test
public void getBindingToRouteSucceeds() throws Exception {
    setupServiceInstanceBindingService(GetServiceInstanceRouteBindingResponse.builder().build());
    mockMvc.perform(get(buildCreateUrl(PLATFORM_INSTANCE_ID)).header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION).header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()).accept(MediaType.APPLICATION_JSON).contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk());
    GetServiceInstanceBindingRequest actualRequest = verifyGetBinding();
    assertHeaderValuesSet(actualRequest);
}
Also used : GetServiceInstanceBindingRequest(org.springframework.cloud.servicebroker.model.binding.GetServiceInstanceBindingRequest) AbstractServiceInstanceBindingControllerIntegrationTest(org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceBindingControllerIntegrationTest) Test(org.junit.Test)

Example 4 with GetServiceInstanceBindingRequest

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

the class ServiceInstanceBindingControllerIntegrationTest method getBindingToAppSucceeds.

@Test
public void getBindingToAppSucceeds() throws Exception {
    setupServiceInstanceBindingService(GetServiceInstanceAppBindingResponse.builder().build());
    mockMvc.perform(get(buildCreateUrl(PLATFORM_INSTANCE_ID)).header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION).header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()).accept(MediaType.APPLICATION_JSON).contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk());
    GetServiceInstanceBindingRequest actualRequest = verifyGetBinding();
    assertHeaderValuesSet(actualRequest);
}
Also used : GetServiceInstanceBindingRequest(org.springframework.cloud.servicebroker.model.binding.GetServiceInstanceBindingRequest) AbstractServiceInstanceBindingControllerIntegrationTest(org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceBindingControllerIntegrationTest) Test(org.junit.Test)

Example 5 with GetServiceInstanceBindingRequest

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

the class ServiceInstanceBindingControllerIntegrationTest method getBindingToRouteSucceeds.

@Test
public void getBindingToRouteSucceeds() throws Exception {
    setupServiceInstanceBindingService(GetServiceInstanceRouteBindingResponse.builder().build());
    client.get().uri(buildCreateUrl(PLATFORM_INSTANCE_ID)).header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION).header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()).accept(MediaType.APPLICATION_JSON).exchange().expectStatus().isOk();
    GetServiceInstanceBindingRequest actualRequest = verifyGetBinding();
    assertHeaderValuesSet(actualRequest);
}
Also used : GetServiceInstanceBindingRequest(org.springframework.cloud.servicebroker.model.binding.GetServiceInstanceBindingRequest) AbstractServiceInstanceBindingControllerIntegrationTest(org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceBindingControllerIntegrationTest) Test(org.junit.Test)

Aggregations

GetServiceInstanceBindingRequest (org.springframework.cloud.servicebroker.model.binding.GetServiceInstanceBindingRequest)6 Test (org.junit.Test)5 AbstractServiceInstanceBindingControllerIntegrationTest (org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceBindingControllerIntegrationTest)4 GetServiceInstanceBindingResponse (org.springframework.cloud.servicebroker.model.binding.GetServiceInstanceBindingResponse)1 ResponseEntity (org.springframework.http.ResponseEntity)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1