@@ -5,13 +5,8 @@ import graphql.TestUtil
55import graphql.parser.Parser
66import graphql.schema.GraphQLSchema
77import graphql.validation.Validator
8- import org.junit.Assert
98import spock.lang.Specification
109
11- import static org.junit.Assert.assertEquals
12- import static org.junit.Assert.assertFalse
13- import static org.junit.Assert.assertNotNull
14- import static org.junit.Assert.assertTrue
1510
1611class QueryGeneratorTest extends Specification {
1712 def " generate query for simple type" () {
@@ -51,10 +46,10 @@ class QueryGeneratorTest extends Specification {
5146 def result = executeTest(schema, fieldPath, expectedNoOperation)
5247
5348 then :
54- assertNotNull ( result)
55- assertEquals ( " Bar" , result. usedType)
56- assertEquals ( 4 , result. totalFieldCount)
57- assertFalse ( result. reachedMaxFieldCount)
49+ result != null
50+ " Bar" == result. usedType
51+ 4 == result. totalFieldCount
52+ ! result. reachedMaxFieldCount
5853
5954 when : " operation and arguments are passed"
6055 def expectedWithOperation = """
@@ -81,7 +76,7 @@ query barTestOperation {
8176 )
8277
8378 then :
84- assertNotNull ( result)
79+ result != null
8580 }
8681
8782
@@ -113,7 +108,7 @@ query barTestOperation {
113108 def result = executeTest(schema, fieldPath, expectedNoOperation)
114109
115110 then :
116- assertNotNull ( result)
111+ result != null
117112 }
118113
119114 def " generate query field of non-nullable type" () {
@@ -144,7 +139,7 @@ query barTestOperation {
144139 def result = executeTest(schema, fieldPath, expectedNoOperation)
145140
146141 then :
147- assertNotNull ( result)
142+ result != null
148143 }
149144
150145 def " generate query for type with nested type" () {
@@ -189,7 +184,7 @@ query barTestOperation {
189184 def result = executeTest(schema, fieldPath, expected)
190185
191186 then :
192- assertNotNull ( result)
187+ result != null
193188 }
194189
195190 def " generate query for deeply nested field" () {
@@ -236,7 +231,7 @@ query barTestOperation {
236231 def result = executeTest(schema, fieldPath, expectedNoOperation)
237232
238233 then :
239- assertNotNull ( result)
234+ result != null
240235 }
241236
242237 def " straight forward cyclic dependency" () {
@@ -272,7 +267,7 @@ query barTestOperation {
272267 def result = executeTest(schema, fieldPath, expected)
273268
274269 then :
275- assertNotNull ( result)
270+ result != null
276271 }
277272
278273 def " cyclic dependency with 2 fields of the same type" () {
@@ -313,7 +308,7 @@ query barTestOperation {
313308 def result = executeTest(schema, fieldPath, expected)
314309
315310 then :
316- assertNotNull ( result)
311+ result != null
317312 }
318313
319314 def " transitive cyclic dependency" () {
@@ -370,7 +365,7 @@ query barTestOperation {
370365 def result = executeTest(schema, fieldPath, expected)
371366
372367 then :
373- assertNotNull ( result)
368+ result != null
374369 }
375370
376371 def " generate mutation and subscription for simple type" () {
@@ -411,7 +406,7 @@ mutation {
411406 def result = executeTest(schema, fieldPath, expected)
412407
413408 then :
414- assertNotNull ( result)
409+ result != null
415410
416411 when : " operation and arguments are passed"
417412
@@ -434,7 +429,7 @@ subscription {
434429 )
435430
436431 then :
437- assertNotNull ( result)
432+ result != null
438433 }
439434
440435 def " generate query containing fields with arguments" () {
@@ -471,7 +466,7 @@ subscription {
471466 def result = executeTest(schema, fieldPath, expected)
472467
473468 then :
474- assertNotNull ( result)
469+ result != null
475470 }
476471
477472 def " generate query for the 'node' field, which returns an interface" () {
@@ -530,7 +525,7 @@ subscription {
530525 result = executeTest(schema, fieldPath, null , " (id: \" 1\" )" , classifierType, expected, QueryGeneratorOptions . newBuilder(). build())
531526
532527 then :
533- assertNotNull ( result)
528+ result != null
534529
535530 when : " passing typeName on field that doesn't return an interface"
536531 fieldPath = " Query.foo"
@@ -605,7 +600,7 @@ subscription {
605600 result = executeTest(schema, fieldPath, null , null , classifierType, expected, QueryGeneratorOptions . newBuilder(). build())
606601
607602 then :
608- assertNotNull ( result)
603+ result != null
609604
610605 when : " passing typeName that is not part of the union"
611606 fieldPath = " Query.something"
@@ -657,9 +652,9 @@ subscription {
657652 def result = executeTest(schema, fieldPath, null , null , null , expected, options)
658653
659654 then :
660- assertNotNull ( result)
661- assertEquals ( 3 , result. totalFieldCount)
662- assertTrue ( result. reachedMaxFieldCount)
655+ result != null
656+ 3 == result. totalFieldCount
657+ result. reachedMaxFieldCount
663658 }
664659
665660 def " field limit enforcement may result in less fields than the MAX" () {
@@ -704,7 +699,7 @@ subscription {
704699 def result = executeTest(schema, fieldPath, null , null , null , expected, options)
705700
706701 then :
707- assertNotNull ( result)
702+ result != null
708703 }
709704
710705 def " max field limit is enforced" () {
@@ -743,9 +738,9 @@ $resultFields
743738 def result = executeTest(schema, fieldPath, expected)
744739
745740 then :
746- assertNotNull ( result)
747- assertEquals ( 10_000, result. totalFieldCount)
748- assertTrue ( result. reachedMaxFieldCount)
741+ result != null
742+ 10_000 == result. totalFieldCount
743+ result. reachedMaxFieldCount
749744 }
750745
751746 def " filter types and field" () {
@@ -800,7 +795,7 @@ $resultFields
800795 def result = executeTest(schema, fieldPath, null , null , null , expected, options)
801796
802797 then :
803- assertNotNull ( result)
798+ result != null
804799 }
805800
806801 def " union fields" () {
@@ -855,7 +850,7 @@ $resultFields
855850 def result = executeTest(schema, fieldPath, expected)
856851
857852 then :
858- assertNotNull ( result)
853+ result != null
859854 }
860855
861856 def " interface fields" () {
@@ -912,7 +907,7 @@ $resultFields
912907 def result = executeTest(schema, fieldPath, expected)
913908
914909 then :
915- assertNotNull ( result)
910+ result != null
916911 }
917912
918913 def " interface fields with a single implementing type" () {
@@ -960,7 +955,7 @@ $resultFields
960955 def result = executeTest(schema, fieldPath, expected)
961956
962957 then :
963- assertNotNull ( result)
958+ result != null
964959 }
965960
966961 def " cyclic dependency with union" () {
@@ -1018,7 +1013,7 @@ $resultFields
10181013 def result = executeTest(schema, fieldPath, expected)
10191014
10201015 then :
1021- assertNotNull ( result)
1016+ result != null
10221017 }
10231018
10241019 def " union fields with a single type in union" () {
@@ -1064,7 +1059,7 @@ $resultFields
10641059 def result = executeTest(schema, fieldPath, expected)
10651060
10661061 then :
1067- assertNotNull ( result)
1062+ result != null
10681063 }
10691064
10701065 def " generates query for large type" () {
@@ -1079,7 +1074,7 @@ $resultFields
10791074 def result = executeTest(schema, fieldPath, null , " (id: \" issue-id-1\" )" , " JiraIssue" , expected, QueryGeneratorOptions . newBuilder(). build())
10801075
10811076 then :
1082- assertNotNull ( result)
1077+ result != null
10831078 }
10841079
10851080 private static QueryGeneratorResult executeTest (
@@ -1115,7 +1110,7 @@ $resultFields
11151110
11161111 executeQuery(query, schema)
11171112
1118- assertEquals ( expected. trim(), query. trim() )
1113+ expected. trim() == query. trim()
11191114
11201115 return result
11211116 }
@@ -1126,7 +1121,7 @@ $resultFields
11261121 def errors = new Validator (). validateDocument(schema, document, Locale . ENGLISH )
11271122
11281123 if (! errors. isEmpty()) {
1129- Assert . fail (" Validation errors: " + errors. collect { it. getMessage() }. join(" , " ))
1124+ throw new Exception (" Validation errors: " + errors. collect { it. getMessage() }. join(" , " ))
11301125 }
11311126
11321127 }
0 commit comments