@Test public void testRemoveAnnotationArray() { UimaSupport support = new UimaSupport(PIPELINE, UimaSupportTest.class, history, monitor, false); support.remove(location, md); assertEquals(0, JCasUtil.select(jCas, Location.class).size()); assertEquals(0, JCasUtil.select(jCas, Metadata.class).size()); // Location should not have history and id assertNotNull(location.getInternalId()); assertFalse(support.getDocumentHistory(jCas).getHistory(location.getInternalId()).isEmpty()); }
@Test public void testMergeWithNewAnnotationAnnotationArray() { UimaSupport support = new UimaSupport(PIPELINE, UimaSupportTest.class, history, monitor, false); Location l = new Location(jCas); l.setBegin(0); l.setEnd(0); Metadata md2 = new Metadata(jCas); md2.setBegin(0); md2.setEnd(0); support.mergeWithNew(l, location); support.mergeWithNew(md2, md); List<Location> locations = new ArrayList<>(JCasUtil.select(jCas, Location.class)); List<Metadata> mds = new ArrayList<>(JCasUtil.select(jCas, Metadata.class)); assertEquals(1, locations.size()); assertEquals(l, locations.get(0)); assertEquals(1, mds.size()); assertEquals(md2, mds.get(0)); assertFalse(support.getDocumentHistory(jCas).getHistory(l.getInternalId()).isEmpty()); }
@Test public void testMergeWithExistingAnnotationAnnotationArray() { UimaSupport support = new UimaSupport(PIPELINE, UimaSupportTest.class, history, monitor, false); Location l = new Location(jCas); l.setBegin(0); l.setEnd(0); l.addToIndexes(); Metadata md2 = new Metadata(jCas); md2.setBegin(0); md2.setEnd(0); md2.addToIndexes(); support.mergeWithExisting(l, location); support.mergeWithExisting(md2, md); List<Location> locations = new ArrayList<>(JCasUtil.select(jCas, Location.class)); List<Metadata> mds = new ArrayList<>(JCasUtil.select(jCas, Metadata.class)); assertEquals(1, locations.size()); assertEquals(l, locations.get(0)); assertEquals(1, mds.size()); assertEquals(md2, mds.get(0)); assertFalse(support.getDocumentHistory(jCas).getHistory(l.getInternalId()).isEmpty()); }
assertEquals(md2, mds.get(0)); assertTrue(support.getDocumentHistory(jCas).getHistory(locationRT1.getInternalId()).isEmpty()); assertFalse( support.getDocumentHistory(jCas).getHistory(locationRT2Again.getInternalId()).isEmpty());
support.getDocumentHistory(jCas).getHistory(locationRT2Again.getInternalId()).isEmpty());