protected void checkAdvance(AnnotationCursor cursor, int location, String ... keys) { assertTrue(cursor.hasNext()); assertEquals( CollectionUtils.newJavaSet(strs(keys)), CollectionUtils.newJavaSet(cursor.nextLocation())); assertEquals(location, cursor.currentLocation()); }
protected void expectFinished(AnnotationCursor cursor) { assertFalse(cursor.hasNext()); try { cursor.nextLocation(); fail("Expected NoSuchElementException"); } catch (NoSuchElementException e) { // OK } }
public void testChange() { RawAnnotationSet<Object> m = fancySet(); AnnotationCursor c1 = m.annotationCursor(i, 100 - i, strs("a")); AnnotationCursor c2 = m.annotationCursor(i, 100 - i, strs("a", "b")); AnnotationCursor c3 = m.annotationCursor(i, 100 - i, strs("a", "b", "c")); AnnotationCursor c4 = m.annotationCursor(i, 100 - i, strs("c", "d")); AnnotationCursor ca = m.annotationCursor(i, 100 - i, strs("a", "b", "c", "d")); AnnotationCursor cx = m.annotationCursor(i, 100 - i, strs("x", "y", "z")); expectFinished(cx); checkAdvance(c1, 10, "a"); checkAdvance(c1, 30, "a"); checkAdvance(c1, 60, "a"); expectFinished(c1); checkAdvance(c2, 10, "a"); checkAdvance(c2, 20, "b"); checkAdvance(c2, 30, "a"); checkAdvance(c2, 40, "b"); checkAdvance(c2, 50, "b"); checkAdvance(c2, 60, "a"); expectFinished(c2); checkAdvance(c3, 10, "a"); checkAdvance(c3, 20, "b"); checkAdvance(c3, 30, "a", "c"); checkAdvance(c3, 40, "b", "c"); checkAdvance(c3, 50, "b");
public void testNoChange() { RawAnnotationSet<Object> m = getNewSet(); m.finish(); expectFinished(m.annotationCursor(40, 60, strs())); expectFinished(m.annotationCursor(40, 60, strs("a", "b"))); expectFinished(m.annotationCursor(0, 100, strs())); expectFinished(m.annotationCursor(0, 100, strs("a", "b"))); m.finish(); expectFinished(m.annotationCursor(40, 60, strs())); expectFinished(m.annotationCursor(40, 60, strs("a"))); expectFinished(m.annotationCursor(40, 60, strs("a", "b"))); m.finish(); expectFinished(m.annotationCursor(40, 60, strs())); expectFinished(m.annotationCursor(40, 60, strs("a"))); expectFinished(m.annotationCursor(40, 60, strs("a", "b"))); expectFinished(m.annotationCursor(40, 60, strs("a", "b", "c"))); m.finish(); expectFinished(m.annotationCursor(40, 60, strs())); expectFinished(m.annotationCursor(40, 60, strs("a"))); expectFinished(m.annotationCursor(40, 60, strs("a", "b"))); expectFinished(m.annotationCursor(40, 60, strs("a", "b", "c")));
public void testInitialStartLocation() { RawAnnotationSet<Object> m = getNewSet(); m.begin(); m.insert(100); m.finish(); // -1 if no hasNext() AnnotationCursor c = m.annotationCursor(40, 80, strs("a")); assertEquals(-1, c.currentLocation()); m.begin(); m.skip(50); m.startAnnotation("a", "1"); m.skip(10); m.endAnnotation("a"); m.finish(); // start value, if hasNext(); c = m.annotationCursor(40, 80, strs("a")); assertEquals(40, c.currentLocation()); }
protected RawAnnotationSet<Object> fancySet() { RawAnnotationSet<Object> m = getNewSet(); m.begin(); m.insert(100); m.finish(); m.begin(); m.skip(10); m.startAnnotation("a", "1"); m.skip(10); m.startAnnotation("b", "2"); m.skip(10); m.startAnnotation("c", "3"); m.startAnnotation("a", "3"); m.startAnnotation("d", "3"); m.skip(10); m.endAnnotation("c"); m.endAnnotation("d"); m.startAnnotation("b", "4"); m.skip(10); m.endAnnotation("b"); m.skip(10); m.endAnnotation("a"); m.finish(); return m; }
public void testNoChange() { RawAnnotationSet<Object> m = getNewSet(); m.finish(); expectFinished(m.annotationCursor(40, 60, strs())); expectFinished(m.annotationCursor(40, 60, strs("a", "b"))); expectFinished(m.annotationCursor(0, 100, strs())); expectFinished(m.annotationCursor(0, 100, strs("a", "b"))); m.finish(); expectFinished(m.annotationCursor(40, 60, strs())); expectFinished(m.annotationCursor(40, 60, strs("a"))); expectFinished(m.annotationCursor(40, 60, strs("a", "b"))); m.finish(); expectFinished(m.annotationCursor(40, 60, strs())); expectFinished(m.annotationCursor(40, 60, strs("a"))); expectFinished(m.annotationCursor(40, 60, strs("a", "b"))); expectFinished(m.annotationCursor(40, 60, strs("a", "b", "c"))); m.finish(); expectFinished(m.annotationCursor(40, 60, strs())); expectFinished(m.annotationCursor(40, 60, strs("a"))); expectFinished(m.annotationCursor(40, 60, strs("a", "b"))); expectFinished(m.annotationCursor(40, 60, strs("a", "b", "c")));
public void testInitialStartLocation() { RawAnnotationSet<Object> m = getNewSet(); m.begin(); m.insert(100); m.finish(); // -1 if no hasNext() AnnotationCursor c = m.annotationCursor(40, 80, strs("a")); assertEquals(-1, c.currentLocation()); m.begin(); m.skip(50); m.startAnnotation("a", "1"); m.skip(10); m.endAnnotation("a"); m.finish(); // start value, if hasNext(); c = m.annotationCursor(40, 80, strs("a")); assertEquals(40, c.currentLocation()); }
protected RawAnnotationSet<Object> fancySet() { RawAnnotationSet<Object> m = getNewSet(); m.begin(); m.insert(100); m.finish(); m.begin(); m.skip(10); m.startAnnotation("a", "1"); m.skip(10); m.startAnnotation("b", "2"); m.skip(10); m.startAnnotation("c", "3"); m.startAnnotation("a", "3"); m.startAnnotation("d", "3"); m.skip(10); m.endAnnotation("c"); m.endAnnotation("d"); m.startAnnotation("b", "4"); m.skip(10); m.endAnnotation("b"); m.skip(10); m.endAnnotation("a"); m.finish(); return m; }
public void testEmptySet() { RawAnnotationSet<Object> m = getNewSet(); m.begin(); m.insert(1); m.startAnnotation("a", "1"); m.insert(1); m.endAnnotation("a"); m.finish(); expectFinished(m.annotationCursor(0, m.size(), strs())); } }
public void testChange() { RawAnnotationSet<Object> m = fancySet(); AnnotationCursor c1 = m.annotationCursor(i, 100 - i, strs("a")); AnnotationCursor c2 = m.annotationCursor(i, 100 - i, strs("a", "b")); AnnotationCursor c3 = m.annotationCursor(i, 100 - i, strs("a", "b", "c")); AnnotationCursor c4 = m.annotationCursor(i, 100 - i, strs("c", "d")); AnnotationCursor ca = m.annotationCursor(i, 100 - i, strs("a", "b", "c", "d")); AnnotationCursor cx = m.annotationCursor(i, 100 - i, strs("x", "y", "z")); expectFinished(cx); checkAdvance(c1, 10, "a"); checkAdvance(c1, 30, "a"); checkAdvance(c1, 60, "a"); expectFinished(c1); checkAdvance(c2, 10, "a"); checkAdvance(c2, 20, "b"); checkAdvance(c2, 30, "a"); checkAdvance(c2, 40, "b"); checkAdvance(c2, 50, "b"); checkAdvance(c2, 60, "a"); expectFinished(c2); checkAdvance(c3, 10, "a"); checkAdvance(c3, 20, "b"); checkAdvance(c3, 30, "a", "c"); checkAdvance(c3, 40, "b", "c"); checkAdvance(c3, 50, "b");
protected void checkAdvance(AnnotationCursor cursor, int location, String ... keys) { assertTrue(cursor.hasNext()); assertEquals( CollectionUtils.newJavaSet(strs(keys)), CollectionUtils.newJavaSet(cursor.nextLocation())); assertEquals(location, cursor.currentLocation()); }
protected void expectFinished(AnnotationCursor cursor) { assertFalse(cursor.hasNext()); try { cursor.nextLocation(); fail("Expected NoSuchElementException"); } catch (NoSuchElementException e) { // OK } }
public void testEmptySet() { RawAnnotationSet<Object> m = getNewSet(); m.begin(); m.insert(1); m.startAnnotation("a", "1"); m.insert(1); m.endAnnotation("a"); m.finish(); expectFinished(m.annotationCursor(0, m.size(), strs())); } }