From af0f1faa7262e67f6b33f908e41c7c91f44144b5 Mon Sep 17 00:00:00 2001
From: Joes <j.dejonge@students.uu.nl>
Date: Wed, 3 Nov 2021 14:36:59 +0100
Subject: [PATCH] Created test hiearchy document with first test

---
 aql/hierarchy_test.go | 87 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 87 insertions(+)
 create mode 100644 aql/hierarchy_test.go

diff --git a/aql/hierarchy_test.go b/aql/hierarchy_test.go
new file mode 100644
index 0000000..73f4c78
--- /dev/null
+++ b/aql/hierarchy_test.go
@@ -0,0 +1,87 @@
+package aql
+
+import (
+	"encoding/json"
+	"fmt"
+	"testing"
+
+	"git.science.uu.nl/graphpolaris/query-conversion/entity"
+	"github.com/stretchr/testify/assert"
+)
+
+func TestHierarchyBasic(t *testing.T) {
+	// Setup for test
+	// Create query conversion service
+	query := []byte(`{
+		"return": {
+			"entities": [
+				0,
+				1
+			],
+			"relations": [
+				0
+			],
+			"groupBys": []
+		},
+		"entities": [
+			{
+				"name": "parliament",
+				"ID": 0
+			},
+			{
+				"name": "parties",
+				"ID": 1
+			}
+		],
+		"relations": [
+			{
+				"ID": 0,
+				"name": "member_of",
+				"depth": {
+					"min": 1,
+					"max": 1
+				},
+				"fromType": "entity",
+				"fromID": 0,
+				"toType": "entity",
+				"toID": 1
+			}
+		],
+		"groupBys": [],
+		"filters": [
+			{
+				"ID": 0,
+				"filteredType": "entity",
+				"filteredID": 0,
+				"attribute": "age",
+				"dataType": "int",
+				"matchType": "NEQ",
+				"value": "40",
+				"inType": "",
+				"inID": 0
+			},
+			{
+				"ID": 1,
+				"filteredType": "relation",
+				"filteredID": 0,
+				"attribute": "isChairman",
+				"dataType": "bool",
+				"matchType": "exact",
+				"value": "true",
+				"inType": "",
+				"inID": 0
+			}
+		],
+		"limit": 5000
+	}
+	`)
+
+	// Unmarshall the incoming message into an IncomingJSONQuery object
+	var JSONQuery entity.IncomingQueryJSON
+	json.Unmarshal(query, &JSONQuery)
+	search(&JSONQuery)
+
+	// Assert that the result and the expected result are the same
+	correctResult := `[[{entity 0} {entity 1}] [{filter 0}] [{relation 0}] [{filter 1}]]`
+	assert.Equal(t, correctResult, fmt.Sprint(listoflists))
+}
-- 
GitLab