RedisHost { @Override public String toString() { return port == DEFAULT_PORT ? host : host + ':' + port; } RedisHost(String host); @Override String toString(); final String host; final int port; }
@Test void convertToString() { assertThat(new RedisHost("redis-1").toString()).isEqualTo("redis-1"); assertThat(new RedisHost("redis-2:6379").toString()).isEqualTo("redis-2"); assertThat(new RedisHost("redis-3:1999").toString()).isEqualTo("redis-3:1999"); }