Search in sources :

Example 6 with CreateServiceInstanceRequest

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

the class ServiceInstanceControllerIntegrationTest method createServiceInstanceWithEmptyPlatformInstanceIdSucceeds.

@Test
void createServiceInstanceWithEmptyPlatformInstanceIdSucceeds() {
    setupCatalogService();
    setupServiceInstanceService(CreateServiceInstanceResponse.builder().async(true).build());
    // force a condition where the platformInstanceId segment is present but empty
    // e.g. https://test.app.local//v2/service_instances/[guid]
    String url = "https://test.app.local/" + buildCreateUpdateUrl();
    client.put().uri(url).contentType(MediaType.APPLICATION_JSON).bodyValue(createRequestBody).accept(MediaType.APPLICATION_JSON).exchange().expectStatus().isAccepted();
    CreateServiceInstanceRequest actualRequest = verifyCreateServiceInstance();
    assertHeaderValuesNotSet(actualRequest);
}
Also used : CreateServiceInstanceRequest(org.springframework.cloud.servicebroker.model.instance.CreateServiceInstanceRequest) StringContains.containsString(org.hamcrest.core.StringContains.containsString) AbstractServiceInstanceControllerIntegrationTest(org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceControllerIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 7 with CreateServiceInstanceRequest

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

the class ServiceInstanceControllerIntegrationTest method createServiceInstanceWithoutAsyncAndHeadersSucceeds.

@Test
void createServiceInstanceWithoutAsyncAndHeadersSucceeds() throws Exception {
    setupCatalogService();
    setupServiceInstanceService(CreateServiceInstanceResponse.builder().build());
    MvcResult mvcResult = mockMvc.perform(put(buildCreateUpdateUrl()).content(createRequestBody).contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)).andExpect(request().asyncStarted()).andReturn();
    mockMvc.perform(asyncDispatch(mvcResult)).andExpect(status().isCreated());
    CreateServiceInstanceRequest actualRequest = verifyCreateServiceInstance();
    assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false);
    assertHeaderValuesNotSet(actualRequest);
}
Also used : CreateServiceInstanceRequest(org.springframework.cloud.servicebroker.model.instance.CreateServiceInstanceRequest) MvcResult(org.springframework.test.web.servlet.MvcResult) AbstractServiceInstanceControllerIntegrationTest(org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceControllerIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 8 with CreateServiceInstanceRequest

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

the class ServiceInstanceControllerIntegrationTest method createServiceInstanceWithAsyncOperationAndHeadersSucceeds.

@Test
void createServiceInstanceWithAsyncOperationAndHeadersSucceeds() throws Exception {
    setupCatalogService();
    // alternatively throw a ServiceBrokerCreateOperationInProgressException when a request is received for
    // an operation in progress. See test: createServiceInstanceWithAsyncAndHeadersOperationInProgress
    setupServiceInstanceService(CreateServiceInstanceResponse.builder().async(true).operation("task_10").dashboardUrl("https://dashboard.app.local").build());
    MvcResult mvcResult = mockMvc.perform(put(buildCreateUpdateUrl(PLATFORM_INSTANCE_ID, true)).content(createRequestBody).contentType(MediaType.APPLICATION_JSON).header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION).header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()).accept(MediaType.APPLICATION_JSON)).andExpect(request().asyncStarted()).andExpect(status().isOk()).andReturn();
    mockMvc.perform(asyncDispatch(mvcResult)).andExpect(status().isAccepted()).andExpect(jsonPath("$.operation", is("task_10"))).andExpect(jsonPath("$.dashboard_url", is("https://dashboard.app.local")));
    CreateServiceInstanceRequest actualRequest = verifyCreateServiceInstance();
    assertThat(actualRequest.isAsyncAccepted()).isEqualTo(true);
    assertHeaderValuesSet(actualRequest);
}
Also used : CreateServiceInstanceRequest(org.springframework.cloud.servicebroker.model.instance.CreateServiceInstanceRequest) MvcResult(org.springframework.test.web.servlet.MvcResult) AbstractServiceInstanceControllerIntegrationTest(org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceControllerIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 9 with CreateServiceInstanceRequest

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

the class ServiceInstanceControllerIntegrationTest method createServiceInstanceFiltersPlansSucceeds.

@Test
void createServiceInstanceFiltersPlansSucceeds() throws Exception {
    setupCatalogService();
    setupServiceInstanceService(CreateServiceInstanceResponse.builder().build());
    MvcResult mvcResult = mockMvc.perform(put(buildCreateUpdateUrl()).content(createRequestBody).contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)).andExpect(request().asyncStarted()).andReturn();
    mockMvc.perform(asyncDispatch(mvcResult)).andExpect(status().isCreated());
    CreateServiceInstanceRequest actualRequest = verifyCreateServiceInstance();
    assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false);
    assertThat(actualRequest.getPlan().getId()).isEqualTo(actualRequest.getPlanId());
    assertHeaderValuesNotSet(actualRequest);
}
Also used : CreateServiceInstanceRequest(org.springframework.cloud.servicebroker.model.instance.CreateServiceInstanceRequest) MvcResult(org.springframework.test.web.servlet.MvcResult) AbstractServiceInstanceControllerIntegrationTest(org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceControllerIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 10 with CreateServiceInstanceRequest

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

the class ServiceInstanceControllerIntegrationTest method createServiceInstanceWithAsyncAndHeadersSucceeds.

@Test
void createServiceInstanceWithAsyncAndHeadersSucceeds() throws Exception {
    setupCatalogService();
    setupServiceInstanceService(CreateServiceInstanceResponse.builder().async(true).build());
    MvcResult mvcResult = mockMvc.perform(put(buildCreateUpdateUrl(PLATFORM_INSTANCE_ID, true)).content(createRequestBody).contentType(MediaType.APPLICATION_JSON).header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION).header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()).accept(MediaType.APPLICATION_JSON)).andExpect(request().asyncStarted()).andReturn();
    mockMvc.perform(asyncDispatch(mvcResult)).andExpect(status().isAccepted());
    CreateServiceInstanceRequest actualRequest = verifyCreateServiceInstance();
    assertThat(actualRequest.isAsyncAccepted()).isEqualTo(true);
    assertHeaderValuesSet(actualRequest);
}
Also used : CreateServiceInstanceRequest(org.springframework.cloud.servicebroker.model.instance.CreateServiceInstanceRequest) MvcResult(org.springframework.test.web.servlet.MvcResult) AbstractServiceInstanceControllerIntegrationTest(org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceControllerIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

CreateServiceInstanceRequest (org.springframework.cloud.servicebroker.model.instance.CreateServiceInstanceRequest)17 Test (org.junit.jupiter.api.Test)15 AbstractServiceInstanceControllerIntegrationTest (org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceControllerIntegrationTest)12 MvcResult (org.springframework.test.web.servlet.MvcResult)6 StringContains.containsString (org.hamcrest.core.StringContains.containsString)2 ServiceBrokerCreateOperationInProgressException (org.springframework.cloud.servicebroker.exception.ServiceBrokerCreateOperationInProgressException)2 CreateServiceInstanceResponse (org.springframework.cloud.servicebroker.model.instance.CreateServiceInstanceResponse)2 Theory (org.junit.experimental.theories.Theory)1