Removed classRefCheck in OPIN without any arguments.

Change-Id: Ib684f42862d2ec725d2b8b73b1f77098b0123662
diff --git a/Changes b/Changes
index 3a859d4..097242c 100644
--- a/Changes
+++ b/Changes
@@ -3,6 +3,7 @@
 	- Updated maven dependency phase (margaretha)
     - Fixed handling of non-necessary brackets in tokens (diewald)
     - Improved error handling (margaretha)
+    - Added wrap to koral:span serialization (margaretha)
 
 0.25 2017-05-10
 	- Altered dominance and relation serialization (margaretha)
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessor.java b/src/main/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessor.java
index ca88711..0155d71 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessor.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessor.java
@@ -521,15 +521,6 @@
         }
         else {
             posGroup = KoralObjectGenerator.makeGroup(KoralOperation.POSITION);
-            // mark this an inverted operands object
-            invertedOperandsLists
-                    .push((ArrayList<Object>) posGroup.get("operands"));
-            wrapOperandInClass(node, 2, 128 + classCounter++);
-            wrapOperandInClass(node, 1, 128 + classCounter++);
-            // EM: why bother inverting the operands and creating classes and focus? 
-            // can't we agree on the first operand to be the results, like in 
-            // operation:exclusion?
-
         }
 
         Map<String, Object> positionOptions;
@@ -568,12 +559,12 @@
                                 .get("classRefCheck"),
                         posGroup);
             }
-            posGroup = addClassFocus((boolean) positionOptions.get("matchall"),
-                    posGroup);
+//            posGroup = addClassFocus((boolean) positionOptions.get("matchall"),
+//                    posGroup);
         }
 
         // wrap in 'merge' operation if grouping option is set
