@Test public void requestWithDefaultsIsBuilt() { CreateServiceInstanceBindingRequest request = CreateServiceInstanceBindingRequest.builder().build(); assertThat(request.getServiceDefinitionId()).isNull(); assertThat(request.getServiceDefinition()).isNull(); assertThat(request.getPlanId()).isNull(); assertThat(request.getServiceInstanceId()).isNull(); assertThat(request.getBindResource()).isNull(); assertThat(request.getContext()).isNull(); assertThat(request.getBindingId()).isNull(); assertThat(request.getParameters()).hasSize(0); assertThat(request.isAsyncAccepted()).isEqualTo(false); assertThat(request.getApiInfoLocation()).isNull(); assertThat(request.getPlatformInstanceId()).isNull(); assertThat(request.getOriginatingIdentity()).isNull(); }
assertThat(request.isAsyncAccepted()).isEqualTo(true);
@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 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 createBindingToAppFiltersPlansSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceBindingService(CreateServiceInstanceAppBindingResponse .builder() .bindingExisted(false) .build()); MvcResult mvcResult = mockMvc .perform(put(buildCreateUrl(PLATFORM_INSTANCE_ID, false)) .content(createRequestBody) .header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION) .header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()) .accept(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)) .andExpect(request().asyncStarted()) .andReturn(); mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isCreated()); CreateServiceInstanceBindingRequest actualRequest = verifyCreateBinding(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false); assertThat(actualRequest.getPlan().getId()).isEqualTo(actualRequest.getPlanId()); assertHeaderValuesSet(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 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 createBindingToAppWithAsyncAndHeadersSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceBindingService(CreateServiceInstanceAppBindingResponse.builder() .async(true) .operation("working") .bindingExisted(false) .build()); client.put().uri(buildCreateUrl(PLATFORM_INSTANCE_ID, true)) .contentType(MediaType.APPLICATION_JSON) .syncBody(createRequestBody) .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"); CreateServiceInstanceBindingRequest actualRequest = verifyCreateBinding(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(true); assertHeaderValuesSet(actualRequest); }
@Test public void createBindingToAppWithoutAsyncAndHeadersSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceBindingService(CreateServiceInstanceAppBindingResponse.builder() .bindingExisted(false) .build()); MvcResult mvcResult = mockMvc.perform(put(buildCreateUrl(PLATFORM_INSTANCE_ID, false)) .content(createRequestBody) .header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION) .header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()) .accept(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)) .andExpect(request().asyncStarted()) .andReturn(); mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isCreated()); CreateServiceInstanceBindingRequest actualRequest = verifyCreateBinding(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false); assertHeaderValuesSet(actualRequest); }
@Test public void createBindingToAppWithAsyncAndHeadersSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceBindingService(CreateServiceInstanceAppBindingResponse.builder() .async(true) .operation("working") .bindingExisted(false) .build()); MvcResult mvcResult = mockMvc.perform(put(buildCreateUrl(PLATFORM_INSTANCE_ID, true)) .content(createRequestBody) .header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION) .header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()) .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); assertHeaderValuesSet(actualRequest); }