Added OPOV with exclusion.

Change-Id: I4221c3df8adf32cdbe7a4a9d59751ea5994dc01b
diff --git a/Changes b/Changes
index 006c566..eb18673 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,7 @@
 0.27 2017-09-12
-	- Changed Cosmas2 wildcards serialization as regex (margaretha).  
-	- Updated C2 OP OV frames (margaretha).
+	- Changed Cosmas2 wildcards serialization as regex (margaretha)  
+	- Fixed OP IN with classRefCheck.INCLUDES (margaretha)
+	- Implemented OP PV with exclusion (margaretha)
 	
 0.26 2017-06-29
 	- Updated collection query grammar (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 e6fb3c8..6ff2a4e 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
@@ -498,11 +498,9 @@
             classOut = classCounter + 128 + 1;
         }
         if (check.contains(ClassRefCheck.EQUALS)
-                || check.contains(ClassRefCheck.UNEQUALS)) {
-            classIn.add(classCounter + 128 - 2);
-            classIn.add(classCounter + 128 - 1);
-        }
-        else if (check.contains(ClassRefCheck.INTERSECTS)) {
+                || check.contains(ClassRefCheck.UNEQUALS) 
+                || check.contains(ClassRefCheck.INTERSECTS)
+                || check.contains(ClassRefCheck.DISJOINT)) {
             classIn.add(classCounter + 128 - 2);
             classIn.add(classCounter + 128 - 1);
         }
@@ -554,7 +552,7 @@
             positionOptions = parseOPINOptions(node, isExclusion);
         }
         else {
-            positionOptions = parseOPOVOptions(node);
+            positionOptions = parseOPOVOptions(node,isExclusion);
         }
 
         posGroup.put("frames", positionOptions.get("frames"));
@@ -1243,6 +1241,7 @@
     private void checkINOptions (String posOption,
             ArrayList<KoralFrame> positions,
             ArrayList<ClassRefCheck> classRefCheck) {
+        positions.add(KoralFrame.MATCHES);
         switch (posOption) {
             case "L":
                 positions.add(KoralFrame.ALIGNS_LEFT);
@@ -1260,13 +1259,14 @@
                 break;
             case "N":
                 positions.add(KoralFrame.IS_WITHIN);
+                positions.remove(KoralFrame.MATCHES);
                 break;
             default:
                 positions.add(KoralFrame.ALIGNS_LEFT);
                 positions.add(KoralFrame.ALIGNS_RIGHT);
                 positions.add(KoralFrame.IS_WITHIN);
         }
-        positions.add(KoralFrame.MATCHES);
+        
     }
 
 
@@ -1300,8 +1300,7 @@
     }
 
 
