@Test public void createBindingToRouteFiltersPlansSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceBindingService(CreateServiceInstanceRouteBindingResponse .builder() .bindingExisted(false) .build()); client.put().uri(buildCreateUrl()) .contentType(MediaType.APPLICATION_JSON) .syncBody(createRequestBody) .accept(MediaType.APPLICATION_JSON) .exchange() .expectStatus().isCreated(); CreateServiceInstanceBindingRequest actualRequest = verifyCreateBinding(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false); assertThat(actualRequest.getPlan().getId()).isEqualTo(actualRequest.getPlanId()); assertHeaderValuesNotSet(actualRequest); }
@Test public void responseWithValuesIsBuilt() { CreateServiceInstanceRouteBindingResponse response = CreateServiceInstanceRouteBindingResponse.builder() .bindingExisted(true) .routeServiceUrl("https://routes.example.com") .build(); assertThat(response.isBindingExisted()).isEqualTo(true); assertThat(response.getRouteServiceUrl()).isEqualTo("https://routes.example.com"); DocumentContext json = JsonUtils.toJsonPath(response); assertThat(json).hasPath("$.route_service_url").isEqualTo("https://routes.example.com"); }
@Test public void createBindingToRouteWithAsyncHeadersSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceBindingService(CreateServiceInstanceRouteBindingResponse.builder() .async(true) .operation("working") .bindingExisted(false) .build()); MvcResult mvcResult = mockMvc.perform(put(buildCreateUrl(null, true)) .content(createRequestBody) .accept(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)) .andExpect(request().asyncStarted()) .andExpect(status().isOk()) .andReturn(); mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isAccepted()) .andExpect(jsonPath("$.operation", equalTo("working"))); CreateServiceInstanceBindingRequest actualRequest = verifyCreateBinding(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(true); assertHeaderValuesNotSet(actualRequest); }
@Test public void createBindingToRouteWithoutAsyncHeadersSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceBindingService(CreateServiceInstanceRouteBindingResponse.builder() .bindingExisted(false) .build()); MvcResult mvcResult = mockMvc.perform(put(buildCreateUrl()) .content(createRequestBody) .accept(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)) .andExpect(request().asyncStarted()) .andExpect(status().isOk()) .andReturn(); mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isCreated()); CreateServiceInstanceBindingRequest actualRequest = verifyCreateBinding(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false); assertHeaderValuesNotSet(actualRequest); }
@Test public void createBindingToRouteWithAsyncAndHeadersSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceBindingService(CreateServiceInstanceRouteBindingResponse.builder() .async(true) .operation("working") .bindingExisted(false) .build()); client.put().uri(buildCreateUrl(null, true)) .contentType(MediaType.APPLICATION_JSON) .syncBody(createRequestBody) .accept(MediaType.APPLICATION_JSON) .exchange() .expectStatus().isAccepted() .expectBody() .jsonPath("$.operation").isEqualTo("working"); CreateServiceInstanceBindingRequest actualRequest = verifyCreateBinding(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(true); assertHeaderValuesNotSet(actualRequest); }
@Test public void createBindingToRouteWithExistingSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceBindingService(CreateServiceInstanceRouteBindingResponse.builder() .bindingExisted(true) .build()); MvcResult mvcResult = mockMvc.perform(put(buildCreateUrl()) .content(createRequestBody) .accept(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)) .andExpect(request().asyncStarted()) .andReturn(); mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isOk()); }
@Test public void createBindingToRouteWithoutAsyncAndHeadersSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceBindingService(CreateServiceInstanceRouteBindingResponse.builder() .bindingExisted(false) .build()); client.put().uri(buildCreateUrl()) .contentType(MediaType.APPLICATION_JSON) .syncBody(createRequestBody) .accept(MediaType.APPLICATION_JSON) .exchange() .expectStatus().isCreated(); CreateServiceInstanceBindingRequest actualRequest = verifyCreateBinding(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false); assertHeaderValuesNotSet(actualRequest); }
@Test public void createBindingToRouteWithExistingSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceBindingService(CreateServiceInstanceRouteBindingResponse.builder() .bindingExisted(true) .build()); client.put().uri(buildCreateUrl()) .contentType(MediaType.APPLICATION_JSON) .syncBody(createRequestBody) .accept(MediaType.APPLICATION_JSON) .exchange() .expectStatus().isOk(); }
/** * Create a builder that provides a fluent API for constructing a * {@literal CreateServiceInstanceRouteBindingResponse}. * * @return the builder */ public static CreateServiceInstanceRouteBindingResponseBuilder builder() { return new CreateServiceInstanceRouteBindingResponseBuilder(); }
@Test public void responseWithDefaultsIsBuilt() { CreateServiceInstanceRouteBindingResponse response = CreateServiceInstanceRouteBindingResponse.builder() .build(); assertThat(response.isBindingExisted()).isEqualTo(false); assertThat(response.getRouteServiceUrl()).isNull(); DocumentContext json = JsonUtils.toJsonPath(response); assertThat(json).hasNoPath("$.route_service_url"); }
/** * Create a builder that provides a fluent API for constructing a * {@literal CreateServiceInstanceRouteBindingResponse}. * * @return the builder */ public static CreateServiceInstanceRouteBindingResponseBuilder builder() { return new CreateServiceInstanceRouteBindingResponseBuilder(); }