FormDataPayload implements Payload { public String getValue() { return value; } FormDataPayload(Map<String, List<String>> parameters);  FormDataPayload(List<QueryParam> parameters);  FormDataPayload(String formatted); MIMEType getMimeType(); InputStream getInputStream(); @Deprecated String getValues(); String getValue(); boolean isAvailable(); long length();  }
@Test public void testSimpleFormPayload() { List<QueryParam> parameters = new ArrayList<>(); parameters.add(new QueryParam("foo", "bar")); parameters.add(new QueryParam("bar", "foo")); FormDataPayload payload = new FormDataPayload(parameters); Assert.assertEquals("foo=bar&bar=foo",payload.getValue()); }
@Test public void testEscapedList() { List<QueryParam> parameters = new ArrayList<>(); parameters.add(new QueryParam("selected song", "hey jude")); parameters.add(new QueryParam("bar", "foo")); FormDataPayload payload = new FormDataPayload(parameters); Assert.assertEquals("selected+song=hey+jude&bar=foo",payload.getValue()); }
@Test public void testEscapedWithNewLines() { List<QueryParam> parameters = new ArrayList<>(); parameters.add(new QueryParam("lyrics", "Hello!\r\nIs there anybody out there?\r\nIs there anyone at home")); parameters.add(new QueryParam("bar", "foo")); FormDataPayload payload = new FormDataPayload(parameters); Assert.assertEquals("lyrics=Hello%21"+ newline + "Is+there+anybody+out+there%3F"+ newline +"Is+there+anyone+at+home&bar=foo", payload.getValue()); }