CodecUtils { public static <T> String formEncode(T x) { return formEncode(x, "UTF-8"); }  static byte[] parseBytes(String encodedBytes); static String urlEncode(String unencoded); static String urlEncode(String unencoded, String encoding); static String urlDecode(String encoded); static String urlDecode(String encoded, String encoding); static String formEncode(T x); static String formEncode(T x, String encoding); static String formDecodeStr(String encoded); static String formDecodeStr(String encoded, String encoding); static Parameters formDecode(String encoded, String encoding); static MediaType parseMediaType(String typeStr); static String printMediaType(MediaType mediaType);  }
@Test public void formEncode() { Map<String, Object> m = new HashMap<>(); m.put("a", null); assertThat(CodecUtils.formEncode(m)).isEqualTo("a="); }
@Test public void formEncodeListParameter() { Map<String, Object> m = new HashMap<>(); m.put("a", Arrays.asList("1", "2", "3")); assertThat(CodecUtils.formEncode(m)).isEqualTo("a=1&a=2&a=3"); }
@Test public void formEncodeSetParameter() { Map<String, Object> m = new HashMap<>(); m.put("a", new TreeSet<>(Arrays.asList("1", "2", "3"))); assertThat(CodecUtils.formEncode(m)).isEqualTo("a=1&a=2&a=3"); }