### Question:
Graphite { public void setHost(String host) { this.host = host; }  boolean isEnabled(); Path getConfig(); void setConfig(Path config); String getHost(); void setHost(String host); String getPrefix(); void setPrefix(String prefix); String getNamespace(); void setNamespace(String namespace);  }### Answer:
@Test public void validHostAndPort() { graphite.setHost("foo.com:1234"); Set<ConstraintViolation<Graphite>> violations = validator.validate(graphite); assertThat(violations.size(), is(0)); }
@Test public void missingPort() { graphite.setHost("foo"); Set<ConstraintViolation<Graphite>> violations = validator.validate(graphite); assertThat(violations.size(), is(1)); }
@Test public void nullHost() { graphite.setHost(null); Set<ConstraintViolation<Graphite>> violations = validator.validate(graphite); assertThat(violations.size(), is(0)); }