### Question:
HostNameVerifier implements Verifier<String> { @Override public VerifierResult verify(String hostName) { List<ValidationResult> validationResults = new ArrayList<ValidationResult>(); String hostNameRegex = "^(([a-zA-Z0-9\\*]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9])$"; try { Pattern p = Pattern.compile(hostNameRegex); Matcher m = p.matcher(hostName); boolean matchFound = m.matches(); if (matchFound) { return new VerifierResult(true); } else if (!matchFound) { validationResults.add(new ValidationResult(false, "Must provide a valid host name")); return new VerifierResult(false, validationResults); } } catch (PatternSyntaxException exception) { validationResults.add(new ValidationResult(false, "Must provide a valid host name")); return new VerifierResult(false, validationResults); } return new VerifierResult(true, validationResults); }  @Override VerifierResult verify(String hostName);  }### Answer:
@Test public void passCase1() { VerifierResult result = hostNameVerifier.verify("hostname.com"); Assert.assertTrue(result.passed()); }
@Test public void passCase2() { VerifierResult result = hostNameVerifier.verify("www.hostname.com"); Assert.assertTrue(result.passed()); }
@Test public void passCase3() { VerifierResult result = hostNameVerifier.verify("*.hostname.com"); Assert.assertTrue(result.passed()); }
@Test public void passCase4() { VerifierResult result = hostNameVerifier.verify("*.*.hostname.com"); Assert.assertTrue(result.passed()); }
@Test public void passCase5() { VerifierResult result = hostNameVerifier.verify("*.com"); Assert.assertTrue(result.passed()); }
@Test public void passCase6() { VerifierResult result = hostNameVerifier.verify("*.*.com"); Assert.assertTrue(result.passed()); }
@Test public void passCase7() { VerifierResult result = hostNameVerifier.verify("com"); Assert.assertTrue(result.passed()); }
@Test public void passCase8() { VerifierResult result = hostNameVerifier.verify("1.2.3.4"); Assert.assertTrue(result.passed()); }
@Test public void passCase9() { VerifierResult result = hostNameVerifier.verify("hostname1.com"); Assert.assertTrue(result.passed()); }
@Test public void passCase10() { VerifierResult result = hostNameVerifier.verify("host-name.com"); Assert.assertTrue(result.passed()); }
@Test public void failCase1() { VerifierResult result = hostNameVerifier.verify(""); Assert.assertFalse(result.passed()); }
@Test public void failCase2() { VerifierResult result = hostNameVerifier.verify("*"); Assert.assertFalse(result.passed()); }
@Test public void failCase3() { VerifierResult result = hostNameVerifier.verify("**"); Assert.assertFalse(result.passed()); }
@Test public void failCase5() { VerifierResult result = hostNameVerifier.verify("1.2.3.4:80"); Assert.assertFalse(result.passed()); }