@Test public void requestWithDefaultsIsBuilt() { CreateServiceInstanceRequest request = CreateServiceInstanceRequest.builder() .build(); assertThat(request.getServiceDefinitionId()).isNull(); assertThat(request.getServiceInstanceId()).isNull(); assertThat(request.getPlanId()).isNull(); assertThat(request.getServiceDefinition()).isNull(); assertThat(request.getContext()).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 createServiceInstanceFiltersPlanSucceeds() { setupCatalogService(); setupServiceInstanceService(CreateServiceInstanceResponse .builder() .build()); client.put().uri(buildCreateUpdateUrl()) .contentType(MediaType.APPLICATION_JSON) .syncBody(createRequestBody) .accept(MediaType.APPLICATION_JSON) .exchange() .expectStatus().isCreated(); CreateServiceInstanceRequest actualRequest = verifyCreateServiceInstance(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false); assertThat(actualRequest.getPlan().getId()).isEqualTo("plan-one-id"); assertHeaderValuesNotSet(actualRequest); }
@Test public void createServiceInstanceWithoutAsyncAndHeadersSucceeds() { setupCatalogService(); setupServiceInstanceService(CreateServiceInstanceResponse.builder() .build()); client.put().uri(buildCreateUpdateUrl()) .contentType(MediaType.APPLICATION_JSON) .syncBody(createRequestBody) .accept(MediaType.APPLICATION_JSON) .exchange() .expectStatus().isCreated(); CreateServiceInstanceRequest actualRequest = verifyCreateServiceInstance(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false); assertHeaderValuesNotSet(actualRequest); }
@Test public void createServiceInstanceFiltersPlansSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceService(CreateServiceInstanceResponse .builder() .build()); MvcResult mvcResult = mockMvc .perform(put(buildCreateUpdateUrl()) .content(createRequestBody) .contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON)) .andExpect(request().asyncStarted()) .andReturn(); mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isCreated()); CreateServiceInstanceRequest actualRequest = verifyCreateServiceInstance(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false); assertThat(actualRequest.getPlan().getId()).isEqualTo(actualRequest.getPlanId()); assertHeaderValuesNotSet(actualRequest); }
@Test public void createServiceInstanceWithAsyncAndHeadersSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceService(CreateServiceInstanceResponse.builder() .async(true) .build()); client.put().uri(buildCreateUpdateUrl(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(); CreateServiceInstanceRequest actualRequest = verifyCreateServiceInstance(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(true); assertHeaderValuesSet(actualRequest); }
@Test public void createServiceInstanceWithoutAsyncAndHeadersSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceService(CreateServiceInstanceResponse.builder() .build()); MvcResult mvcResult = mockMvc.perform(put(buildCreateUpdateUrl()) .content(createRequestBody) .contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON)) .andExpect(request().asyncStarted()) .andReturn(); mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isCreated()); CreateServiceInstanceRequest actualRequest = verifyCreateServiceInstance(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(false); assertHeaderValuesNotSet(actualRequest); }
@Test public void createServiceInstanceWithAsyncAndHeadersSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceService(CreateServiceInstanceResponse.builder() .async(true) .build()); MvcResult mvcResult = mockMvc.perform(put(buildCreateUpdateUrl(PLATFORM_INSTANCE_ID, true)) .content(createRequestBody) .contentType(MediaType.APPLICATION_JSON) .header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION) .header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()) .accept(MediaType.APPLICATION_JSON)) .andExpect(request().asyncStarted()) .andReturn(); mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isAccepted()); CreateServiceInstanceRequest actualRequest = verifyCreateServiceInstance(); assertThat(actualRequest.isAsyncAccepted()).isEqualTo(true); assertHeaderValuesSet(actualRequest); }