Pairs { public static EncodedPair toPair(String nameToEncode, String valueToEncode, Charset charset) throws UnsupportedEncodingException { return toPair(nameToEncode, valueToEncode, charset, false); } private  Pairs(); static EncodedPair toPreEncodedPair(String name, String value); static EncodedPair toPair(String nameToEncode, String valueToEncode, Charset charset); static EncodedPair toPair(String name, String value, Charset charset, boolean encoded); static List<EncodedPair> fromUrlEncoded(String urlEncoded); static List<EncodedPair> sortByNameAndValues(List<? extends EncodedPair> pairs); static String join(List<? extends EncodedPair> pairs, char pairSep); static String join(List<? extends EncodedPair> pairs, char pairSep, char nameValSep); static String join(List<? extends EncodedPair> pairs, char pairSep, char nameValSep, boolean quoteName, boolean quoteVal); static String join(Iterator<? extends EncodedPair> pairs, char pairSep); static String join(Iterator<? extends EncodedPair> pairs, char pairSep, char nameValSep); static String join(Iterator<? extends EncodedPair> pairs, char pairSep, char nameValSep, boolean quoteName, boolean quoteVal); static void join(Writer writer, List<? extends EncodedPair> pairs, char pairSep); static void join(Writer writer, List<? extends EncodedPair> pairs, char pairSep, char nameValSep); static void join(Writer writer, List<? extends EncodedPair> pairs, char pairSep, char nameValSep, boolean quoteName, boolean quoteVal); static void join(Writer writer, Iterator<? extends EncodedPair> pairs, char pairSep); static void join(Writer writer, Iterator<? extends EncodedPair> pairs, char pairSep, char nameValSep); static void join(Writer writer, Iterator<? extends EncodedPair> pairs, char pairSep, char nameValSep, boolean quoteName, boolean quoteVal);  }
@Test public void toPairDefaultToEncodedShouldEncodedAndBuildASimpleEncodedPairWithGivenParams() throws UnsupportedEncodingException { EncodedPair actual = Pairs.toPair("some name", "some value", UTF8); assertNotNull(actual); assertEquals(SimpleEncodedPair.class, actual.getClass()); assertEquals("some%20name", actual.getName()); assertEquals("some%20value", actual.getValue()); }
@Test public void toPairShouldEncodedAndBuildASimpleEncodedPairWithGivenParams() throws UnsupportedEncodingException { EncodedPair actual = Pairs.toPair("some name", "some value", UTF8, false); assertNotNull(actual); assertEquals(SimpleEncodedPair.class, actual.getClass()); assertEquals("some%20name", actual.getName()); assertEquals("some%20value", actual.getValue()); }
@Test public void toPairShouldNotEncodedAndBuildASimpleEncodedPairWithGivenParams() throws UnsupportedEncodingException { EncodedPair actual = Pairs.toPair("some name", "some value", UTF8, true); assertNotNull(actual); assertEquals(SimpleEncodedPair.class, actual.getClass()); assertEquals("some name", actual.getName()); assertEquals("some value", actual.getValue()); }