### Question:
UrlHelper { public static String getDomain(String url, boolean includeProtocol, boolean includeSubdomain) { String result = ""; try { URL urlObj = new URL(url); String host = urlObj.getHost(); if (!host.isEmpty()) { if (includeProtocol) { result = urlObj.getProtocol() + ": } result += urlObj.getHost(); if (!includeSubdomain) { String suffix = ""; for (String domainSuffix : DOMAIN_SUFFIXES) { if (result.endsWith(domainSuffix)) { suffix = domainSuffix; break; } } result = result.substring(0, result.length() - suffix.length()); String[] parts = result.split("\\."); result = parts[parts.length - 1] + suffix; } LOGGER.trace("root url for {} -> {}", url, result); } else { LOGGER.trace("no domain specified {}", url); } } catch (MalformedURLException e) { LOGGER.trace("could not determine domain for {}", url); } return result; } private  UrlHelper(); static String removeSessionId(String originalUrl); static void makeAbsoluteUrls(Document document); static String getBaseUrl(Document document); static String makeFullUrl(String pageUrl, String baseUrl, String linkUrl); static String makeFullUrl(String contextUrl, String linkUrl); static String getCleanUrl(String url); static String removeAnchors(String url); static String getDomain(String url, boolean includeProtocol, boolean includeSubdomain); static String getDomain(String url, boolean includeProtocol); static String getDomain(String url); static String getCanonicalUrl(String url); static String decodeParameter(String string); static String encodeParameter(String string); static List<String> extractUrls(String text); static boolean isLocalFile(URL url); static String createParameterString(List<Pair<String, String>> parameters); static List<Pair<String, String>> parseParams(String parameterString); static String parseBaseUrl(String url); static boolean isValidUrl(String url); static final Pattern URL_PATTERN; }### Answer:
@Test public void testGetDomain() { collector.checkThat(UrlHelper.getDomain("https: collector.checkThat(UrlHelper.getDomain("http: collector.checkThat(UrlHelper.getDomain("https: collector.checkThat(UrlHelper.getDomain("https: collector.checkThat(UrlHelper.getDomain("http: collector.checkThat(UrlHelper.getDomain("http: collector.checkThat(UrlHelper.getDomain("http: collector.checkThat(UrlHelper.getDomain("http: collector.checkThat(UrlHelper.getDomain("http: collector.checkThat(UrlHelper.getDomain("http: collector.checkThat(UrlHelper.getDomain("http: assertEquals("http: UrlHelper.getDomain("http: assertEquals("www.flashdevices.net", UrlHelper.getDomain("http: assertEquals("http: UrlHelper.getDomain("http: assertEquals("blog.wired.com", UrlHelper.getDomain("http: assertEquals("https: assertEquals("", UrlHelper.getDomain("")); assertEquals("", UrlHelper.getDomain(null)); assertEquals("", UrlHelper.getDomain("file: assertEquals("localhost", UrlHelper.getDomain("file: }