Search in sources :

Example 6 with UpdateServiceInstanceRequest

use of org.springframework.cloud.servicebroker.model.instance.UpdateServiceInstanceRequest 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)

Example 7 with UpdateServiceInstanceRequest

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

the class ServiceInstanceControllerIntegrationTest method updateServiceInstanceWithAsyncAndHeadersSucceeds.

@Test
void updateServiceInstanceWithAsyncAndHeadersSucceeds() throws Exception {
    setupCatalogService();
    setupServiceInstanceService(UpdateServiceInstanceResponse.builder().async(true).operation("working").dashboardUrl("https://dashboard.app.local").build());
    MvcResult mvcResult = mockMvc.perform(patch(buildCreateUpdateUrl(PLATFORM_INSTANCE_ID, true)).content(updateRequestBody).header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION).header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()).contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)).andExpect(request().asyncStarted()).andReturn();
    mockMvc.perform(asyncDispatch(mvcResult)).andExpect(status().isAccepted()).andExpect(jsonPath("$.operation", equalTo("working"))).andExpect(jsonPath("$.dashboard_url", equalTo("https://dashboard.app.local")));
    UpdateServiceInstanceRequest actualRequest = verifyUpdateServiceInstance();
    assertThat(actualRequest.isAsyncAccepted()).isEqualTo(true);
    assertHeaderValuesSet(actualRequest);
}
Also used : UpdateServiceInstanceRequest(org.springframework.cloud.servicebroker.model.instance.UpdateServiceInstanceRequest) MvcResult(org.springframework.test.web.servlet.MvcResult) AbstractServiceInstanceControllerIntegrationTest(org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceControllerIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 8 with UpdateServiceInstanceRequest

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

the class ServiceInstanceControllerIntegrationTest method updateServiceInstanceFiltersPlansSucceeds.

@Test
void updateServiceInstanceFiltersPlansSucceeds() {
    setupCatalogService();
    setupServiceInstanceService(UpdateServiceInstanceResponse.builder().build());
    client.patch().uri(buildCreateUpdateUrl()).contentType(MediaType.APPLICATION_JSON).bodyValue(updateRequestBodyWithPlan).accept(MediaType.APPLICATION_JSON).exchange().expectStatus().isOk().expectBody().json("{}");
    UpdateServiceInstanceRequest actualRequest = verifyUpdateServiceInstance();
    assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false);
    assertThat(actualRequest.getPlan().getId()).isEqualTo("plan-three-id");
    assertHeaderValuesNotSet(actualRequest);
}
Also used : UpdateServiceInstanceRequest(org.springframework.cloud.servicebroker.model.instance.UpdateServiceInstanceRequest) AbstractServiceInstanceControllerIntegrationTest(org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceControllerIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 9 with UpdateServiceInstanceRequest

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

the class ServiceInstanceControllerIntegrationTest method updateServiceInstanceWithAsyncAndHeadersSucceeds.

@Test
void updateServiceInstanceWithAsyncAndHeadersSucceeds() throws Exception {
    setupCatalogService();
    setupServiceInstanceService(UpdateServiceInstanceResponse.builder().async(true).operation("working").dashboardUrl("https://dashboard.app.local").build());
    client.patch().uri(buildCreateUpdateUrl(PLATFORM_INSTANCE_ID, true)).contentType(MediaType.APPLICATION_JSON).bodyValue(updateRequestBody).header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION).header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()).accept(MediaType.APPLICATION_JSON).exchange().expectStatus().isAccepted().expectBody().jsonPath("$.operation").isEqualTo("working").jsonPath("$.dashboard_url").isEqualTo("https://dashboard.app.local");
    UpdateServiceInstanceRequest actualRequest = verifyUpdateServiceInstance();
    assertThat(actualRequest.isAsyncAccepted()).isEqualTo(true);
    assertHeaderValuesSet(actualRequest);
}
Also used : UpdateServiceInstanceRequest(org.springframework.cloud.servicebroker.model.instance.UpdateServiceInstanceRequest) AbstractServiceInstanceControllerIntegrationTest(org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceControllerIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 10 with UpdateServiceInstanceRequest

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

the class ServiceInstanceControllerIntegrationTest method updateServiceInstanceFiltersPlansSucceeds.

@Test
void updateServiceInstanceFiltersPlansSucceeds() throws Exception {
    setupCatalogService();
    setupServiceInstanceService(UpdateServiceInstanceResponse.builder().build());
    MvcResult mvcResult = mockMvc.perform(patch(buildCreateUpdateUrl()).content(updateRequestBodyWithPlan).contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)).andExpect(request().asyncStarted()).andReturn();
    mockMvc.perform(asyncDispatch(mvcResult)).andExpect(status().isOk()).andExpect(content().string("{}"));
    UpdateServiceInstanceRequest actualRequest = verifyUpdateServiceInstance();
    assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false);
    assertThat(actualRequest.getPlan().getId()).isEqualTo(actualRequest.getPlanId());
    assertHeaderValuesNotSet(actualRequest);
}
Also used : UpdateServiceInstanceRequest(org.springframework.cloud.servicebroker.model.instance.UpdateServiceInstanceRequest) MvcResult(org.springframework.test.web.servlet.MvcResult) AbstractServiceInstanceControllerIntegrationTest(org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceControllerIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

UpdateServiceInstanceRequest (org.springframework.cloud.servicebroker.model.instance.UpdateServiceInstanceRequest)11 Test (org.junit.jupiter.api.Test)8 AbstractServiceInstanceControllerIntegrationTest (org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceControllerIntegrationTest)7 MvcResult (org.springframework.test.web.servlet.MvcResult)3 UpdateServiceInstanceResponse (org.springframework.cloud.servicebroker.model.instance.UpdateServiceInstanceResponse)2 Test (org.junit.Test)1 Theory (org.junit.experimental.theories.Theory)1