public AnnotationIntervalImpl(AnnotationInterval<V> other) { this(other.start(), other.end(), CollectionUtils.copyStringMap(other.annotations()), CollectionUtils.copyStringMap(other.diffFromLeft())); }
protected static <V> void expectIntervals(Iterable<AnnotationInterval<V>> iterable, List<AnnotationInterval<V>> expectedIntervals) { List<AnnotationInterval<V>> actualIntervals = new ArrayList<AnnotationInterval<V>>(); for (AnnotationInterval<V> i : iterable) { actualIntervals.add(new AnnotationIntervalImpl<V>(i)); } assertEquals("Number of intervals", expectedIntervals.size(), actualIntervals.size()); for (int i = 0; i < expectedIntervals.size(); i++) { AnnotationInterval<V> expected = expectedIntervals.get(i); AnnotationInterval<V> actual = actualIntervals.get(i); assertEquals("Start of interval " + i, expected.start(), actual.start()); assertEquals("End of interval " + i, expected.end(), actual.end()); assertMapsEqual(expected.annotations(), actual.annotations()); assertMapsEqual(expected.diffFromLeft(), actual.diffFromLeft()); } }
protected static <V> void expectIntervals(Iterable<AnnotationInterval<V>> iterable, List<AnnotationInterval<V>> expectedIntervals) { List<AnnotationInterval<V>> actualIntervals = new ArrayList<AnnotationInterval<V>>(); for (AnnotationInterval<V> i : iterable) { actualIntervals.add(new AnnotationIntervalImpl<V>(i)); } assertEquals("Number of intervals", expectedIntervals.size(), actualIntervals.size()); for (int i = 0; i < expectedIntervals.size(); i++) { AnnotationInterval<V> expected = expectedIntervals.get(i); AnnotationInterval<V> actual = actualIntervals.get(i); assertEquals("Start of interval " + i, expected.start(), actual.start()); assertEquals("End of interval " + i, expected.end(), actual.end()); assertMapsEqual(expected.annotations(), actual.annotations()); assertMapsEqual(expected.diffFromLeft(), actual.diffFromLeft()); } }
public void testIntervalIterator2() { RawAnnotationSet<Object> m = getNew(); m.begin(); m.startAnnotation("a", "1"); m.insert(1); m.endAnnotation("a"); m.insert(1); m.finish(); IntervalCallback c = mock(IntervalCallback.class); for (AnnotationInterval<Object> i : m.annotationIntervals(0, m.size(), null)) { c.apply(i.start(), i.end(), CollectionUtils.newJavaMap(i.annotations()), CollectionUtils.newJavaMap(i.diffFromLeft())); } verify(c).apply(0, 1, Collections.<String, Object>singletonMap("a", "1"), Collections.<String, Object>singletonMap("a", "1")); verify(c).apply(1, 2, Collections.<String, Object>singletonMap("a", null), Collections.<String, Object>singletonMap("a", null)); } //
public void testIntervalIterator2() { RawAnnotationSet<Object> m = getNew(); m.begin(); m.startAnnotation("a", "1"); m.insert(1); m.endAnnotation("a"); m.insert(1); m.finish(); IntervalCallback c = mock(IntervalCallback.class); for (AnnotationInterval<Object> i : m.annotationIntervals(0, m.size(), null)) { c.apply(i.start(), i.end(), CollectionUtils.newJavaMap(i.annotations()), CollectionUtils.newJavaMap(i.diffFromLeft())); } verify(c).apply(0, 1, Collections.<String, Object>singletonMap("a", "1"), Collections.<String, Object>singletonMap("a", "1")); verify(c).apply(1, 2, Collections.<String, Object>singletonMap("a", null), Collections.<String, Object>singletonMap("a", null)); } //
public void testIntervalIterator() { // IndexedDocumentImplTest contains some more tests that also exercise the // iterator methods of AnnotationTree. RawAnnotationSet<Object> m = getNew(); m.begin(); m.startAnnotation("a", "1"); m.insert(1); m.endAnnotation("a"); m.finish(); IntervalCallback c = mock(IntervalCallback.class); for (AnnotationInterval<Object> i : m.annotationIntervals(0, m.size(), null)) { c.apply(i.start(), i.end(), CollectionUtils.newJavaMap(i.annotations()), CollectionUtils.newJavaMap(i.diffFromLeft())); } verify(c).apply(0, 1, Collections.<String, Object>singletonMap("a", "1"), Collections.<String, Object>singletonMap("a", "1")); }
public void testIntervalIterator() { // IndexedDocumentImplTest contains some more tests that also exercise the // iterator methods of AnnotationTree. RawAnnotationSet<Object> m = getNew(); m.begin(); m.startAnnotation("a", "1"); m.insert(1); m.endAnnotation("a"); m.finish(); IntervalCallback c = mock(IntervalCallback.class); for (AnnotationInterval<Object> i : m.annotationIntervals(0, m.size(), null)) { c.apply(i.start(), i.end(), CollectionUtils.newJavaMap(i.annotations()), CollectionUtils.newJavaMap(i.diffFromLeft())); } verify(c).apply(0, 1, Collections.<String, Object>singletonMap("a", "1"), Collections.<String, Object>singletonMap("a", "1")); }
i.diffFromLeft().each(new ProcV<Object>() { @Override public void apply(String key, Object value) {
assertEquals(1, CollectionUtils.newJavaMap(i.annotations()).size()); assertEquals("1", i.annotations().get("a", "x")); assertEquals(0, CollectionUtils.newJavaMap(i.diffFromLeft()).size()); assertEquals("x", i.diffFromLeft().get("a", "x")); assertEquals(1, CollectionUtils.newJavaMap(i.annotations()).size()); assertEquals("2", i.annotations().get("a", "x")); assertEquals(1, CollectionUtils.newJavaMap(i.diffFromLeft()).size()); assertEquals("2", i.diffFromLeft().get("a", "x")); assertEquals(1, CollectionUtils.newJavaMap(i.annotations()).size()); assertEquals(null, i.annotations().get("a", "x")); assertEquals(1, CollectionUtils.newJavaMap(i.diffFromLeft()).size()); assertEquals(null, i.diffFromLeft().get("a", "x")); assertEquals(null, i.annotations().get("b", "x")); assertEquals("1", i.annotations().get("c", "x")); assertEquals(0, CollectionUtils.newJavaMap(i.diffFromLeft()).size()); assertEquals("x", i.diffFromLeft().get("a", "x")); assertEquals("x", i.diffFromLeft().get("b", "x")); assertEquals("x", i.diffFromLeft().get("c", "x")); assertEquals("1", i.annotations().get("b", "x")); assertEquals("1", i.annotations().get("c", "x")); assertEquals(1, CollectionUtils.newJavaMap(i.diffFromLeft()).size()); assertEquals("x", i.diffFromLeft().get("a", "x")); assertEquals("1", i.diffFromLeft().get("b", "x")); assertEquals("x", i.diffFromLeft().get("c", "x"));
assertEquals(1, CollectionUtils.newJavaMap(i.annotations()).size()); assertEquals("1", i.annotations().get("a", "x")); assertEquals(0, CollectionUtils.newJavaMap(i.diffFromLeft()).size()); assertEquals("x", i.diffFromLeft().get("a", "x")); assertEquals(1, CollectionUtils.newJavaMap(i.annotations()).size()); assertEquals("2", i.annotations().get("a", "x")); assertEquals(1, CollectionUtils.newJavaMap(i.diffFromLeft()).size()); assertEquals("2", i.diffFromLeft().get("a", "x")); assertEquals(1, CollectionUtils.newJavaMap(i.annotations()).size()); assertEquals(null, i.annotations().get("a", "x")); assertEquals(1, CollectionUtils.newJavaMap(i.diffFromLeft()).size()); assertEquals(null, i.diffFromLeft().get("a", "x")); assertEquals(null, i.annotations().get("b", "x")); assertEquals("1", i.annotations().get("c", "x")); assertEquals(0, CollectionUtils.newJavaMap(i.diffFromLeft()).size()); assertEquals("x", i.diffFromLeft().get("a", "x")); assertEquals("x", i.diffFromLeft().get("b", "x")); assertEquals("x", i.diffFromLeft().get("c", "x")); assertEquals("1", i.annotations().get("b", "x")); assertEquals("1", i.annotations().get("c", "x")); assertEquals(1, CollectionUtils.newJavaMap(i.diffFromLeft()).size()); assertEquals("x", i.diffFromLeft().get("a", "x")); assertEquals("1", i.diffFromLeft().get("b", "x")); assertEquals("x", i.diffFromLeft().get("c", "x"));
for (AnnotationInterval<String> interval : // update along the way doc.annotationIntervals(removeStart, removeEnd, null)) { interval.diffFromLeft().each(new ProcV<Object>() { @Override public void apply(String key, Object value) { assert value == null || value instanceof String;