@Test
public void writesMultivaluedMapToOutputStream() throws Exception {

    MultivaluedMap<String, String> multivaluedMap = new MultivaluedHashMap<>();
    multivaluedMap.put("bar", newArrayList("hello world"));
    multivaluedMap.put("foo", newArrayList("to be or not to be"));
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    multivaluedMapEntityProvider.writeTo(multivaluedMap, MultivaluedMap.class, multiValuedMapGenericType, null,
                                         APPLICATION_FORM_URLENCODED_TYPE, new MultivaluedHashMap<>(), out);
    assertEquals("bar=hello+world&foo=to+be+or+not+to+be", out.toString());
}