Search in sources :

Example 1 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 validateUpdateServiceInstanceWithResponseStatus.

private void validateUpdateServiceInstanceWithResponseStatus(UpdateServiceInstanceResponse response, HttpStatus expectedStatus) {
    Mono<UpdateServiceInstanceResponse> responseMono;
    if (response == null) {
        responseMono = Mono.empty();
    } else {
        responseMono = Mono.just(response);
    }
    given(serviceInstanceService.updateServiceInstance(any(UpdateServiceInstanceRequest.class))).willReturn(responseMono);
    UpdateServiceInstanceRequest updateRequest = UpdateServiceInstanceRequest.builder().serviceDefinitionId("service-definition-id").build();
    ResponseEntity<UpdateServiceInstanceResponse> responseEntity = controller.updateServiceInstance(pathVariables, null, false, null, null, null, updateRequest).block();
    assertThat(responseEntity).isNotNull();
    assertThat(responseEntity.getStatusCode()).isEqualTo(expectedStatus);
    assertThat(responseEntity.getBody()).isEqualTo(response);
}
Also used : UpdateServiceInstanceRequest(org.springframework.cloud.servicebroker.model.instance.UpdateServiceInstanceRequest) UpdateServiceInstanceResponse(org.springframework.cloud.servicebroker.model.instance.UpdateServiceInstanceResponse)

Example 2 with UpdateServiceInstanceRequest

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

the class ServiceInstanceControllerRequestTest method updateServiceInstanceParametersAreMappedToRequest.

@Test
void updateServiceInstanceParametersAreMappedToRequest() {
    UpdateServiceInstanceRequest parsedRequest = buildUpdateRequest().build();
    UpdateServiceInstanceRequest expectedRequest = buildUpdateRequest().asyncAccepted(true).serviceInstanceId("service-instance-id").platformInstanceId("platform-instance-id").apiInfoLocation("api-info-location").originatingIdentity(identityContext).requestIdentity("request-id").serviceDefinition(serviceDefinition).plan(plan).build();
    ServiceInstanceController controller = createControllerUnderTest(expectedRequest);
    controller.updateServiceInstance(pathVariables, "service-instance-id", true, "api-info-location", encodeOriginatingIdentity(identityContext), "request-id", parsedRequest).block();
}
Also used : UpdateServiceInstanceRequest(org.springframework.cloud.servicebroker.model.instance.UpdateServiceInstanceRequest) Test(org.junit.jupiter.api.Test)

Example 3 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 updateServiceInstanceWithoutAsyncAndHeadersSucceeds.

@Test
void updateServiceInstanceWithoutAsyncAndHeadersSucceeds() {
    setupCatalogService();
    setupServiceInstanceService(UpdateServiceInstanceResponse.builder().build());
    client.patch().uri(buildCreateUpdateUrl()).contentType(MediaType.APPLICATION_JSON).bodyValue(updateRequestBody).accept(MediaType.APPLICATION_JSON).exchange().expectStatus().isOk().expectBody().json("{}");
    UpdateServiceInstanceRequest actualRequest = verifyUpdateServiceInstance();
    assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false);
    assertThat(actualRequest.getPlan()).isNull();
    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 4 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 updateServiceInstanceWithoutSyncAndHeadersSucceeds.

@Test
void updateServiceInstanceWithoutSyncAndHeadersSucceeds() throws Exception {
    setupCatalogService();
    setupServiceInstanceService(UpdateServiceInstanceResponse.builder().build());
    MvcResult mvcResult = mockMvc.perform(patch(buildCreateUpdateUrl()).content(updateRequestBody).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.getServiceDefinition().getPlans().size()).isEqualTo(3);
    assertThat(actualRequest.getPlan()).isNull();
    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)

Example 5 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 updateServiceInstanceWithoutSyncAndHeadersSucceeds.

@Test
public void updateServiceInstanceWithoutSyncAndHeadersSucceeds() {
    setupCatalogService();
    setupServiceInstanceService(UpdateServiceInstanceResponse.builder().build());
    client.patch().uri(buildCreateUpdateUrl()).contentType(MediaType.APPLICATION_JSON).syncBody(updateRequestBody).accept(MediaType.APPLICATION_JSON).exchange().expectStatus().isOk().expectBody().json("{}");
    UpdateServiceInstanceRequest actualRequest = verifyUpdateServiceInstance();
    assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false);
    assertHeaderValuesNotSet(actualRequest);
}
Also used : UpdateServiceInstanceRequest(org.springframework.cloud.servicebroker.model.instance.UpdateServiceInstanceRequest) Test(org.junit.Test) AbstractServiceInstanceControllerIntegrationTest(org.springframework.cloud.servicebroker.autoconfigure.web.AbstractServiceInstanceControllerIntegrationTest)

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