UIMA-6406: Removing an annotation inside a BLOCK only takes effect outside the block

- added test
diff --git a/ruta-core/src/test/java/org/apache/uima/ruta/action/UnmarkTest.java b/ruta-core/src/test/java/org/apache/uima/ruta/action/UnmarkTest.java
index 64b7152..ad992d7 100644
--- a/ruta-core/src/test/java/org/apache/uima/ruta/action/UnmarkTest.java
+++ b/ruta-core/src/test/java/org/apache/uima/ruta/action/UnmarkTest.java
@@ -20,6 +20,7 @@
 package org.apache.uima.ruta.action;

 

 import java.util.ArrayList;

+import java.util.LinkedHashMap;

 import java.util.List;

 import java.util.Map;

 import java.util.TreeMap;

@@ -43,45 +44,64 @@
 

     cas.release();

   }

-  

-  

+

   @Test

   public void testAnnotationExpression() throws Exception {

-    Map<String, String> typeMap = new TreeMap<String, String>();

+    Map<String, String> typeMap = new LinkedHashMap<String, String>();

     typeMap.put("Complex", "uima.tcas.Annotation");

     Map<String, List<TestFeature>> featureMap = new TreeMap<String, List<TestFeature>>();

-    List<TestFeature> list = new ArrayList<RutaTestUtils.TestFeature>();

+    List<TestFeature> list = new ArrayList<>();

     featureMap.put("Complex", list);

     list.add(new TestFeature("inner", "", "uima.tcas.Annotation"));

-    

+

     CAS cas = RutaTestUtils.getCAS("This is a test.", typeMap, featureMap);

     String script = "";

     script += "CW{->T1};t:T1 SW SW{-> UNMARK(t)};";

     script += "CW{->T2};\n t:T2 # PERIOD{-> Complex, Complex.inner=t};\n Complex{-> UNMARK(Complex.inner)};\n";

     Ruta.apply(cas, script);

-    

+

     RutaTestUtils.assertAnnotationsEquals(cas, 1, 0);

     RutaTestUtils.assertAnnotationsEquals(cas, 2, 0);

-    

+

   }

-  

+

   @Test

-  public void testAnnotationListExpression()  throws Exception {

-    Map<String, String> typeMap = new TreeMap<String, String>();

+  public void testAnnotationListExpression() throws Exception {

+    Map<String, String> typeMap = new LinkedHashMap<String, String>();

     typeMap.put("Complex", "uima.tcas.Annotation");

     Map<String, List<TestFeature>> featureMap = new TreeMap<String, List<TestFeature>>();

-    List<TestFeature> list = new ArrayList<RutaTestUtils.TestFeature>();

+    List<TestFeature> list = new ArrayList<>();

     featureMap.put("Complex", list);

     list.add(new TestFeature("inner", "", "uima.cas.FSArray"));

-    

+

     CAS cas = RutaTestUtils.getCAS("This is a test.", typeMap, featureMap);

     String script = "";

     script += "W{->T1}; Document{-> Complex, Complex.inner = T1};";

     script += "Complex{-> UNMARK(Complex.inner)};\n";

     Ruta.apply(cas, script);

-    

+

     RutaTestUtils.assertAnnotationsEquals(cas, 1, 0);

     RutaTestUtils.assertAnnotationsEquals(cas, 2, 0);

   }

-  

+

+  @Test

+  public void testUnmarkWithFeatureMatchInBlock() throws Exception {

+

+    Map<String, String> typeMap = new LinkedHashMap<String, String>();

+    typeMap.put("Struct", "uima.tcas.Annotation");

+    Map<String, List<TestFeature>> featureMap = new TreeMap<String, List<TestFeature>>();

+    List<TestFeature> list = new ArrayList<>();

+    featureMap.put("Struct", list);

+    list.add(new TestFeature("s", "", CAS.TYPE_NAME_STRING));

+

+    CAS cas = RutaTestUtils.getCAS("This is a test.", typeMap, featureMap);

+    String script = "\"is\"{->s:Struct,Struct.s=\"foo\"};";

+    script += "BLOCK(SoftRemove) Struct.s==\"foo\"{} {\r\n"

+            + "    t:Struct.s==\"foo\"{-> UNMARK(t)};\r\n"

+            + "    t:Struct.s==\"foo\"{-> T1}; \r\n" + "}";

+    Ruta.apply(cas, script);

+

+    RutaTestUtils.assertAnnotationsEquals(cas, 1, 0);

+  }

+

 }