@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"); }
.async(true) .instanceExisted(false) .operation("creating") .build(), HttpStatus.ACCEPTED
@Test public void createServiceInstanceResponseShouldNotContainEmptyValuesWhenNull() throws Exception { setupCatalogService(); setupServiceInstanceService(CreateServiceInstanceResponse.builder() .operation(null) .dashboardUrl(null) .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()) .andExpect(jsonPath("$.dashboard_url").doesNotExist()) .andExpect(jsonPath("$.operation").doesNotExist()); }
@Test public void createServiceInstanceResponseShouldNotContainEmptyValuesWhenEmpty() throws Exception { setupCatalogService(); setupServiceInstanceService(CreateServiceInstanceResponse.builder() .operation("") .dashboardUrl("") .build()); client.put().uri(buildCreateUpdateUrl()) .contentType(MediaType.APPLICATION_JSON) .syncBody(createRequestBody) .accept(MediaType.APPLICATION_JSON) .exchange() .expectStatus().isCreated() .expectBody() .jsonPath("$.dashboard_url").doesNotExist() .jsonPath("$.operation").doesNotExist(); }
@Test public void createServiceInstanceResponseShouldNotContainEmptyValuesWhenNull() throws Exception { setupCatalogService(); setupServiceInstanceService(CreateServiceInstanceResponse.builder() .operation(null) .dashboardUrl(null) .build()); client.put().uri(buildCreateUpdateUrl()) .contentType(MediaType.APPLICATION_JSON) .syncBody(createRequestBody) .accept(MediaType.APPLICATION_JSON) .exchange() .expectStatus().isCreated() .expectBody() .jsonPath("$.dashboard_url").doesNotExist() .jsonPath("$.operation").doesNotExist(); }
@Test public void createServiceInstanceResponseShouldNotContainEmptyValuesWhenEmpty() throws Exception { setupCatalogService(); setupServiceInstanceService(CreateServiceInstanceResponse.builder() .operation("") .dashboardUrl("") .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()) .andExpect(jsonPath("$.dashboard_url").doesNotExist()) .andExpect(jsonPath("$.operation").doesNotExist()); }