### Question:
FormatUtils { public static boolean isValidUrl(String url) { boolean hasValidProtocol; boolean hasValidHost; try { hasValidProtocol = isHttpsUrl(url) || url.startsWith(HTTP_PROTOCOL); URL wsdlUrl = new URL(url); String asciiHost = IDN.toASCII(wsdlUrl.getHost()); hasValidHost = asciiHost.matches(URL_HOST_REGEX); } catch (MalformedURLException | IllegalArgumentException e) { return false; } return hasValidProtocol && hasValidHost; } private  FormatUtils(); static OffsetDateTime fromDateToOffsetDateTime(Date date); static Date fromOffsetDateTimeToDate(OffsetDateTime offsetDateTime); static boolean isValidUrl(String url); static boolean isHttpsUrl(String url); static String getServiceFullName(ServiceType serviceType); static String getServiceFullName(WsdlParser.ServiceInfo serviceInfo); static Long parseLongIdOrThrowNotFound(String id); static int countOccurences(String from, char searched); static String xRoadIdToEncodedId(XRoadId xRoadId); static boolean isValidBackupFilename(String filename); static String encodeStringToBase64(String toBeEncoded); static final String HTTPS_PROTOCOL; static final String HTTP_PROTOCOL; static final String URL_HOST_REGEX; }### Answer:
@Test public void validHttpUrl() { assertTrue(FormatUtils.isValidUrl(VALID_HTTP_URL)); }
@Test public void validHttpsUrl() { assertTrue(FormatUtils.isValidUrl(VALID_HTTPS_URL)); }
@Test public void validNonAsciiUrl() { assertTrue(FormatUtils.isValidUrl(NON_ASCII_HOST)); }
@Test public void invalidUrlHost() { assertFalse(FormatUtils.isValidUrl(INVALID_HOST)); }
@Test public void invalidUrlProtocol() { assertFalse(FormatUtils.isValidUrl(INVALID_PROTOCOL)); }
@Test public void malformedUrlProtocol() { assertFalse(FormatUtils.isValidUrl(MALFORMED_PROTOCOL)); }