### Question:
URLEncodingUtilities { public static URL encodeURL(URL url) { URL encodedURL = null; if (url != null) { UrlBuilder builder = new UrlBuilder(url); builder.setQueryParameters(encodeQueryParameters(builder.getQueryParameters())); try { encodedURL = builder.toURL(); } catch (MalformedURLException e) { encodedURL = url; } } return encodedURL; } private  URLEncodingUtilities(); static URL encodeURL(URL url);  }### Answer:
@Test public void testEncodeURL() throws MalformedURLException { URL input = new URL("http: URL expected = new URL("http: URL actual = URLEncodingUtilities.encodeURL(input); Assert.assertEquals(expected.toString(), actual.toString()); }
@Test public void testEncodeURLNoQuery() throws MalformedURLException { URL input = new URL("http: URL actual = URLEncodingUtilities.encodeURL(input); Assert.assertEquals(input.toString(), actual.toString()); }
@Test public void testEncodeURLNull() { Assert.assertNull(URLEncodingUtilities.encodeURL(null)); }