@Test
public void testJSONAnnotationStructure() throws Exception {

    Engine engine = GrobidFactory.getInstance().getEngine();
    File inputTmpFile = getInputDocument("/test/test_Grobid_1_05452615.pdf");
    Document tei = engine.fullTextToTEIDoc(inputTmpFile, GrobidAnalysisConfig.defaultInstance());
    String refURL = "http://example.com/xyz";
    List<String> refURLs = Arrays.asList(refURL);
    String json = CitationsVisualizer.getJsonAnnotations(tei, refURLs);
    JsonNode root = mapper.readTree(json);
    assertTrue(root.has("pages"));
    assertTrue(root.has("refBibs"));
    assertTrue(root.has("refMarkers"));
    JsonNode pages = root.get("pages");
    assertTrue(pages.isArray());
    assertEquals(tei.getPages().size(), pages.size());
    assertTrue(pages.size() > 0);
    JsonNode firstPage = pages.get(0);
    assertTrue(firstPage.has("page_height"));
    assertTrue(firstPage.has("page_width"));
    JsonNode bibs = root.get("refBibs");
    JsonNode firstBib = bibs.get(0);
    assertTrue(firstBib.has("id"));
    assertTrue(firstBib.has("url"));
    assertEquals(refURL, firstBib.get("url").asText());
    assertTrue(firstBib.has("pos"));
    JsonNode fbPos = firstBib.get("pos");
    assertTrue(fbPos.isArray());
    assertTrue(fbPos.size() > 0);
    for (JsonNode bbox : fbPos) {
        assertTrue(bbox.isObject());
        assertTrue(bbox.has("p"));
        assertTrue(bbox.has("x"));
        assertTrue(bbox.has("y"));
        assertTrue(bbox.has("w"));
        assertTrue(bbox.has("h"));
    }
    // XXX: this isn't working, not sure if it needs a different
    // test document or some extra processing step
    /*
    JsonNode markers = root.get("refMarkers");
    JsonNode firstMarker = markers.get(0);
    assertTrue(firstMarker.has("id"));
    assertTrue(firstMarker.has("p"));
    assertTrue(firstMarker.has("x"));
    assertTrue(firstMarker.has("y"));
    assertTrue(firstMarker.has("w"));
    assertTrue(firstMarker.has("h"));
    */
}