/** * Construct a {@link GetServiceInstanceResponse} from the provided values. * * @return the newly constructed {@literal GetServiceInstanceResponse} */ public GetServiceInstanceResponse build() { return new GetServiceInstanceResponse(serviceDefinitionId, planId, dashboardUrl, parameters); } }
@Override public final boolean equals(Object o) { if (this == o) return true; if (!(o instanceof GetServiceInstanceResponse)) return false; GetServiceInstanceResponse that = (GetServiceInstanceResponse) o; return that.canEqual(this) && Objects.equals(serviceDefinitionId, that.serviceDefinitionId) && Objects.equals(planId, that.planId) && Objects.equals(dashboardUrl, that.dashboardUrl) && Objects.equals(parameters, that.parameters); }
@Test public void responseWithAllValuesIsDeserialized() { GetServiceInstanceResponse response = JsonUtils.readTestDataFile( "getResponse.json", GetServiceInstanceResponse.class); assertThat(response.getServiceDefinitionId()).isEqualTo("service-definition-id"); assertThat(response.getPlanId()).isEqualTo("plan-id"); assertThat(response.getDashboardUrl()).isEqualTo("https://dashboard.local"); assertThat(response.getParameters()).containsOnly(entry("field1", "foo"), entry("field2", "bar")); }
@Override public Mono<GetServiceInstanceResponse> getServiceInstance(GetServiceInstanceRequest request) { String serviceInstanceId = request.getServiceInstanceId(); // // retrieve the details of the specified service instance // String dashboardUrl = new String(/* retrieve dashboard URL */); GetServiceInstanceResponse response = GetServiceInstanceResponse.builder() .dashboardUrl(dashboardUrl) .build(); return Mono.just(response); }
@Test public void responseWithDefaultsIsBuilt() { GetServiceInstanceResponse response = GetServiceInstanceResponse.builder() .build(); assertThat(response.getServiceDefinitionId()).isNull(); assertThat(response.getPlanId()).isNull(); assertThat(response.getDashboardUrl()).isNull(); assertThat(response.getParameters()).hasSize(0); DocumentContext json = JsonUtils.toJsonPath(response); assertThat(json).hasNoPath("$.service_id"); assertThat(json).hasNoPath("$.plan_id"); assertThat(json).hasNoPath("$.dashboard_url"); assertThat(json).hasMapAtPath("$.parameters").hasSize(0); }
@DataPoints("getResponsesWithExpectedStatus") public static List<GetResponseAndExpectedStatus> getDataPoints() { return Arrays.asList( new GetResponseAndExpectedStatus( null, HttpStatus.OK ), new GetResponseAndExpectedStatus( GetServiceInstanceResponse.builder() .serviceDefinitionId("service-definition-id") .planId("plan-id") .build(), HttpStatus.OK ) ); }
}}; GetServiceInstanceResponse response = GetServiceInstanceResponse.builder() .serviceDefinitionId("service-definition-id") .planId("plan-id") .build(); assertThat(response.getServiceDefinitionId()).isEqualTo("service-definition-id"); assertThat(response.getPlanId()).isEqualTo("plan-id"); assertThat(response.getDashboardUrl()).isEqualTo("https://dashboard.example.com"); assertThat(response.getParameters()).hasSize(5); assertThat(response.getParameters().get("field1")).isEqualTo("value1"); assertThat(response.getParameters().get("field2")).isEqualTo(2); assertThat(response.getParameters().get("field3")).isEqualTo(true); assertThat(response.getParameters().get("field4")).isEqualTo("value4"); assertThat(response.getParameters().get("field5")).isEqualTo("value5");
@Test public void getServiceInstanceSucceeds() throws Exception { setupServiceInstanceService(GetServiceInstanceResponse.builder() .build()); client.get().uri(buildCreateUpdateUrl(PLATFORM_INSTANCE_ID, false)) .header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION) .header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()) .accept(MediaType.APPLICATION_JSON) .exchange() .expectStatus().isOk(); GetServiceInstanceRequest actualRequest = verifyGetServiceInstance(); assertHeaderValuesSet(actualRequest); }
/** * Construct a {@link GetServiceInstanceResponse} from the provided values. * * @return the newly constructed {@literal GetServiceInstanceResponse} */ public GetServiceInstanceResponse build() { return new GetServiceInstanceResponse(serviceDefinitionId, planId, dashboardUrl, parameters); } }
@Override public final boolean equals(Object o) { if (this == o) return true; if (!(o instanceof GetServiceInstanceResponse)) return false; GetServiceInstanceResponse that = (GetServiceInstanceResponse) o; return that.canEqual(this) && Objects.equals(serviceDefinitionId, that.serviceDefinitionId) && Objects.equals(planId, that.planId) && Objects.equals(dashboardUrl, that.dashboardUrl) && Objects.equals(parameters, that.parameters); }
@Test public void getServiceInstanceSucceeds() throws Exception { setupServiceInstanceService(GetServiceInstanceResponse.builder() .build()); MvcResult mvcResult = mockMvc.perform(get(buildCreateUpdateUrl(PLATFORM_INSTANCE_ID, false)) .header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION) .header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()) .contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON)) .andExpect(request().asyncStarted()) .andReturn(); mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isOk()); GetServiceInstanceRequest actualRequest = verifyGetServiceInstance(); assertHeaderValuesSet(actualRequest); }