RetrieveConnectionStatusResponse extends AbstractCommandResponse<RetrieveConnectionStatusResponse> implements ConnectivityQueryCommandResponse<RetrieveConnectionStatusResponse> { public static Builder getBuilder(final ConnectionId connectionId, final DittoHeaders dittoHeaders) { return new Builder(connectionId, dittoHeaders); } private  RetrieveConnectionStatusResponse(final ConnectionId connectionId,
            final JsonObject jsonObject,
            final DittoHeaders dittoHeaders); static RetrieveConnectionStatusResponse of(final ConnectionId connectionId,
            final JsonObject jsonObject,
            final DittoHeaders dittoHeaders); static RetrieveConnectionStatusResponse closedResponse(final ConnectionId connectionId,
            final String address,
            final Instant connectionClosedAt,
            final ConnectivityStatus clientStatus,
            final String statusDetails,
            final DittoHeaders dittoHeaders); static RetrieveConnectionStatusResponse fromJson(final String jsonString, final DittoHeaders dittoHeaders); static RetrieveConnectionStatusResponse fromJson(final JsonObject jsonObject,
            final DittoHeaders dittoHeaders); ConnectivityStatus getConnectionStatus(); ConnectivityStatus getLiveStatus(); Optional<Instant> getConnectedSince(); List<ResourceStatus> getClientStatus(); List<ResourceStatus> getSourceStatus(); List<ResourceStatus> getTargetStatus(); @Override ConnectionId getConnectionEntityId(); @Override RetrieveConnectionStatusResponse setEntity(final JsonValue entity); @Override JsonValue getEntity(final JsonSchemaVersion schemaVersion); @Override JsonPointer getResourcePath(); @Override RetrieveConnectionStatusResponse setDittoHeaders(final DittoHeaders dittoHeaders); static Builder getBuilder(final ConnectionId connectionId, final DittoHeaders dittoHeaders); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); static final String TYPE; }
@Test public void retrieveInstanceWithNullConnectionId() { assertThatExceptionOfType(NullPointerException.class) .isThrownBy(() -> RetrieveConnectionStatusResponse.getBuilder(null, DittoHeaders.empty()) .connectionStatus(ConnectivityStatus.OPEN) .liveStatus(ConnectivityStatus.CLOSED) .connectedSince(IN_CONNECTION_STATUS_SINCE) .clientStatus(Collections.emptyList()) .sourceStatus(Collections.emptyList()) .targetStatus(Collections.emptyList()) .build()) .withMessage("The %s must not be null!", "Connection ID") .withNoCause(); }
@Test public void retrieveInstanceWithNullConnectionStatus() { assertThatExceptionOfType(NullPointerException.class) .isThrownBy(() -> RetrieveConnectionStatusResponse.getBuilder(TestConstants.ID, DittoHeaders.empty()) .connectionStatus(null) .liveStatus(ConnectivityStatus.CLOSED) .connectedSince(IN_CONNECTION_STATUS_SINCE) .clientStatus(Collections.emptyList()) .sourceStatus(Collections.emptyList()) .targetStatus(Collections.emptyList()) .build()) .withMessage("The %s must not be null!", "Connection Status") .withNoCause(); }
@Test public void retrieveInstanceWithNullLiveStatus() { assertThatExceptionOfType(NullPointerException.class) .isThrownBy(() -> RetrieveConnectionStatusResponse.getBuilder(TestConstants.ID, DittoHeaders.empty()) .connectionStatus(ConnectivityStatus.OPEN) .liveStatus(null) .connectedSince(IN_CONNECTION_STATUS_SINCE) .clientStatus(Collections.emptyList()) .sourceStatus(Collections.emptyList()) .targetStatus(Collections.emptyList()) .build()) .withMessage("The %s must not be null!", "Live Connection Status") .withNoCause(); }
@Test public void toJsonReturnsExpected() { final JsonObject actual = RetrieveConnectionStatusResponse.getBuilder(TestConstants.ID, DittoHeaders.empty()) .connectionStatus(ConnectivityStatus.OPEN) .liveStatus(ConnectivityStatus.CLOSED) .connectedSince(IN_CONNECTION_STATUS_SINCE) .clientStatus(clientStatus) .sourceStatus(sourceStatus) .targetStatus(targetStatus) .build() .toJson(); assertThat(actual).isEqualTo(KNOWN_JSON); }