-    private Map<String, Object> parseOPOVOptions (Tree node) {
-        boolean negatePosition = false;
+    private Map<String, Object> parseOPOVOptions (Tree node, boolean isExclusion) {
         Tree posnode = getFirstChildWithCat(node, "POS");
         Tree rangenode = getFirstChildWithCat(node, "RANGE");
         Tree exclnode = getFirstChildWithCat(node, "EXCL");
@@ -1313,38 +1312,17 @@
         String posOption = null;
         if (posnode != null) {
             posOption = posnode.getChild(0).toStringTree();
-            switch (posOption) {
-                case "L":
-                    positions.add(KoralFrame.ALIGNS_LEFT);
-                    positions.add(KoralFrame.OVERLAPS_LEFT);
-                    positions.add(KoralFrame.MATCHES);
-                    classRefCheck.add(ClassRefCheck.INTERSECTS);
-                    break;
-                case "R":
-                    positions.add(KoralFrame.ALIGNS_RIGHT);
-                    positions.add(KoralFrame.OVERLAPS_RIGHT);
-                    positions.add(KoralFrame.MATCHES);
-                    classRefCheck.add(ClassRefCheck.INTERSECTS);
-                    break;
-                case "F":
-                    positions.add(KoralFrame.MATCHES);
-                    classRefCheck.add(ClassRefCheck.INTERSECTS);
-                    break;
-                case "FE":
-                    positions.add(KoralFrame.MATCHES);
-                    classRefCheck.add(ClassRefCheck.EQUALS);
-                    break;
-                case "FI":
-                    positions.add(KoralFrame.MATCHES);
-                    classRefCheck.add(ClassRefCheck.UNEQUALS);
-                    break;
-                case "X":
-                    positions.add(KoralFrame.IS_WITHIN);
-                    classRefCheck.add(ClassRefCheck.INTERSECTS);
-                    break;
+            if (isExclusion){
+                checkOVExclusionOptions(posOption, positions, classRefCheck);
+            }
+            else{
+                checkOVOptions(posOption, positions, classRefCheck);
             }
         }
-        else {
+        else if (isExclusion){
+            classRefCheck.add(ClassRefCheck.DISJOINT);
+        }
+        else{
             classRefCheck.add(ClassRefCheck.INTERSECTS);
         }
 
@@ -1354,11 +1332,11 @@
             wrapOperandInClass(node, 1, 128 + classCounter++);
             wrapOperandInClass(node, 2, 128 + classCounter++);
         }
-        if (exclnode != null) {
-            if (exclnode.getChild(0).toStringTree().equals("YES")) {
-                negatePosition = !negatePosition;
-            }
-        }
+//        if (exclnode != null) {
+//            if (exclnode.getChild(0).toStringTree().equals("YES")) {
+//                negatePosition = !negatePosition;
+//            }
+//        }
 
         if (rangenode != null) {
             String range = rangenode.getChild(0).toStringTree().toLowerCase();
@@ -1370,9 +1348,9 @@
             }
         }
 
-        if (negatePosition) {
-            posOptions.put("exclude", "true");
-        }
+//        if (negatePosition) {
+//            posOptions.put("exclude", "true");
+//        }
 
         boolean grouping = false;
         if (groupnode != null) {
@@ -1386,6 +1364,70 @@
     }
 
 
+    private void checkOVExclusionOptions (String posOption,
+            ArrayList<KoralFrame> positions,
+            ArrayList<ClassRefCheck> classRefCheck) {
+        positions.add(KoralFrame.MATCHES);
+        switch (posOption) {
+            case "L":
+                positions.add(KoralFrame.ALIGNS_LEFT);
+                positions.add(KoralFrame.OVERLAPS_LEFT);
+                classRefCheck.add(ClassRefCheck.INTERSECTS);
+                classRefCheck.add(ClassRefCheck.DISJOINT);
+                break;
+            case "R":
+                positions.add(KoralFrame.ALIGNS_RIGHT);
+                positions.add(KoralFrame.OVERLAPS_RIGHT);
+                classRefCheck.add(ClassRefCheck.INTERSECTS);
+                classRefCheck.add(ClassRefCheck.DISJOINT);
+                break;
+            case "FE":
+                classRefCheck.add(ClassRefCheck.UNEQUALS);
+                break;
+            case "FI":
+                classRefCheck.add(ClassRefCheck.EQUALS);
+                break;
+            case "X":
+                positions.add(KoralFrame.IS_WITHIN);
+                positions.remove(KoralFrame.MATCHES);
+                break;
+        }
+        
+    }
+
+
+    private void checkOVOptions (String posOption, 
+            ArrayList<KoralFrame> positions, 
+            ArrayList<ClassRefCheck> classRefCheck) {
+        classRefCheck.add(ClassRefCheck.INTERSECTS);
+        positions.add(KoralFrame.MATCHES);
+        switch (posOption) {
+            case "L":
+                positions.add(KoralFrame.ALIGNS_LEFT);
+                positions.add(KoralFrame.OVERLAPS_LEFT);
+                break;
+            case "R":
+                positions.add(KoralFrame.ALIGNS_RIGHT);
+                positions.add(KoralFrame.OVERLAPS_RIGHT);
+                break;
+            case "F":
+                break;
+            case "FE":
+                classRefCheck.add(ClassRefCheck.EQUALS);
+                classRefCheck.remove(ClassRefCheck.INTERSECTS);
+                break;
+            case "FI":
+                classRefCheck.add(ClassRefCheck.UNEQUALS);
+                break;
+            case "X":
+                positions.add(KoralFrame.IS_WITHIN);
+                positions.remove(KoralFrame.MATCHES);
+                break;
+        }
+        
+    }
+
+
     @SuppressWarnings({ "unchecked" })
     private Map<String, Object> wrap (Map<String, Object>[] wrapCascade) {
         int i;
diff --git a/src/test/java/de/ids_mannheim/korap/test/cosmas2/Cosmas2QueryProcessorTest.java b/src/test/java/de/ids_mannheim/korap/test/cosmas2/Cosmas2QueryProcessorTest.java
index 7dc5046..2b8d809 100644
--- a/src/test/java/de/ids_mannheim/korap/test/cosmas2/Cosmas2QueryProcessorTest.java
+++ b/src/test/java/de/ids_mannheim/korap/test/cosmas2/Cosmas2QueryProcessorTest.java
@@ -763,11 +763,11 @@
         assertEquals("classRefCheck:intersects",
                 res.at("/query/classRefCheck/0").asText());
         assertEquals("frames:alignsLeft",
-                res.at("/query/operands/0/frames/0").asText());
-        assertEquals("frames:overlapsLeft",
                 res.at("/query/operands/0/frames/1").asText());
-        assertEquals("frames:matches",
+        assertEquals("frames:overlapsLeft",
                 res.at("/query/operands/0/frames/2").asText());
+        assertEquals("frames:matches",
+                res.at("/query/operands/0/frames/0").asText());
 
         query = "wegen #OV(F) <s>";
         qs.setQuery(query, "cosmas2");
@@ -782,8 +782,10 @@
         query = "wegen #OV(FI) <s>";
         qs.setQuery(query, "cosmas2");
         res = mapper.readTree(qs.toJSON());
-        assertEquals("classRefCheck:unequals",
+        assertEquals("classRefCheck:intersects",
                 res.at("/query/classRefCheck/0").asText());
+        assertEquals("classRefCheck:unequals",
+                res.at("/query/classRefCheck/1").asText());
         assertEquals("frames:matches",
                 res.at("/query/operands/0/frames/0").asText());
 
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 1762a3b..c32d900 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
@@ -33,10 +33,10 @@
         assertEquals("koral:group", res.at("/query/@type").asText());
         assertEquals("operation:position", 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("frames:matches", res.at("/query/frames/0").asText());
+        assertEquals("frames:alignsLeft", res.at("/query/frames/1").asText());
+        assertEquals("frames:alignsRight", res.at("/query/frames/2").asText());
+        assertEquals("frames:isWithin", 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());
     }
@@ -48,6 +48,7 @@
         query = "wegen #IN(N) <s>";
         qs.setQuery(query, "cosmas2");
         res = mapper.readTree(qs.toJSON());
+        System.out.println(res);
         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());
@@ -65,8 +66,8 @@
 
         assertEquals("operation:position", 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("frames:matches", res.at("/query/frames/0").asText());
+        assertEquals("frames:alignsLeft", 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());
@@ -81,8 +82,9 @@
         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("frames:matches", res.at("/query/frames/0").asText());
+        assertEquals("frames:alignsRight", 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());
@@ -143,7 +145,6 @@
         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("sich", res.at("/query/operands/0/wrap/key").asText());
         assertEquals("gelten",
                 res.at("/query/operands/1/operands/0/operands/0/wrap/key")
@@ -162,7 +163,7 @@
         query = "gilt #IN(N,HIT) (&gelten /w5:10 zurecht)";
         qs.setQuery(query, "cosmas2");
         res = mapper.readTree(qs.toJSON());
-//        System.out.println(res);
+        System.out.println(res);
         assertEquals("koral:group", res.at("/query/@type").asText());
         assertEquals("operation:class", res.at("/query/operation").asText());
         assertEquals("classRefCheck:includes",
@@ -175,8 +176,6 @@
                 res.at("/query/operands/0/operation").asText());
         assertEquals("frames:isWithin",
                 res.at("/query/operands/0/frames/0").asText());
-        assertEquals("frames:matches",
-                res.at("/query/operands/0/frames/1").asText());
         
         assertEquals("operation:class",
                 res.at("/query/operands/0/operands/0/operation").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 9d410dc..06f60fa 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
@@ -224,6 +224,7 @@
         query = "wegen #IN(N,ALL,%) <s>";
         qs.setQuery(query, "cosmas2");
         res = mapper.readTree(qs.toJSON());
+//        System.out.println(res);
         assertEquals("koral:group", res.at("/query/@type").asText());
         assertEquals("operation:exclusion",
                 res.at("/query/operation").asText());
@@ -276,4 +277,31 @@
                 res.at("/query/operands/0/frames/0").asText());
     }
 
+    // EM: Does exclusion HIT not need classRefCheck?
+    @Test
+    public void testOPINwithExclusionN_HIT ()
+            throws JsonProcessingException, IOException {
+        
+        query = "wegen #IN(N,HIT,%) (wegen /w5:10 des)";
+        qs.setQuery(query, "cosmas2");
+        res = mapper.readTree(qs.toJSON());
+//        System.out.println(res);
+        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("operation:sequence", res.at("/query/operands/1/operation").asText());
+        
+        JsonNode seqOperand = res.at("/query/operands/1/operands");
+                
+        assertEquals("operation:class", seqOperand.at("/0/operation").asText());
+        assertEquals(129, seqOperand.at("/0/classOut").asInt());
+        
+        assertEquals("operation:class", seqOperand.at("/1/operation").asText());
+        assertEquals(129, seqOperand.at("/1/classOut").asInt());
+    }
+    
 }
diff --git a/src/test/java/de/ids_mannheim/korap/test/cosmas2/OPOVWithExclusionTest.java b/src/test/java/de/ids_mannheim/korap/test/cosmas2/OPOVWithExclusionTest.java
new file mode 100644
index 0000000..262b1a1
--- /dev/null
+++ b/src/test/java/de/ids_mannheim/korap/test/cosmas2/OPOVWithExclusionTest.java
@@ -0,0 +1,186 @@
+package de.ids_mannheim.korap.test.cosmas2;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+
+import org.junit.Test;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import de.ids_mannheim.korap.query.serialize.QuerySerializer;
+
+public class OPOVWithExclusionTest {
+
+    private String query;
+
+    private QuerySerializer qs = new QuerySerializer();
+    private ObjectMapper mapper = new ObjectMapper();
+    private JsonNode res;
+
+
+    @Test
+    public void testOPOVWithExclusion ()
+            throws JsonProcessingException, IOException {
+        query = "wegen #OV(%) <s>";
+        qs.setQuery(query, "cosmas2");
+        res = mapper.readTree(qs.toJSON());
+//        System.out.println(res);
+
+        assertEquals("koral:group", res.at("/query/@type").asText());
+        assertEquals("operation:class", res.at("/query/operation").asText());
+        assertEquals(1, res.at("/query/classRefCheck").size());
+        assertEquals("classRefCheck:disjoint",
+                res.at("/query/classRefCheck/0").asText());
+        
+        JsonNode classRefCheckOperand = res.at("/query/operands/0");
+        assertEquals("operation:exclusion",
+                classRefCheckOperand.at("/operation").asText());
+        assertEquals(0, classRefCheckOperand.at("/frames").size());
+    }
+    
+    @Test
+    public void testOPOVWithExclusionX ()
+            throws JsonProcessingException, IOException {
+        query = "wegen #OV(%, X) <s>";
+        qs.setQuery(query, "cosmas2");
+        res = mapper.readTree(qs.toJSON());
+//        System.out.println(res);
+
+        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());
+    }
+    
+    @Test
+    public void testOPOVWithExclusionL ()
+            throws JsonProcessingException, IOException {
+        query = "wegen #OV(%, L) <s>";
+        qs.setQuery(query, "cosmas2");
+        res = mapper.readTree(qs.toJSON());
+//        System.out.println(res);
+
+        assertEquals("koral:group", res.at("/query/@type").asText());
+        assertEquals("operation:class", res.at("/query/operation").asText());
+        assertEquals(2, res.at("/query/classRefCheck").size());
+        assertEquals("classRefCheck:intersects",
+                res.at("/query/classRefCheck/0").asText());
+        assertEquals("classRefCheck:disjoint",
+                res.at("/query/classRefCheck/1").asText());
+        
+        JsonNode classRefCheckOperand = res.at("/query/operands/0");
+        assertEquals("operation:exclusion",
+                classRefCheckOperand.at("/operation").asText());
+        assertEquals(3, classRefCheckOperand.at("/frames").size());
+        assertEquals("frames:matches",
+                classRefCheckOperand.at("/frames/0").asText());
+        assertEquals("frames:alignsLeft",
+                classRefCheckOperand.at("/frames/1").asText());
+        assertEquals("frames:overlapsLeft",
+                classRefCheckOperand.at("/frames/2").asText());
+        
+        JsonNode exclusionOperands = classRefCheckOperand.at("/operands/0");
+        assertEquals("operation:class", exclusionOperands.at("/operation").asText());
+        assertEquals("wegen", exclusionOperands.at("/operands/0/wrap/key").asText());
+        assertEquals(129, exclusionOperands.at("/classOut").asInt());
+        
+        exclusionOperands = classRefCheckOperand.at("/operands/1");
+        assertEquals("s", exclusionOperands.at("/operands/0/wrap/key").asText());
+        assertEquals(130, exclusionOperands.at("/classOut").asInt());
+        
+    }
+    
+    
+    @Test
+    public void testOPOVWithExclusionR ()
+            throws JsonProcessingException, IOException {
+        query = "wegen #OV(%, R) <s>";
+        qs.setQuery(query, "cosmas2");
+        res = mapper.readTree(qs.toJSON());
+//        System.out.println(res);
+
+        assertEquals("koral:group", res.at("/query/@type").asText());
+        assertEquals("operation:class", res.at("/query/operation").asText());
+        assertEquals(2, res.at("/query/classRefCheck").size());
+        assertEquals("classRefCheck:intersects",
+                res.at("/query/classRefCheck/0").asText());
+        assertEquals("classRefCheck:disjoint",
+                res.at("/query/classRefCheck/1").asText());
+        
+        JsonNode classRefCheckOperand = res.at("/query/operands/0");
+        assertEquals("operation:exclusion",
+                classRefCheckOperand.at("/operation").asText());
+        assertEquals(3, classRefCheckOperand.at("/frames").size());
+        assertEquals("frames:matches",
+                classRefCheckOperand.at("/frames/0").asText());
+        assertEquals("frames:alignsRight",
+                classRefCheckOperand.at("/frames/1").asText());
+        assertEquals("frames:overlapsRight",
+                classRefCheckOperand.at("/frames/2").asText());
+    }
+    
+    @Test
+    public void testOPOVWithExclusionF ()
+            throws JsonProcessingException, IOException {
+        query = "wegen #OV(%, F) <s>";
+        qs.setQuery(query, "cosmas2");
+        res = mapper.readTree(qs.toJSON());
+//        System.out.println(res);
+
+        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:matches", res.at("/query/frames/0").asText());
+    }
+    
+    @Test
+    public void testOPOVWithExclusionFE ()
+            throws JsonProcessingException, IOException {
+        query = "wegen #OV(%, FE) <s>";
+        qs.setQuery(query, "cosmas2");
+        res = mapper.readTree(qs.toJSON());
+        System.out.println(res);
+
+        assertEquals("koral:group", res.at("/query/@type").asText());
+        assertEquals("operation:class", res.at("/query/operation").asText());
+        assertEquals(1, res.at("/query/classRefCheck").size());
+        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 testOPOVWithExclusionFI ()
+            throws JsonProcessingException, IOException {
+        query = "wegen #OV(%, FI) <s>";
+        qs.setQuery(query, "cosmas2");
+        res = mapper.readTree(qs.toJSON());
+//        System.out.println(res);
+
+        assertEquals("koral:group", res.at("/query/@type").asText());
+        assertEquals("operation:class", res.at("/query/operation").asText());
+        assertEquals(1, res.at("/query/classRefCheck").size());
+        assertEquals("classRefCheck:equals",
+                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());
+    }
+    
+    
+}