@Test public void responseWithAllValuesIsBuilt() { CreateServiceInstanceResponse response = CreateServiceInstanceResponse.builder() .async(true) .operation("in progress") .instanceExisted(true) .dashboardUrl("http://dashboard.example.com") .build(); assertThat(response.isAsync()).isEqualTo(true); assertThat(response.getOperation()).isEqualTo("in progress"); assertThat(response.isInstanceExisted()).isEqualTo(true); assertThat(response.getDashboardUrl()).isEqualTo("http://dashboard.example.com"); DocumentContext json = JsonUtils.toJsonPath(response); assertThat(json).hasPath("$.operation").isEqualTo("in progress"); assertThat(json).hasPath("$.dashboard_url").isEqualTo("http://dashboard.example.com"); }
CreateServiceInstanceResponse.builder() .async(false) .instanceExisted(false) .dashboardUrl("https://dashboard.example.com") .build(), CreateServiceInstanceResponse.builder() .async(false) .instanceExisted(true) .build(), HttpStatus.OK CreateServiceInstanceResponse.builder() .async(true) .instanceExisted(false) .operation("creating") .build(), CreateServiceInstanceResponse.builder() .async(true) .instanceExisted(true) .build(), HttpStatus.ACCEPTED
@Test public void createServiceInstanceWithExistingInstanceSucceeds() throws Exception { setupCatalogService(); setupServiceInstanceService(CreateServiceInstanceResponse.builder() .instanceExisted(true) .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().isOk()); }
@Test public void createServiceInstanceWithExistingInstanceSucceeds() { setupCatalogService(); setupServiceInstanceService(CreateServiceInstanceResponse.builder() .instanceExisted(true) .build()); client.put().uri(buildCreateUpdateUrl()) .contentType(MediaType.APPLICATION_JSON) .syncBody(createRequestBody) .accept(MediaType.APPLICATION_JSON) .exchange() .expectStatus().isOk(); }