Search in sources :

Example 1 with CreateServiceInstanceBindingRequest

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

the class ServiceInstanceBindingControllerIntegrationTest method createBindingToAppSucceeds.

@Test
public void createBindingToAppSucceeds() throws Exception {
    setupCatalogService();
    setupServiceInstanceBindingService(CreateServiceInstanceAppBindingResponse.builder().bindingExisted(false).build());
    mockMvc.perform(put(buildCreateUrl(PLATFORM_INSTANCE_ID)).content(createRequestBody).header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION).header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()).accept(MediaType.APPLICATION_JSON).contentType(MediaType.APPLICATION_JSON)).andExpect(status().isCreated());
    CreateServiceInstanceBindingRequest actualRequest = verifyCreateBinding();
    assertHeaderValuesSet(actualRequest);
}
Also used : CreateServiceInstanceBindingRequest(org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceBindingRequest) AbstractServiceInstanceBindingControllerIntegrationTest(org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceBindingControllerIntegrationTest) Test(org.junit.Test)

Example 2 with CreateServiceInstanceBindingRequest

use of org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceBindingRequest 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);
}
Also used : CreateServiceInstanceBindingRequest(org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceBindingRequest) CreateServiceInstanceBindingResponse(org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceBindingResponse) Theory(org.junit.experimental.theories.Theory)

Example 3 with CreateServiceInstanceBindingRequest

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

the class ServiceInstanceBindingIntegrationTest method setupBase.

@BeforeEach
void setupBase() {
    CreateServiceInstanceBindingRequest request = CreateServiceInstanceBindingRequest.builder().serviceDefinitionId(serviceDefinition.getId()).planId("plan-one-id").build();
    createRequestBody = JsonUtils.toJson(request);
}
Also used : CreateServiceInstanceBindingRequest(org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceBindingRequest) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with CreateServiceInstanceBindingRequest

use of org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceBindingRequest 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);
}
Also used : CreateServiceInstanceBindingRequest(org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceBindingRequest) CreateServiceInstanceBindingResponse(org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceBindingResponse)

Example 5 with CreateServiceInstanceBindingRequest

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

the class ServiceInstanceBindingControllerRequestTest method createServiceBindingWithInvalidPlanIdThrowsException.

@Test
void createServiceBindingWithInvalidPlanIdThrowsException() {
    CreateServiceInstanceBindingRequest createRequest = CreateServiceInstanceBindingRequest.builder().serviceDefinitionId("service-definition-id").planId("unknown-plan-id").build();
    ServiceInstanceBindingController controller = createControllerUnderTest();
    assertThrows(ServiceDefinitionPlanDoesNotExistException.class, () -> controller.createServiceInstanceBinding(pathVariables, null, null, false, null, encodeOriginatingIdentity(identityContext), "request-id", createRequest).block());
}
Also used : CreateServiceInstanceBindingRequest(org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceBindingRequest) Test(org.junit.jupiter.api.Test)

Aggregations

CreateServiceInstanceBindingRequest (org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceBindingRequest)21 Test (org.junit.jupiter.api.Test)16 AbstractServiceInstanceBindingControllerIntegrationTest (org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceBindingControllerIntegrationTest)15 MvcResult (org.springframework.test.web.servlet.MvcResult)6 Test (org.junit.Test)2 CreateServiceInstanceBindingResponse (org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceBindingResponse)2 Theory (org.junit.experimental.theories.Theory)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1