()
| 41 | |
| 42 | // test getting and combining annotations |
| 43 | public void testAnnotationSetHandling() |
| 44 | throws InvalidOffsetException, ResourceInstantiationException { |
| 45 | // create a new document of 100 spaces |
| 46 | Document doc = Factory.newDocument(new String(new char[100]).replace("\0", " ")); |
| 47 | // get an annotation set for the first couple of tests |
| 48 | AnnotationSet set1 = doc.getAnnotations("s1"); |
| 49 | // add 3 coextensive annotations on top of each other |
| 50 | Annotation ann1_1 = set1.get(addAnn(set1,0,5,"t1.1",featureMap())); |
| 51 | Annotation ann1_2 = set1.get(addAnn(set1,0,5,"t1.2",featureMap())); |
| 52 | @SuppressWarnings("unused") |
| 53 | Annotation ann1_3 = set1.get(addAnn(set1,0,5,"t1.3",featureMap())); |
| 54 | // add 3 overlapping annotations |
| 55 | Annotation ann2_1 = set1.get(addAnn(set1,10,15,"t2.1",featureMap())); |
| 56 | @SuppressWarnings("unused") |
| 57 | Annotation ann2_2 = set1.get(addAnn(set1,11,16,"t2.2",featureMap())); |
| 58 | @SuppressWarnings("unused") |
| 59 | Annotation ann2_3 = set1.get(addAnn(set1,12,17,"t2.3",featureMap())); |
| 60 | |
| 61 | AnnotationSet ret = getCoextensiveAnnotations(set1,ann1_1); |
| 62 | assertEquals(3, ret.size()); |
| 63 | |
| 64 | ret = minus(ret,ann1_1); |
| 65 | assertEquals(2, ret.size()); |
| 66 | |
| 67 | ret = minus(ret,ann2_1); |
| 68 | assertEquals(2, ret.size()); |
| 69 | |
| 70 | ret = minus(ret); |
| 71 | assertEquals(2, ret.size()); |
| 72 | |
| 73 | ret = minus(ret,ann1_2); |
| 74 | assertEquals(1, ret.size()); |
| 75 | |
| 76 | ret = getOverlappingAnnotations(set1, ann2_1); |
| 77 | assertEquals(3, ret.size()); |
| 78 | |
| 79 | ret = plus(ret,ann1_2); |
| 80 | assertEquals(4, ret.size()); |
| 81 | |
| 82 | ret = intersect(getCoextensiveAnnotations(set1,ann1_1),ret); |
| 83 | assertEquals(1, ret.size()); |
| 84 | |
| 85 | ret = getAnnotationsEndingAtOffset(set1, 15L); |
| 86 | assertEquals(1, ret.size()); |
| 87 | assertEquals(15,ret.iterator().next().getEndNode().getOffset().longValue()); |
| 88 | |
| 89 | ret = getAnnotationsEndingAtOffset(set1, 5L); |
| 90 | assertEquals(3, ret.size()); |
| 91 | |
| 92 | } // testAnnotationSetHandling |
| 93 | } // class TestAnnotation |
| 94 |
nothing calls this directly
no test coverage detected