### Question:
UriComponent { static Parameters decodeQuery(String query, boolean decode) { return decodeQuery(query, true, decode); } private  UriComponent();   }### Answer:
@Test public void noDecode() throws Exception { Parameters parameters = UriComponent.decodeQuery("a=" + URLEncoder.encode("1&b=2", US_ASCII.name()), false); assertThat(parameters.first("a").get(), is(URLEncoder.encode("1&b=2", US_ASCII.name()))); }
@Test public void yesDecode() throws Exception { Parameters parameters = UriComponent.decodeQuery("a=" + URLEncoder.encode("1&b=2", US_ASCII.name()), true); assertThat(parameters.first("a").get(), is("1&b=2")); }
@Test public void testNonExistingParam() throws Exception { Parameters parameters = UriComponent.decodeQuery("a=b", true); assertThat(parameters.first("c"), is(Optional.empty())); }
@Test public void sanityParse() throws Exception { Parameters parameters = UriComponent.decodeQuery(URI.create("http: assertThat(parameters.all("a"), hasItems(is("b"), is("e"))); assertThat(parameters.all("c"), hasItems(is("d"))); assertThat(parameters.all("z"), hasSize(0)); }