ImmutableConnection implements Connection { @Override public String toString() { return getClass().getSimpleName() + " [" + "id=" + id + ", name=" + name + ", connectionType=" + connectionType + ", connectionStatus=" + connectionStatus + ", failoverEnabled=" + failOverEnabled + ", credentials=" + credentials + ", trustedCertificates=hash:" + Objects.hash(trustedCertificates) + ", uri=" + uri.getUriStringWithMaskedPassword() + ", sources=" + sources + ", targets=" + targets + ", clientCount=" + clientCount + ", validateCertificate=" + validateCertificate + ", processorPoolSize=" + processorPoolSize + ", specificConfig=" + specificConfig + ", payloadMappingDefinition=" + payloadMappingDefinition + ", tags=" + tags + ", lifecycle=" + lifecycle + "]"; } private  ImmutableConnection(final Builder builder); static ConnectionBuilder getBuilder(final ConnectionId id,
            final ConnectionType connectionType,
            final ConnectivityStatus connectionStatus,
            final String uri); static ConnectionBuilder getBuilder(final Connection connection); static Connection fromJson(final JsonObject jsonObject); @Override ConnectionId getId(); @Override Optional<String> getName(); @Override ConnectionType getConnectionType(); @Override ConnectivityStatus getConnectionStatus(); @Override List<Source> getSources(); @Override List<Target> getTargets(); @Override int getClientCount(); @Override boolean isFailoverEnabled(); @Override Optional<Credentials> getCredentials(); @Override Optional<String> getTrustedCertificates(); @Override String getUri(); @Override String getProtocol(); @Override Optional<String> getUsername(); @Override Optional<String> getPassword(); @Override String getHostname(); @Override int getPort(); @Override Optional<String> getPath(); @Override boolean isValidateCertificates(); @Override int getProcessorPoolSize(); @Override Map<String, String> getSpecificConfig(); @Override PayloadMappingDefinition getPayloadMappingDefinition(); @Override Set<String> getTags(); @Override Optional<ConnectionLifecycle> getLifecycle(); @Override JsonObject toJson(final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate); @SuppressWarnings("OverlyComplexMethod") @Override boolean equals(@Nullable final Object o); @Override int hashCode(); @Override String toString();  }
@Test public void toStringDoesNotContainPassword() { final String password = "thePassword"; final String uri = "amqps: final Connection connection = ConnectivityModelFactory.newConnectionBuilder(ID, TYPE, STATUS, uri) .sources(Collections.singletonList(SOURCE1)) .build(); assertThat(connection.toString()).doesNotContain(password); }