-        if (positionOptions.containsKey("grouping")
+        if (!isExclusion && positionOptions.containsKey("grouping")
                 && (boolean) positionOptions.get("grouping")) {
             Map<String, Object> mergeOperation = KoralObjectGenerator
                     .makeGroup(KoralOperation.MERGE);
@@ -1154,31 +1145,32 @@
         ArrayList<ClassRefCheck> classRefCheck = new ArrayList<ClassRefCheck>();
         posOptions.put("matchall", false);
 
-        String posOption = null;
+        String posOption = "";
         if (posnode != null) {
             posOption = posnode.getChild(0).toStringTree().toUpperCase();
-            if (isExclusion) {
-                checkINWithExclusionOptions(posOption, positions,
-                        classRefCheck);
-            }
-            else {
-                checkINOptions(posOption, positions, classRefCheck);
-            }
+        }
+
+        if (isExclusion) {
+            checkINWithExclusionOptions(posOption, positions,
+                    classRefCheck);
         }
         else {
-            classRefCheck.add(ClassRefCheck.INCLUDES);
+            checkINOptions(posOption, positions, classRefCheck);
         }
 
         posOptions.put("frames", Converter.enumListToStringList(positions));
         posOptions.put("classRefCheck", classRefCheck);
-        if (rangenode != null) {
+        if (!isExclusion && rangenode != null) {
             String range = rangenode.getChild(0).toStringTree().toLowerCase();
-            if (range.equals("all")) {
-                posOptions.put("matchall", true);
+            // ALL is default in KorAP
+            // if (range.equals("all")) {
+                
+                // posOptions.put("matchall", true);
                 // Map<String,Object> ref =
                 // makeResetReference(); // reset all defined classes
                 // wrapOperand(node,2,ref);
-            }
+            //}
+            // HIT is default in C2
         }
 
         Boolean grouping = false;
@@ -1197,33 +1189,28 @@
             ArrayList<ClassRefCheck> classRefCheck) {
         switch (posOption) {
             case "L":
-                positions.add(KoralFrame.STARTS_WITH);
-                positions.add(KoralFrame.MATCHES);
-                //                    classRefCheck.add("classRefCheck:includes");
+                positions.add(KoralFrame.ALIGNS_LEFT);
                 break;
             case "R":
-                positions.add(KoralFrame.ENDS_WITH);
-                positions.add(KoralFrame.MATCHES);
-                //                    classRefCheck.add("classRefCheck:includes");
+                positions.add(KoralFrame.ALIGNS_RIGHT);
                 break;
             case "F":
-                positions.add(KoralFrame.MATCHES);
-                //                    classRefCheck.add("classRefCheck:includes");
                 break;
             case "FE":
-                positions.add(KoralFrame.MATCHES);
                 classRefCheck.add(ClassRefCheck.EQUALS);
                 break;
             case "FI":
-                positions.add(KoralFrame.MATCHES);
                 classRefCheck.add(ClassRefCheck.UNEQUALS);
-                //                    classRefCheck.add("classRefCheck:includes");
                 break;
             case "N":
-                positions.add(KoralFrame.IS_AROUND);
-                //                    classRefCheck.add("classRefCheck:includes");
+                positions.add(KoralFrame.IS_WITHIN);
                 break;
+            default:
+                positions.add(KoralFrame.ALIGNS_LEFT);
+                positions.add(KoralFrame.ALIGNS_RIGHT);
+                positions.add(KoralFrame.IS_WITHIN);
         }
+        positions.add(KoralFrame.MATCHES);
     }
 
 
@@ -1248,8 +1235,9 @@
         }
         else if (CosmasPosition.F.name().equals(posOption)) {}
         else {
-            // throw an error or add an exception;
-            return;
+            positions.add(KoralFrame.ALIGNS_LEFT);
+            positions.add(KoralFrame.ALIGNS_RIGHT);
+            positions.add(KoralFrame.IS_WITHIN);
         }
 
         positions.add(KoralFrame.MATCHES);
diff --git a/src/test/java/de/ids_mannheim/korap/test/cosmas2/OPINTest.java b/src/test/java/de/ids_mannheim/korap/test/cosmas2/OPINTest.java
index d32195c..d58c223 100644
--- a/src/test/java/de/ids_mannheim/korap/test/cosmas2/OPINTest.java
+++ b/src/test/java/de/ids_mannheim/korap/test/cosmas2/OPINTest.java
@@ -13,6 +13,9 @@
 
 import de.ids_mannheim.korap.query.serialize.QuerySerializer;
 
+// EM: OPIN always returns the combination span of both operands
+// MAX groups all first operand spans that are in a same second operand span
+
 public class OPINTest {
     private String query;
 
@@ -26,69 +29,35 @@
         query = "wegen #IN <s>";
         qs.setQuery(query, "cosmas2");
         res = mapper.readTree(qs.toJSON());
-        assertEquals("koral:reference", res.at("/query/@type").asText());
-        assertEquals("operation:focus", res.at("/query/operation").asText());
-        assertEquals(130, res.at("/query/classRef/0").asInt());
-        assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
-        assertEquals("operation:class",
-                res.at("/query/operands/0/operation").asText());
-        assertEquals("classRefCheck:includes",
-                res.at("/query/operands/0/classRefCheck/0").asText());
-        assertEquals("koral:group",
-                res.at("/query/operands/0/operands/0/@type").asText());
+
+        assertEquals("koral:group", res.at("/query/@type").asText());
         assertEquals("operation:position",
-                res.at("/query/operands/0/operands/0/operation").asText());
-        assertEquals(true, res.at("/query/operands/0/operands/0/frames/0")
-                .isMissingNode());
-        assertEquals(129, res.at("/query/operands/0/classIn/0").asInt());
-        assertEquals(130, res.at("/query/operands/0/classIn/1").asInt());
-        assertEquals(131, res.at("/query/operands/0/classOut").asInt());
-        assertEquals("koral:group",
-                res.at("/query/operands/0/operands/0/@type").asText());
-        assertEquals("operation:class",
-                res.at("/query/operands/0/operands/0/operands/0/operation")
-                        .asText());
-        assertEquals(129,
-                res.at("/query/operands/0/operands/0/operands/0/classOut")
-                        .asInt());
-        assertEquals("koral:span",
-                res.at("/query/operands/0/operands/0/operands/0/operands/0/@type")
-                        .asText());
-        assertEquals("s",
-                res.at("/query/operands/0/operands/0/operands/0/operands/0/wrap/key")
-                        .asText());
-        assertEquals("koral:group", res
-                .at("/query/operands/0/operands/0/operands/1/@type").asText());
-        assertEquals("operation:class",
-                res.at("/query/operands/0/operands/0/operands/1/operation")
-                        .asText());
-        assertEquals(130,
-                res.at("/query/operands/0/operands/0/operands/1/classOut")
-                        .asInt());
-        assertEquals("koral:token",
-                res.at("/query/operands/0/operands/0/operands/1/operands/0/@type")
-                        .asText());
-        assertEquals("wegen",
-                res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key")
-                        .asText());
+                res.at("/query/operation").asText());
+        assertEquals(4, res.at("/query/frames").size());
+        assertEquals("frames:alignsLeft", res.at("/query/frames/0").asText());
+        assertEquals("frames:alignsRight", res.at("/query/frames/1").asText());
+        assertEquals("frames:isWithin", res.at("/query/frames/2").asText());
+        assertEquals("frames:matches", res.at("/query/frames/3").asText());
+        assertEquals("koral:token", res.at("/query/operands/0/@type").asText());
+        assertEquals("koral:span", res.at("/query/operands/1/@type").asText());
     }
 
 
     @Test
