UrlEncodedFormEntityParamExtractor implements EntityParamExtractor { public List<EncodedPair> extract(String contentType, Charset charset, InputStream entity) throws IOException { String formContent = IOs.toString(entity, charset); if(isNotBlank(formContent)) { return fromUrlEncoded(formContent); }else{ return emptyList(); } }  List<EncodedPair> extract(String contentType, Charset charset, InputStream entity);  }
@Test public void shouldReturnParsedPairsOutOfUrlEncodedEntity() throws IOException { InputStream stream = new ByteArrayInputStream(URL_ENCODED_FORM.getBytes()); List<EncodedPair> actual = toTest.extract(null, UTF8, stream); assertEquals(3, actual.size()); assertEquals("p1", actual.get(0).getName()); assertEquals("v%201", actual.get(0).getValue()); assertEquals("p1", actual.get(1).getName()); assertEquals("v%202", actual.get(1).getValue()); assertEquals("p3", actual.get(2).getName()); assertEquals("v3", actual.get(2).getValue()); }
@Test public void shouldReturnEmptyListForEmptyEntity() throws IOException { InputStream stream = new ByteArrayInputStream("".getBytes()); assertTrue(toTest.extract(null, UTF8, stream).isEmpty()); }