Skip to content

Commit 6525401

Browse files
committed
Added Movies TCK Test
1 parent 23b5201 commit 6525401

File tree

4 files changed

+99
-31
lines changed

4 files changed

+99
-31
lines changed

readme.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,14 @@ curl -XPOST http://localhost:4567/graphql -d'{"query":"{person {name}}"}'
202202
* aliases
203203
* inline and named fragments
204204
* auto-generate queries
205+
* @cypher for fields
206+
* auto-generate mutations
205207

206208
=== Next
207209

208-
* auto-generate mutations
209210
* sorting (nested)
210211
* interfaces
211212
* input types
212-
* @cypher for fields
213213
* unions
214214
* scalars
215215
* date(time), spatial

src/test/kotlin/org/neo4j/graphql/MovieSchemaTest.kt

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,33 +28,11 @@ class MovieSchemaTest {
2828
))
2929
}
3030

31-
/*
32-
@Test fun `testsimple Cypher query`() { val graphQLQuery = """{ Movie(title: "River Runs Through It, A") { title } }""", expectedCypherQuery = """MATCH (movie:Movie {title:${"$"}title}) RETURN movie { .title } AS movie SKIP ${"$"}offset""";
33-
34-
testTranslation(graphQLQuery, expectedCypherQuery, mapOf(
35-
"title" to "River Runs Through It, A",
36-
"first" to -1,
37-
"offset" to 0
38-
))
39-
}
40-
41-
fun `testSimple skip limit`() {
42-
val graphQLQuery = """{
43-
Movie("title" to "River Runs Through It, A", first: 1, offset: 0) {
44-
title
45-
year
46-
}
47-
}
48-
"""val expectedCypherQuery =
49-
"""MATCH (movie:Movie {title:${"$"}title}) RETURN movie { .title , .year } AS movie SKIP ${"$"}offset LIMIT ${"$"}first""";
50-
51-
testTranslation(graphQLQuery, expectedCypherQuery, mapOf(
52-
"title" to "River Runs Through It, A",
53-
first: 1,
54-
"offset" to 0
55-
))
56-
}
31+
@Test fun testTck() {
32+
TckTest(schema).testTck("movie-test.md",0, false)
33+
}
5734

35+
/*
5836
fun `testCypher projection skip limit`() {
5937
val graphQLQuery = """{
6038
Movie(title: "River Runs Through It, A") {

src/test/kotlin/org/neo4j/graphql/TckTest.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,25 @@ class TckTest(val schema:String) {
4040
return testData
4141
}
4242

43-
public fun testTck(fileName: String, expectedFailures: Int) {
43+
public fun testTck(fileName: String, expectedFailures: Int, fail:Boolean = false) {
4444
val pairs = loadQueryPairsFrom(fileName)
4545
val failed = pairs.map {
4646
try {
4747
assertQuery(schema, it.first, it.second, it.third); null
4848
} catch (ae: Throwable) {
49-
ae.message
49+
if (fail) throw ae else ae.message
5050
}
5151
}
5252
.filterNotNull()
5353
failed.forEach(::println)
54+
println("""Succeeded in "$fileName": ${pairs.size - failed.size} of ${pairs.size}""")
5455
Assert.assertEquals("${failed.size} failed of ${pairs.size}", expectedFailures, failed.size)
5556
}
5657

5758
companion object {
5859
fun assertQuery(schema:String, query: String, expected: String, params : Map<String,Any?> = emptyMap()) {
5960
val result = Translator(SchemaBuilder.buildSchema(schema)).translate(query).first()
60-
Assert.assertEquals(expected, result.query)
61+
Assert.assertEquals(expected.replace(Regex("\\s+")," "), result.query)
6162
Assert.assertTrue("${params} IN ${result.params}", result.params.entries.containsAll(params.entries))
6263
}
6364
}

src/test/resources/movie-test.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
## Filter Test TCK
2+
3+
4+
### Schema
5+
```schema
6+
7+
```
8+
9+
### Basic Test
10+
11+
```graphql
12+
{ Movie(title: "River Runs Through It, A") { title } }
13+
```
14+
```params
15+
{"movieTitle":"River Runs Through It, A"}
16+
```
17+
```cypher
18+
MATCH (movie:Movie)
19+
WHERE movie.title = $movieTitle
20+
RETURN movie { .title } AS movie
21+
```
22+
23+
### Testing Paging
24+
25+
```graphql
26+
{
27+
Movie("title" to "River Runs Through It, A", first: 1, offset: 0) {
28+
title
29+
year
30+
}
31+
}
32+
```
33+
34+
```params
35+
{"movieTitle": "River Runs Through It, A", "first": 1, "offset": 0}
36+
```
37+
38+
```cypher
39+
MATCH (movie:Movie)
40+
WHERE movie.title = $movieTitle
41+
RETURN movie { .title , .year } AS movie
42+
SKIP $offset LIMIT $first
43+
```
44+
45+
### Testing Projection
46+
47+
```graphql
48+
{
49+
Movie(title: "River Runs Through It, A") {
50+
title
51+
actors {
52+
name
53+
}
54+
}
55+
}
56+
```
57+
58+
```params
59+
{"movieTitle": "River Runs Through It, A"}
60+
```
61+
62+
```cypher
63+
MATCH (movie:Movie)
64+
WHERE movie.title = $movieTitle
65+
RETURN movie { .title,actors:[(movie)<-[:ACTED_IN]-(movieActors:Actor) | movieActors { .name }] } AS movie
66+
```
67+
68+
### Testing Projection with sub-paging
69+
70+
```graphql
71+
{
72+
Movie(title: "River Runs Through It, A") {
73+
title
74+
actors(first:3) {
75+
name
76+
}
77+
}
78+
}
79+
```
80+
#### todo ,"actorsFirst":3
81+
```params
82+
{"movieTitle": "River Runs Through It, A"}
83+
```
84+
85+
```cypher
86+
MATCH (movie:Movie)
87+
WHERE movie.title = $movieTitle
88+
RETURN movie { .title,actors:[(movie)<-[:ACTED_IN]-(movieActors:Actor) | movieActors { .name }][0..3] } AS movie
89+
```

0 commit comments

Comments
 (0)