-   
     public void testOPINWithOptionN ()
             throws JsonProcessingException, IOException {
         query = "wegen #IN(N) <s>";
         qs.setQuery(query, "cosmas2");
         res = mapper.readTree(qs.toJSON());
-        assertEquals("koral:reference", res.at("/query/@type").asText());
-        assertEquals("operation:focus", res.at("/query/operation").asText());
-        assertEquals(130, res.at("/query/classRef/0").asInt());
-        assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
+        assertEquals("koral:group", res.at("/query/@type").asText());
         assertEquals("operation:position",
-                res.at("/query/operands/0/operation").asText());
-        assertEquals("frames:isAround",
-                res.at("/query/operands/0/frames/0").asText());
+                res.at("/query/operation").asText());
+        assertEquals("frames:isWithin",
+                res.at("/query/frames/0").asText());
+        assertEquals("wegen",
+                res.at("/query/operands/0/wrap/key").asText());
+        assertEquals("s",
+                res.at("/query/operands/1/wrap/key").asText());
     }
     
     
@@ -98,39 +67,39 @@
         query = "wegen #IN(L) <s>";
         qs.setQuery(query, "cosmas2");
         res = mapper.readTree(qs.toJSON());
-        assertEquals("koral:reference", res.at("/query/@type").asText());
-        assertEquals("operation:focus", res.at("/query/operation").asText());
-        assertEquals(130, res.at("/query/classRef/0").asInt());
-        assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
+        
         assertEquals("operation:position",
-                res.at("/query/operands/0/operation").asText());
-        assertEquals("frames:startsWith",
-                res.at("/query/operands/0/frames/0").asText());
+                res.at("/query/operation").asText());
+        assertEquals(2, res.at("/query/frames").size());
+        assertEquals("frames:alignsLeft",
+                res.at("/query/frames/0").asText());
         assertEquals("frames:matches",
-                res.at("/query/operands/0/frames/1").asText());
-        assertEquals(true,
-                res.at("/query/operands/0/frames/2").isMissingNode());
-        assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
-        assertEquals("operation:class",
-                res.at("/query/operands/0/operands/0/operation").asText());
-        assertEquals(129,
-                res.at("/query/operands/0/operands/0/classOut").asInt());
-        assertEquals("koral:span", res
-                .at("/query/operands/0/operands/0/operands/0/@type").asText());
-        assertEquals("s",
-                res.at("/query/operands/0/operands/0/operands/0/wrap/key")
-                        .asText());
-        assertEquals("koral:group",
-                res.at("/query/operands/0/operands/1/@type").asText());
-        assertEquals("operation:class",
-                res.at("/query/operands/0/operands/1/operation").asText());
-        assertEquals(130,
-                res.at("/query/operands/0/operands/1/classOut").asInt());
-        assertEquals("koral:token", res
-                .at("/query/operands/0/operands/1/operands/0/@type").asText());
+                res.at("/query/frames/1").asText());
+
         assertEquals("wegen",
-                res.at("/query/operands/0/operands/1/operands/0/wrap/key")
-                        .asText());
+                res.at("/query/operands/0/wrap/key").asText());
+        assertEquals("s",
+                res.at("/query/operands/1/wrap/key").asText());
+    }
+    
+    @Test
+    public void testOPINWithOptionR ()
+            throws JsonProcessingException, IOException {
+        query = "wegen #IN(R) <s>";
+        qs.setQuery(query, "cosmas2");
+        res = mapper.readTree(qs.toJSON());
+        
+        assertEquals("operation:position",
+                res.at("/query/operation").asText());
+        assertEquals("frames:alignsRight",
+                res.at("/query/frames/0").asText());
+        assertEquals("frames:matches",
+                res.at("/query/frames/1").asText());
+        assertEquals(2, res.at("/query/frames").size());
+        assertEquals("wegen",
+                res.at("/query/operands/0/wrap/key").asText());
+        assertEquals("s",
+                res.at("/query/operands/1/wrap/key").asText());
     }
 
     @Test
