@SuppressWarnings("unchecked")
@Test
public void testHistory() throws AnalysisEngineProcessException {
jCas.setDocumentText("Bill went to London. William came back.");
Person p = Annotations.createPerson(jCas, 0, 4, "Bill");
Person q = Annotations.createPerson(jCas, 21, 28, NAME_2);
DocumentHistory documentHistory =
history.getHistory("unknown:" + getDocumentAnnotation(jCas).getHash());
documentHistory.add(HistoryEvents.createAdded(p, "test"));
documentHistory.add(HistoryEvents.createAdded(q, "test"));
documentHistory.add(HistoryEvents.createMerged(p, "test", q.getInternalId()));
documentHistory.add(HistoryEvents.createMerged(p, "fakeId merge", 500));
documentHistory.add(HistoryEvents.createRemoved(q, "test"));
ae.process(jCas);
Collection<HistoryEvent> pHistory = documentHistory.getHistory(p.getInternalId());
Collection<HistoryEvent> qHistory = documentHistory.getHistory(q.getInternalId());
assertEquals(1, documents.count());
assertEquals(2, entities.count());
Document a = entities.find(new Document(Mongo.FIELD_ENTITIES + "." + VALUE, "Bill")).first();
List<Document> pH =
(List<Document>)
((List<Document>) a.get(Mongo.FIELD_ENTITIES)).get(0).get(fields.getHistory());
assertEquals(pHistory.size() + qHistory.size(), pH.size());
Document b = entities.find(new Document(Mongo.FIELD_ENTITIES + "." + VALUE, NAME_2)).first();
List<Document> qH =
(List<Document>)
((List<Document>) b.get(Mongo.FIELD_ENTITIES)).get(0).get(fields.getHistory());
assertEquals(qHistory.size(), qH.size());
}