diff --git a/aql/convertQuery_test.go b/aql/convertQuery_test.go index 65c891864dc52c895fc3bb152e8672a7d3ecb515..f083a12123332994a623938178fdd1c973e02887 100644 --- a/aql/convertQuery_test.go +++ b/aql/convertQuery_test.go @@ -1053,6 +1053,90 @@ func TestNoRelationsField(t *testing.T) { assert.Equal(t, correctConvertedResult, cleanedResult) } +/* +Tests a query with double WITH + t: *testing.T, makes go recognise this as a test +*/ +func TestDoubleWITH(t *testing.T) { + // Setup for test + // Create query conversion service + service := NewService() + + query := []byte(`{ + "databaseName": "test", + "return": { + "entities": [ + 0, + 1, + 2, + 3 + ], + "relations": [ + 0, + 1 + ] + }, + "entities": [ + { + "type": "kamerleden", + "constraints": [] + }, + { + "type": "partijen", + "constraints": [] + } + , + { + "type": "kamerleden", + "constraints": [] + }, + { + "type": "commissies", + "constraints": [] + } + ], + "relations": [ + { + "type": "lid_van", + "depth": { + "min": 1, + "max": 1 + }, + "entityFrom": 0, + "entityTo": 1, + "constraints": [] + }, + { + "type": "onderdeel_van", + "depth": { + "min": 1, + "max": 1 + }, + "entityFrom": 2, + "entityTo": 3, + "constraints": [] + } + ], + "limit": 5000, + "modifiers": [] + }`) + + // Unmarshall the incoming message into an IncomingJSONQuery object + var JSONQuery entity.IncomingQueryJSON + json.Unmarshal(query, &JSONQuery) + + convertedResult, err := service.ConvertQuery(&JSONQuery) + + // Assert that there is no error + assert.NoError(t, err) + + // Assert that the result and the expected result are the same + correctConvertedResult := "WITH partijen, commissiesLET n0 = (FOR x IN kamerleden RETURN x)LET r0 = (FOR x IN n0 FOR v, e, p IN 1..1 OUTBOUND x lid_van OPTIONS { uniqueEdges: \"path\" }LIMIT 5000 RETURN DISTINCT p )LET n2 = (FOR x IN kamerleden RETURN x)LET r1 = (FOR x IN n2 FOR v, e, p IN 1..1 OUTBOUND x onderdeel_van OPTIONS { uniqueEdges: \"path\" }LIMIT 5000 RETURN DISTINCT p )LET nodes = first(RETURN UNION_DISTINCT(flatten(r0[**].vertices), flatten(r1[**].vertices), [],[]))LET edges = first(RETURN UNION_DISTINCT(flatten(r0[**].edges), flatten(r1[**].edges), [],[]))RETURN {\"vertices\":nodes, \"edges\":edges }" + cleanedResult := strings.ReplaceAll(*convertedResult, "\n", "") + cleanedResult = strings.ReplaceAll(cleanedResult, "\t", "") + assert.Equal(t, correctConvertedResult, cleanedResult) +} + /* Tests an entity with a lower than -1 in a relation t: *testing.T, makes go recognise this as a test diff --git a/aql/debug.test b/aql/debug.test new file mode 100644 index 0000000000000000000000000000000000000000..934cd9a89adf48e864e89ee0528ad2681abfaa01 Binary files /dev/null and b/aql/debug.test differ