@@ -142,9 +111,9 @@
         assertEquals(true,
                 res.at("/query/operands/0/classRefCheck").isMissingNode());
         assertEquals("frames:matches",
-                res.at("/query/operands/0/frames/0").asText());
+                res.at("/query/frames/0").asText());
         assertEquals(true,
-                res.at("/query/operands/0/frames/1").isMissingNode());
+                res.at("/query/frames/1").isMissingNode());
     }
 
 
@@ -155,10 +124,10 @@
         qs.setQuery(query, "cosmas2");
         res = mapper.readTree(qs.toJSON());
         assertEquals("classRefCheck:unequals",
-                res.at("/query/operands/0/classRefCheck/0").asText());
+                res.at("/query/classRefCheck/0").asText());
         assertEquals("frames:matches",
-                res.at("/query/operands/0/operands/0/frames/0").asText());
-        assertEquals(true, res.at("/query/operands/0/operands/0/frames/1")
+                res.at("/query/operands/0/frames/0").asText());
+        assertEquals(true, res.at("/query/operands/0/frames/1")
                 .isMissingNode());
         
     }
@@ -171,38 +140,63 @@
         qs.setQuery(query, "cosmas2");
         res = mapper.readTree(qs.toJSON());
         assertEquals("classRefCheck:equals",
-                res.at("/query/operands/0/classRefCheck/0").asText());
+                res.at("/query/classRefCheck/0").asText());
         assertEquals("frames:matches",
-                res.at("/query/operands/0/operands/0/frames/0").asText());
-        assertEquals(true, res.at("/query/operands/0/operands/0/frames/1")
+                res.at("/query/operands/0/frames/0").asText());
+        assertEquals(true, res.at("/query/operands/0/frames/1")
                 .isMissingNode());
     }
 
     @Test
-    @Ignore
-    public void testOPINWithOptionN_MAX ()
+    public void testOPINWithOptionN_ALL ()
             throws JsonProcessingException, IOException {
-        query = "wegen #IN(N, MAX) <s>";
+        // ALL is default in KorAP
+        query = "sich #IN(N,ALL) (&gelten /w5:10 zurecht)";
         qs.setQuery(query, "cosmas2");
         res = mapper.readTree(qs.toJSON());
-        // System.out.println(res.toString());
-        assertEquals("koral:reference", res.at("/query/@type").asText());
-        assertEquals("operation:focus", res.at("/query/operation").asText());
-        assertEquals(130, res.at("/query/classRef/0").asInt());
-        assertEquals("koral:group", res.at("/query/operands/0/@type").asText());
+        assertEquals("koral:group", res.at("/query/@type").asText());
         assertEquals("operation:position",
-                res.at("/query/operands/0/operation").asText());
-        assertEquals("frames:isAround",
-                res.at("/query/operands/0/frames/0").asText());
+                res.at("/query/operation").asText());
+        assertEquals("frames:isWithin",
+                res.at("/query/frames/0").asText());
+        assertEquals("frames:matches",
+                res.at("/query/frames/1").asText());
+        assertEquals("sich",
+                res.at("/query/operands/0/wrap/key").asText());
+        assertEquals("gelten",
+                res.at("/query/operands/1/operands/0/operands/0/wrap/key").asText());
+        assertEquals("zurecht",
+                res.at("/query/operands/1/operands/1/operands/0/wrap/key").asText());
     }
     
     @Test
     public void testOPINWithOptionN_HIT ()
             throws JsonProcessingException, IOException {
-        query = "wegen #IN(N, HIT) <s>";
+        // EM: KorAP does not support matching in multiple hits?   
+        query = "gilt #IN(N,HIT) (&gelten /w5:10 zurecht)";
         qs.setQuery(query, "cosmas2");
         res = mapper.readTree(qs.toJSON());
-        // System.out.println(res.toString());
+        assertEquals("koral:group", res.at("/query/@type").asText());
+        assertEquals("operation:position",
+                res.at("/query/operation").asText());
+        assertEquals("frames:isWithin",
+                res.at("/query/frames/0").asText());
+        assertEquals("frames:matches",
+                res.at("/query/frames/1").asText());
+        assertEquals("wegen",
+                res.at("/query/operands/0/wrap/key").asText());
+        assertEquals("s",
+                res.at("/query/operands/1/wrap/key").asText());
+    }
+    
+    @Test
+    public void testOPINWithOptionN_MAX ()
+            throws JsonProcessingException, IOException {
+        // EM: Fix operation:merge
+        query = "wegen #IN(N, MAX) <s>";
+        qs.setQuery(query, "cosmas2");
+        res = mapper.readTree(qs.toJSON());
+
         assertEquals("koral:reference", res.at("/query/@type").asText());
         assertEquals("operation:focus", res.at("/query/operation").asText());
         assertEquals(130, res.at("/query/classRef/0").asInt());
@@ -212,6 +206,4 @@
         assertEquals("frames:isAround",
                 res.at("/query/operands/0/frames/0").asText());
     }
