### Question:
DomainUtils { public static boolean isBaseDomain(String baseDomain, String url) { try { baseDomain = StringUtils.lowerCase(StringUtils.trim(baseDomain)); String domain = StringUtils.lowerCase(StringUtils.trimToNull(new URI(url).getHost())); if (domain == null) { logger.info("Returning false because url's domain is null"); return false; } while (StringUtils.isNotBlank(domain)) { if (StringUtils.equals(baseDomain, domain)) { return true; } domain = StringUtils.substringAfter(domain, "."); } return false; } catch (URISyntaxException ex) { logger.error("Could not determine base domain relationship. Returning default of false.", ex); return false; } }  static boolean isBaseDomain(String baseDomain, String url);  }### Answer:
@Test public void isBaseDomain_isBaseDomain_returnsTrue() { String baseDomain = "xoxide.com"; String url = "http: boolean result = DomainUtils.isBaseDomain(baseDomain, url); assertTrue(result); }
@Test public void isBaseDomain_wrongDomain_returnsFalse() { String baseDomain = "xoxide.com"; String url = "http: boolean result = DomainUtils.isBaseDomain(baseDomain, url); assertFalse(result); }
@Test public void isBaseDomain_noDomain_returnsFalse() { String baseDomain = "xoxide.com"; String url = "/powersupplies.html"; boolean result = DomainUtils.isBaseDomain(baseDomain, url); assertFalse(result); }
@Test public void isBaseDomain_badUrl_returnsFalse() { String baseDomain = "xoxide.com"; String url = "hfn:/fdbsdb nl]kmnasdbfnjvah7sg967*&06r5*E$^%&^*&(*ymhvi"; boolean result = DomainUtils.isBaseDomain(baseDomain, url); assertFalse(result); }