### Question:
UrlUtils { public static String getEncodedUrl(String url) { if (url != null) { return url.replaceAll("\\W", "-"); } else { return RandomStringUtils.randomAlphanumeric(10); } }  static String trimSlashes(String string); static String getEncodedUrl(String url); static String removeFirstAndLastSlash(String uri); static String addFirstSlash(String uri); static String removeLastSlash(String uri); static String getHostIPAddress(String fqdn); static String getIpAddressFromUrl(String urlString);  }### Answer:
@Test public void getEncodedUrlTest() { assertEquals("api-v1", UrlUtils.getEncodedUrl("api/v1")); assertEquals("-api-v1", UrlUtils.getEncodedUrl("/api/v1")); assertEquals("-api-v1-", UrlUtils.getEncodedUrl("/api/v1/")); assertNotNull(UrlUtils.getEncodedUrl(null)); }