/** * Construct a {@link GetServiceInstanceAppBindingResponse} from the provided values. * * @return the newly constructed {@literal GetServiceInstanceAppBindingResponse} */ public GetServiceInstanceAppBindingResponse build() { return new GetServiceInstanceAppBindingResponse(parameters, credentials, syslogDrainUrl, volumeMounts); } }
@Override public final boolean equals(Object o) { if (this == o) return true; if (!(o instanceof GetServiceInstanceAppBindingResponse)) return false; if (!super.equals(o)) return false; GetServiceInstanceAppBindingResponse that = (GetServiceInstanceAppBindingResponse) o; return that.canEqual(this) && Objects.equals(credentials, that.credentials) && Objects.equals(syslogDrainUrl, that.syslogDrainUrl) && Objects.equals(volumeMounts, that.volumeMounts); }
@Test public void responseWithValuesIsDeserialized() { GetServiceInstanceAppBindingResponse response = JsonUtils.readTestDataFile( "getAppBindingResponse.json", GetServiceInstanceAppBindingResponse.class); assertThat(response.getCredentials()).containsOnly(entry("cred1", "foo"), entry("cred2", "bar")); assertThat(response.getSyslogDrainUrl()).isEqualTo("https://logs.hello.local"); assertThat(response.getParameters()).containsOnly(entry("field1", "p1"), entry("field2", "p2")); assertThat(response.getVolumeMounts()).hasSize(1); VolumeMount volumeMount = response.getVolumeMounts().get(0); assertThat(volumeMount.getDriver()).isEqualTo("driver-1"); assertThat(volumeMount.getContainerDir()).isEqualTo("container-dir-1"); assertThat(volumeMount.getMode()).isEqualTo(VolumeMount.Mode.READ_ONLY); assertThat(volumeMount.getDeviceType()).isEqualTo(VolumeMount.DeviceType.SHARED); SharedVolumeDevice sharedVolumeDevice = ((SharedVolumeDevice)volumeMount.getDevice()); assertThat(sharedVolumeDevice.getVolumeId()).isEqualTo("volume-id"); assertThat(sharedVolumeDevice.getMountConfig()) .containsOnly(entry("field1", "mount-config-1"), entry("field2", "mount-config-2")); }
@Override public Mono<GetServiceInstanceBindingResponse> getServiceInstanceBinding(GetServiceInstanceBindingRequest request) { if (request.getBindingId() == null) { return Mono.error(new ServiceInstanceDoesNotExistException("foo")); } return Mono.just(GetServiceInstanceAppBindingResponse.builder().build()); }
@Test public void responseWithDefaultsIsBuilt() { GetServiceInstanceAppBindingResponse response = GetServiceInstanceAppBindingResponse.builder() .build(); assertThat(response.getParameters()).hasSize(0); assertThat(response.getCredentials()).hasSize(0); assertThat(response.getSyslogDrainUrl()).isNull(); assertThat(response.getVolumeMounts()).hasSize(0); DocumentContext json = JsonUtils.toJsonPath(response); assertThat(json).hasNoPath("$.parameters"); assertThat(json).hasNoPath("$.credentials"); assertThat(json).hasNoPath("$.syslog_drain_url"); assertThat(json).hasNoPath("$.volume_mounts"); }
@DataPoints("getResponsesWithExpectedStatus") public static List<GetResponseAndExpectedStatus> getDataPoints() { return Arrays.asList( new GetResponseAndExpectedStatus( null, HttpStatus.OK ), new GetResponseAndExpectedStatus( GetServiceInstanceAppBindingResponse.builder() .build(), HttpStatus.OK ) ); }
); GetServiceInstanceAppBindingResponse response = GetServiceInstanceAppBindingResponse.builder() .parameters("field1", "value1") .parameters("field2", 2) .build(); 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"); assertThat(response.getCredentials()).hasSize(5); assertThat(response.getCredentials().get("credential1")).isEqualTo("value1"); assertThat(response.getCredentials().get("credential2")).isEqualTo(2); assertThat(response.getCredentials().get("credential3")).isEqualTo(true); assertThat(response.getCredentials().get("credential4")).isEqualTo("value4"); assertThat(response.getCredentials().get("credential5")).isEqualTo("value5"); assertThat(response.getSyslogDrainUrl()).isEqualTo("https://logs.example.com"); assertThat(response.getVolumeMounts()).hasSize(4);
@Override public Mono<GetServiceInstanceBindingResponse> getServiceInstanceBinding(GetServiceInstanceBindingRequest request) { String serviceInstanceId = request.getServiceInstanceId(); String bindingId = request.getBindingId(); // // retrieve the details of the specified service binding // String url = new String(/* retrieved URL */); String bindingUsername = new String(/* retrieved user */); String bindingPassword = new String(/* retrieved password */); GetServiceInstanceBindingResponse response = GetServiceInstanceAppBindingResponse.builder() .credentials("username", bindingUsername) .credentials("password", bindingPassword) .credentials("url", url) .build(); return Mono.just(response); } }
/** * Construct a {@link GetServiceInstanceAppBindingResponse} from the provided values. * * @return the newly constructed {@literal GetServiceInstanceAppBindingResponse} */ public GetServiceInstanceAppBindingResponse build() { return new GetServiceInstanceAppBindingResponse(parameters, credentials, syslogDrainUrl, volumeMounts); } }
@Override public final boolean equals(Object o) { if (this == o) return true; if (!(o instanceof GetServiceInstanceAppBindingResponse)) return false; if (!super.equals(o)) return false; GetServiceInstanceAppBindingResponse that = (GetServiceInstanceAppBindingResponse) o; return that.canEqual(this) && Objects.equals(credentials, that.credentials) && Objects.equals(syslogDrainUrl, that.syslogDrainUrl) && Objects.equals(volumeMounts, that.volumeMounts); }
@Test public void getServiceInstanceBinding() { StepVerifier .create(serviceInstanceBindingEventService.getServiceInstanceBinding( GetServiceInstanceBindingRequest.builder() .serviceInstanceId("foo") .bindingId("bar") .build())) .expectNext(GetServiceInstanceAppBindingResponse.builder().build()) .verifyComplete(); }
@Test public void getBindingToAppSucceeds() throws Exception { setupServiceInstanceBindingService(GetServiceInstanceAppBindingResponse.builder() .build()); client.get().uri(buildCreateUrl(PLATFORM_INSTANCE_ID, false)) .header(API_INFO_LOCATION_HEADER, API_INFO_LOCATION) .header(ORIGINATING_IDENTITY_HEADER, buildOriginatingIdentityHeader()) .accept(MediaType.APPLICATION_JSON) .exchange() .expectStatus().isOk(); GetServiceInstanceBindingRequest actualRequest = verifyGetBinding(); assertHeaderValuesSet(actualRequest); }
@Test public void getBindingToAppSucceeds() throws Exception { setupServiceInstanceBindingService(GetServiceInstanceAppBindingResponse.builder() .build()); MvcResult mvcResult = mockMvc.perform(get(buildCreateUrl(PLATFORM_INSTANCE_ID, false)) .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().isOk()); GetServiceInstanceBindingRequest actualRequest = verifyGetBinding(); assertHeaderValuesSet(actualRequest); }