You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by re...@apache.org on 2020/10/06 17:14:46 UTC

[uima-uimaj] 01/01: [UIMA-6269] select.coveredBy with includeAnnotationsWithEndBeyondBounds has broken edge case

This is an automated email from the ASF dual-hosted git repository.

rec pushed a commit to branch UIMA-6269-select-coveredBy-broken-on-edge-case
in repository https://gitbox.apache.org/repos/asf/uima-uimaj.git

commit 2244a2fe3d44326f4220a1e4ca6633235cac07cc
Author: Richard Eckart de Castilho <re...@apache.org>
AuthorDate: Tue Oct 6 19:15:07 2020 +0200

    [UIMA-6269] select.coveredBy with includeAnnotationsWithEndBeyondBounds has broken edge case
    
    - Added unit test illustrating the problem and currently failing
---
 .../java/org/apache/uima/cas/impl/SelectFsTest.java  | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/uimaj-core/src/test/java/org/apache/uima/cas/impl/SelectFsTest.java b/uimaj-core/src/test/java/org/apache/uima/cas/impl/SelectFsTest.java
index 1726a5b..db02f6a 100644
--- a/uimaj-core/src/test/java/org/apache/uima/cas/impl/SelectFsTest.java
+++ b/uimaj-core/src/test/java/org/apache/uima/cas/impl/SelectFsTest.java
@@ -19,17 +19,20 @@
 
 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);
   }
 }