-    
-
 }
diff --git a/src/test/java/de/ids_mannheim/korap/test/cosmas2/OPINWithExclusionTest.java b/src/test/java/de/ids_mannheim/korap/test/cosmas2/OPINWithExclusionTest.java
index 3246141..9d410dc 100644
--- a/src/test/java/de/ids_mannheim/korap/test/cosmas2/OPINWithExclusionTest.java
+++ b/src/test/java/de/ids_mannheim/korap/test/cosmas2/OPINWithExclusionTest.java
@@ -4,7 +4,6 @@
 
 import java.io.IOException;
 
-import org.junit.Ignore;
 import org.junit.Test;
 
 import com.fasterxml.jackson.core.JsonProcessingException;
@@ -13,6 +12,8 @@
 
 import de.ids_mannheim.korap.query.serialize.QuerySerializer;
 
+// EM: exclusion always returns the first operand
+
 public class OPINWithExclusionTest {
     private String query;
 
@@ -20,6 +21,24 @@
     private ObjectMapper mapper = new ObjectMapper();
     private JsonNode res;
 
+    @Test
+    public void testOPINWithExclusion ()
+            throws JsonProcessingException, IOException {
+        query = "wegen #IN(%) <s>";
+        qs.setQuery(query, "cosmas2");
+        res = mapper.readTree(qs.toJSON());
+
+        assertEquals("koral:group", res.at("/query/@type").asText());
+        assertEquals("operation:exclusion",
+                res.at("/query/operation").asText());
+        assertEquals(4, res.at("/query/frames").size());
+        assertEquals("frames:alignsLeft", res.at("/query/frames/0").asText());
+        assertEquals("frames:alignsRight", res.at("/query/frames/1").asText());
+        assertEquals("frames:matches", res.at("/query/frames/3").asText());
+        assertEquals("frames:isWithin", res.at("/query/frames/2").asText());
+        assertEquals("koral:token", res.at("/query/operands/0/@type").asText());
+        assertEquals("koral:span", res.at("/query/operands/1/@type").asText());
+    }
 
     @Test
     public void testOPINWithExclusionN ()
@@ -125,6 +144,8 @@
     }
 
 
+    // EM: MIN, MAX does not matter with %
+    
     @Test
     public void testOPINwithExclusionFE_MIN ()
             throws JsonProcessingException, IOException {
@@ -141,23 +162,42 @@
                 res.at("/query/operands/0/frames/0").asText());
     }
 
