@Test
public void writesMapStringToObjectToOutputStream() throws Exception {

    Map<String, Book> books = ImmutableMap.of("1", createJunitBook());
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    jsonEntityProvider.writeTo(books, Map.class, newParameterizedType(Map.class, String.class, Book.class), null, APPLICATION_JSON_TYPE,
                               new MultivaluedHashMap<>(), out);
    String outputAsString = out.toString();
    assertTrue(outputAsString.startsWith("{\"1\":{"));
    assertTrue(outputAsString.endsWith("}"));
    assertTrue(outputAsString.contains("\"author\":\"Vincent Massol\""));
    assertTrue(outputAsString.contains("\"title\":\"JUnit in Action\""));
    assertTrue(outputAsString.contains("\"pages\":386"));
    assertTrue(outputAsString.contains("\"price\":19.37"));
    assertTrue(outputAsString.contains("\"isdn\":93011099534534"));
}