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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations