@Test
public void testWrite() throws
                        Exception {

    // given a pager metadata
    final Pager pager = new Pager(1234L);
    pager.setSize(5);
    pager.setPosition(3);
    pager.getHistory()
         .add(1);
    pager.getHistory()
         .add(4);
    pager.getHistory()
         .add(3);
    pager.getHistory()
         .add(2);
    // when write this pager as JSON string
    final StringWriter writer = new StringWriter();
    pagerJsonWriter.write(writer,
                          pager);
    // then
    assertNotNull(writer.toString());
    @SuppressWarnings("StringBufferReplaceableByString")
    final String expectedJsonString = new StringBuilder().append('{')
                                                         .append("\"id\":")
                                                         .append(1234L)
                                                         .append(",\"size\":")
                                                         .append(5)
                                                         .append(",\"position\":")
                                                         .append(3)
                                                         .append(",\"history\":[1,4,3,2]")
                                                         .append('}')
                                                         .toString();
    assertEquals(expectedJsonString,
                 writer.toString());
}