+    @Test
+    public void testOPINwithExclusionFE_MAX ()
+            throws JsonProcessingException, IOException {
+        query = "wegen #IN(FE,%,MAX) <s>";
+        qs.setQuery(query, "cosmas2");
+        res = mapper.readTree(qs.toJSON());
+        
+        assertEquals("operation:class", res.at("/query/operation").asText());
+        assertEquals("classRefCheck:unequals",
+                res.at("/query/classRefCheck/0").asText());
+
+        JsonNode classRefCheckOperand = res.at("/query/operands/0");
+        assertEquals("operation:exclusion",
+                classRefCheckOperand.at("/operation").asText());
+        assertEquals(1, classRefCheckOperand.at("/frames").size());
+        assertEquals("frames:matches",
+                classRefCheckOperand.at("/frames/0").asText());
+    }
 
     @Test
     public void testOPINwithExclusionN_MAX ()
             throws JsonProcessingException, IOException {
+
         query = "wegen #IN(N,%,MAX) <s>";
         qs.setQuery(query, "cosmas2");
         res = mapper.readTree(qs.toJSON());
-
-        assertEquals("operation:merge", res.at("/query/operation").asText());
+        
+        assertEquals("koral:group", res.at("/query/@type").asText());
         assertEquals("operation:exclusion",
-                res.at("/query/operands/0/operation").asText());
-        assertEquals(1, res.at("/query/operands/0/frames").size());
-        assertEquals("frames:isWithin",
-                res.at("/query/operands/0/frames/0").asText());
+                res.at("/query/operation").asText());
+        assertEquals(1, res.at("/query/frames").size());
+        assertEquals("frames:isWithin", res.at("/query/frames/0").asText());
+        assertEquals("koral:token", res.at("/query/operands/0/@type").asText());
+        assertEquals("koral:span", res.at("/query/operands/1/@type").asText());
     }
 
-
     @Test
     public void testOPINwithExclusionL_MAX ()
             throws JsonProcessingException, IOException {
@@ -165,97 +205,75 @@
         qs.setQuery(query, "cosmas2");
         res = mapper.readTree(qs.toJSON());
         
-        assertEquals("operation:merge", res.at("/query/operation").asText());
+        assertEquals("koral:group", res.at("/query/@type").asText());
         assertEquals("operation:exclusion",
-                res.at("/query/operands/0/operation").asText());
-        assertEquals(2, res.at("/query/operands/0/frames").size());
-        assertEquals("frames:alignsLeft",
-                res.at("/query/operands/0/frames/0").asText());
-        assertEquals("frames:matches",
-                res.at("/query/operands/0/frames/1").asText());
+                res.at("/query/operation").asText());
+        assertEquals(2, res.at("/query/frames").size());
+        assertEquals("frames:alignsLeft", res.at("/query/frames/0").asText());
+        assertEquals("frames:matches", res.at("/query/frames/1").asText());
+        assertEquals("koral:token", res.at("/query/operands/0/@type").asText());
+        assertEquals("koral:span", res.at("/query/operands/1/@type").asText());
     }
 
-
-    @Test
-    public void testOPINwithExclusionFE_MAX ()
-            throws JsonProcessingException, IOException {
-        query = "wegen #IN(FE,%,MAX) <s>";
-        qs.setQuery(query, "cosmas2");
-        res = mapper.readTree(qs.toJSON());
-
-        assertEquals("operation:merge", res.at("/query/operation").asText());
-        assertEquals("operation:class",
-                res.at("/query/operands/0/operation").asText());
-        assertEquals("classRefCheck:unequals",
-                res.at("/query/operands/0/classRefCheck/0").asText());
-        JsonNode classOperand = res.at("/query/operands/0/operands/0");
-        assertEquals("operation:exclusion",
-                classOperand.at("/operation").asText());
-        assertEquals(1, classOperand.at("/frames").size());
-        assertEquals("frames:matches", classOperand.at("/frames/0").asText());
-    }
-
+    // EM: KorAP always do ALL by default.
     
     @Test
