UrlEncoder { public String encodeQueryParam(@Nullable String content) { if (content == null) { return null; } return urlEncode(content, QUERY_SAFE, false, true); } UrlEncoder();  UrlEncoder(Charset charset); String encodeQueryParam(@Nullable String content); String urlEncodeUrl(@Nullable String content); String encodeFragment(@Nullable String content);  }
@Test public void testQueryParamEncode() { String url = "http: String result = new UrlEncoder().encodeQueryParam(url); assertEquals(result, "http%3A%2F%2Fopenecard.org%2F%3Fquery1%3Dfoo%26query2%3Dbar%20ui"); }
@Test public void testQueryParamEncodeNullValue() { String result = new UrlEncoder().encodeQueryParam(null); assertNull(result); }
@Test public void testQueryParamEncodeEmptyValue() { String result = new UrlEncoder().encodeQueryParam(""); assertEquals(result, ""); }