### Question:
ConnectionStringUtil { static String createConnectionString(MongoConfiguration configuration) { StringBuilder connectionStringBuilder = new StringBuilder(); connectionStringBuilder .append("mongodb: .append(buildCredentialsUriPartIfNeeded(configuration)) .append(configuration.getHosts()) .append("/") .append(configuration.getDatabase()); if (StringUtils.isNotBlank(configuration.getOptions())) { connectionStringBuilder.append("?").append(configuration.getOptions()); } return connectionStringBuilder.toString(); } private  ConnectionStringUtil();   }### Answer:
@Test public void buildConnectionStringWithOneHost() { MongoConfiguration mongoConfiguration = createValidConfiguration().setHosts("only.example.com"); String connectionString = createConnectionString(mongoConfiguration); assertThat(connectionString).isNotNull().contains("@only.example.com/"); }
@Test public void testUriBuilderUserPassword() { MongoConfiguration mongoConfiguration = createValidConfiguration(); String connectionString = createConnectionString(mongoConfiguration); assertThat(connectionString) .isNotNull() .isEqualTo( "mongodb: }
@Test public void testUriBuilderWithoutUserPassword() { MongoConfiguration mongoConfiguration = createValidConfiguration(); mongoConfiguration.setUsername(null); mongoConfiguration.setPassword(null); String connectionString = createConnectionString(mongoConfiguration); assertThat(connectionString) .isNotNull() .isEqualTo( "mongodb: }
@Test public void testUriBuilderWithoutOptions() { MongoConfiguration mongoConfiguration = createValidConfiguration(); mongoConfiguration.setOptions(null); String connectionString = createConnectionString(mongoConfiguration); assertThat(connectionString) .isNotNull() .isEqualTo("mongodb: }