-    @Ignore
-    public void testOPINwithMultipleExclusionN_ALL ()
+    public void testOPINwithExclusionN_ALL ()
             throws JsonProcessingException, IOException {
+        
         query = "wegen #IN(N,ALL,%) <s>";
         qs.setQuery(query, "cosmas2");
         res = mapper.readTree(qs.toJSON());
-        // System.out.println(res.toString());
-        assertEquals("operation:class", res.at("/query/operation").asText());
-        assertEquals("classRefOp:delete", res.at("/query/classRefOp").asText());
-        assertEquals(131, res.at("/query/classIn/0").asInt());
-        assertEquals("classRefCheck:unequals",
-                res.at("/query/operands/0/classRefCheck/0").asText());
-        assertEquals("frames:matches",
-                res.at("/query/operands/0/operands/0/frames/0").asText());
+        assertEquals("koral:group", res.at("/query/@type").asText());
+        assertEquals("operation:exclusion",
+                res.at("/query/operation").asText());
+        assertEquals(1, res.at("/query/frames").size());
+        assertEquals("frames:isWithin", res.at("/query/frames/0").asText());
+        assertEquals("koral:token", res.at("/query/operands/0/@type").asText());
+        assertEquals("koral:span", res.at("/query/operands/1/@type").asText());
     }
 
     @Test
-    @Ignore
-    public void testOPINwithMultipleExclusionFE_ALL ()
+    public void testOPINwithExclusionN_ALL_MAX ()
+            throws JsonProcessingException, IOException {
+        query = "wegen #IN(N,ALL,%,MAX) <s>";
+        qs.setQuery(query, "cosmas2");
+        res = mapper.readTree(qs.toJSON());
+        
+        assertEquals("koral:group", res.at("/query/@type").asText());
+        assertEquals("operation:exclusion",
+                res.at("/query/operation").asText());
+        assertEquals(1, res.at("/query/frames").size());
+        assertEquals("frames:isWithin", res.at("/query/frames/0").asText());
+        assertEquals("koral:token", res.at("/query/operands/0/@type").asText());
+    }
+    
+    @Test
+    public void testOPINwithExclusionFE_ALL ()
             throws JsonProcessingException, IOException {
         query = "wegen #IN(FE,ALL,%) <s>";
         qs.setQuery(query, "cosmas2");
         res = mapper.readTree(qs.toJSON());
         assertEquals("operation:class", res.at("/query/operation").asText());
-        assertEquals("classRefOp:delete", res.at("/query/classRefOp").asText());
-        assertEquals(131, res.at("/query/classIn/0").asInt());
         assertEquals("classRefCheck:unequals",
-                res.at("/query/operands/0/classRefCheck/0").asText());
+                res.at("/query/classRefCheck/0").asText());
+        assertEquals(1, res.at("/query/operands/0/frames").size());
         assertEquals("frames:matches",
-                res.at("/query/operands/0/operands/0/frames/0").asText());
+                res.at("/query/operands/0/frames/0").asText());
     }
 
     @Test
-    public void testOPINwithMultipleExclusionN_ALL_MAX ()
-            throws JsonProcessingException, IOException {
-        query = "wegen #IN(N,ALL,%,MAX) <s>";
-        qs.setQuery(query, "cosmas2");
-        res = mapper.readTree(qs.toJSON());
-    }
-    
-    @Test
-    @Ignore
-    public void testOPINwithMultipleExclusionFE_ALL_MAX ()
+    public void testOPINwithExclusionFE_ALL_MAX ()
             throws JsonProcessingException, IOException {
         query = "wegen #IN(FE,ALL,%,MAX) <s>";
         qs.setQuery(query, "cosmas2");
         res = mapper.readTree(qs.toJSON());
-        assertEquals("operation:merge", res.at("/query/operation").asText());
-        assertEquals("operation:class",
-                res.at("/query/operands/0/operation").asText());
-        assertEquals("classRefOp:delete",
-                res.at("/query/operands/0/classRefOp").asText());
-        assertEquals(131, res.at("/query/operands/0/classIn/0").asInt());
-        assertEquals("classRefCheck:unequals", res
-                .at("/query/operands/0/operands/0/classRefCheck/0").asText());
+        assertEquals("operation:class", res.at("/query/operation").asText());
+        assertEquals("classRefCheck:unequals",
+                res.at("/query/classRefCheck/0").asText());
+        assertEquals(1, res.at("/query/operands/0/frames").size());
         assertEquals("frames:matches",
-                res.at("/query/operands/0/operands/0/operands/0/frames/0")
-                        .asText());
+                res.at("/query/operands/0/frames/0").asText());
     }
 
-
 }