Added relation deserialization tests.
Change-Id: I4cc6128956513f46af760e235a27ac886d50eac6
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestSpanRelationQueryJSON.java b/src/test/java/de/ids_mannheim/korap/query/TestSpanRelationQueryJSON.java
index b051509..3ba5a66 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestSpanRelationQueryJSON.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestSpanRelationQueryJSON.java
@@ -12,6 +12,47 @@
public class TestSpanRelationQueryJSON {
@Test
+ public void testMatchAnyRelationSourceWithAttribute() throws QueryException {
+ String filepath = getClass().getResource(
+ "/queries/relation/any-source-with-attribute.json").getFile();
+ SpanQueryWrapper sqwi = getJSONQuery(filepath);
+ SpanQuery sq = sqwi.toQuery();
+ assertEquals(
+ "focus(#[1,2]spanSegment(focus(#2: spanSegment(spanRelation(tokens:>:mate/d:HEAD), "
+ + "spanElementWithAttribute(<tokens:c: />, spanAttribute(tokens:type:case:accusative)))), "
+ + "<tokens:c:vp />))", sq.toString());
+ }
+
+ @Test
+ public void testMatchSpecificRelationSourceWithAttribute()
+ throws QueryException {
+ String filepath = getClass().getResource(
+ "/queries/relation/specific-source-with-attribute.json")
+ .getFile();
+ SpanQueryWrapper sqwi = getJSONQuery(filepath);
+ SpanQuery sq = sqwi.toQuery();
+ assertEquals(
+ "focus(#[1,2]spanSegment(focus(#2: spanSegment(spanRelation(tokens:>:mate/d:HEAD), "
+ + "spanElementWithAttribute(<tokens:c:np />, spanAttribute(tokens:type:case:accusative)))), "
+ + "<tokens:c:vp />))", sq.toString());
+ }
+
+ @Test
+ public void testMatchAnyRelationNodeWithAttribute() throws QueryException {
+ String filepath = getClass().getResource(
+ "/queries/relation/any-node-with-attribute.json").getFile();
+ SpanQueryWrapper sqwi = getJSONQuery(filepath);
+ SpanQuery sq = sqwi.toQuery();
+ assertEquals(
+ "focus(#[1,2]spanSegment(focus(#2: spanSegment(spanRelation(tokens:>:mate/d:HEAD), "
+ + "spanElementWithAttribute(<tokens:c: />, spanAttribute(tokens:type:case:accusative)))), "
+ + "spanElementWithAttribute(<tokens:c: />, spanAttribute(tokens:type:case:accusative))))",
+ sq.toString());
+
+ System.out.println(sq.toString());
+ }
+
+ @Test
public void testMatchRelationSource () throws QueryException {
//
String filepath = getClass().getResource(
diff --git a/src/test/resources/queries/relation/any-node-with-attribute.json b/src/test/resources/queries/relation/any-node-with-attribute.json
new file mode 100644
index 0000000..f83118f
--- /dev/null
+++ b/src/test/resources/queries/relation/any-node-with-attribute.json
@@ -0,0 +1,40 @@
+{
+ "query": {
+ "@type": "koral:group",
+ "operation": "operation:relation",
+ "operands": [
+ {
+ "@type": "koral:span",
+ "layer": "c",
+ "match": "match:eq",
+ "attr": {
+ "@type": "koral:term",
+ "layer": "type",
+ "key": "case:accusative",
+ "match": "match:eq"
+ }
+ },
+ {
+ "@type": "koral:span",
+ "layer": "c",
+ "match": "match:eq",
+ "attr": {
+ "@type": "koral:term",
+ "layer": "type",
+ "key": "case:accusative",
+ "match": "match:eq"
+ }
+ }
+ ],
+ "relType": {
+ "@type": "koral:relation",
+ "wrap": {
+ "@type": "koral:term",
+ "foundry": "mate",
+ "layer": "d",
+ "key": "HEAD"
+ }
+ }
+ },
+ "meta": {}
+}
\ No newline at end of file
diff --git a/src/test/resources/queries/relation/any-source-with-attribute.json b/src/test/resources/queries/relation/any-source-with-attribute.json
new file mode 100644
index 0000000..6154f18
--- /dev/null
+++ b/src/test/resources/queries/relation/any-source-with-attribute.json
@@ -0,0 +1,34 @@
+{
+ "query": {
+ "@type": "koral:group",
+ "operation": "operation:relation",
+ "operands": [
+ {
+ "@type": "koral:span",
+ "layer": "c",
+ "match": "match:eq",
+ "attr": {
+ "@type": "koral:term",
+ "layer": "type",
+ "key": "case:accusative",
+ "match": "match:eq"
+ }
+ },
+ {
+ "@type": "koral:span",
+ "layer": "c",
+ "key": "vp"
+ }
+ ],
+ "relType": {
+ "@type": "koral:relation",
+ "wrap": {
+ "@type": "koral:term",
+ "foundry": "mate",
+ "layer": "d",
+ "key": "HEAD"
+ }
+ }
+ },
+ "meta": {}
+}
\ No newline at end of file
diff --git a/src/test/resources/queries/relation/specific-source-with-attribute.json b/src/test/resources/queries/relation/specific-source-with-attribute.json
new file mode 100644
index 0000000..930e082
--- /dev/null
+++ b/src/test/resources/queries/relation/specific-source-with-attribute.json
@@ -0,0 +1,35 @@
+{
+ "query": {
+ "@type": "koral:group",
+ "operation": "operation:relation",
+ "operands": [
+ {
+ "@type": "koral:span",
+ "layer": "c",
+ "key": "np",
+ "match": "match:eq",
+ "attr": {
+ "@type": "koral:term",
+ "layer": "type",
+ "key": "case:accusative",
+ "match": "match:eq"
+ }
+ },
+ {
+ "@type": "koral:span",
+ "layer": "c",
+ "key": "vp"
+ }
+ ],
+ "relType": {
+ "@type": "koral:relation",
+ "wrap": {
+ "@type": "koral:term",
+ "foundry": "mate",
+ "layer": "d",
+ "key": "HEAD"
+ }
+ }
+ },
+ "meta": {}
+}
\ No newline at end of file