select.coveredBy with includeAnnotationsWithEndBeyondBounds has broken edge case
Added unit test illustrating the problem and currently failing
package org.apache.uima.cas.impl;
+import static java.util.stream.Collectors.toList;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.File;
-import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.apache.uima.UIMAFramework;
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.text.AnnotationFS;
import org.apache.uima.jcas.JCas;
import org.apache.uima.jcas.tcas.Annotation;
import org.apache.uima.resource.metadata.TypeSystemDescription;
@@ -226,7 +229,22 @@ public class SelectFsTest {
prec2 = jCas.select(Token.class).between(b, e).backwards().asList();
assertEquals(Arrays.asList(d, c), prec2);
+ }
+
+ @Test
+ public void thatCoveredByWithBeyondEndsCanSelectAnnotationsStartingAtSelectPosition() throws Exception
+ {
+ cas.reset();
+ AnnotationFS annotation = cas.createAnnotation(cas.getAnnotationType(), 0, 2);
+ cas.addFsToIndexes(annotation);
+ List<AnnotationFS> result = cas.select(Annotation.class)
+ .coveredBy(0, 1)
+ .includeAnnotationsWithEndBeyondBounds()
+ .collect(toList());
+ assertThat(result)
+ .as("Selection (0-1) including start position (0) but not end position (2)")
+ .containsExactly(annotation);
}
}
