Skip to content

Commit d9b316b

Browse files
Merge pull request #181 from ameytotawar/assert_for_outgoing_queries_202310
test: add assert for outgoing queries in integration tests - (Issue #179)
2 parents c75b8ae + ec8d424 commit d9b316b

File tree

5 files changed

+42
-0
lines changed

5 files changed

+42
-0
lines changed

src/test/groovy/com/intuit/graphql/orchestrator/integration/CustomScalarsSpec.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.intuit.graphql.orchestrator.integration
22

33
import com.intuit.graphql.orchestrator.GraphQLOrchestrator
4+
import com.intuit.graphql.orchestrator.testhelpers.SimpleMockServiceProvider
45
import graphql.ExecutionInput
56
import graphql.ExecutionResult
67
import graphql.schema.GraphQLArgument
@@ -64,6 +65,8 @@ class CustomScalarsSpec extends BaseIntegrationTestSpecification {
6465
ExecutionResult executionResult = specUnderTest.execute(executionInput).get()
6566

6667
then:
68+
compareQueryToExecutionInput(null,
69+
"query QUERY { uuid url }", (SimpleMockServiceProvider) testService)
6770
executionResult.getErrors().isEmpty()
6871
Map<String, Object> data = executionResult.getData()
6972
data.uuid instanceof String && data.uuid == "123e4567-e89b-12d3-a456-426614174000"

src/test/groovy/com/intuit/graphql/orchestrator/integration/DeprecatedSpec.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.intuit.graphql.orchestrator.integration
22

33
import com.intuit.graphql.orchestrator.GraphQLOrchestrator
4+
import com.intuit.graphql.orchestrator.testhelpers.SimpleMockServiceProvider
45
import graphql.ExecutionInput
56
import graphql.ExecutionResult
67
import helpers.BaseIntegrationTestSpecification
@@ -53,6 +54,9 @@ class DeprecatedSpec extends BaseIntegrationTestSpecification {
5354
ExecutionResult executionResult = specUnderTest.execute(executionInput).get()
5455

5556
then:
57+
compareQueryToExecutionInput(null,
58+
'query TestQuery($a1: String, $a2: InputType) {x(arg1: $a1, arg2: $a2)}',
59+
(SimpleMockServiceProvider) testService)
5660
executionResult.getErrors().isEmpty()
5761
Map<String, Object> data = executionResult.getData()
5862
data.x instanceof String && data.x == "some value for x"

src/test/groovy/com/intuit/graphql/orchestrator/integration/DirectivesOnVariableDefinitionSpec.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.intuit.graphql.orchestrator.integration
22

33
import com.intuit.graphql.orchestrator.GraphQLOrchestrator
4+
import com.intuit.graphql.orchestrator.testhelpers.SimpleMockServiceProvider
45
import graphql.ExecutionInput
56
import graphql.ExecutionResult
67
import graphql.language.Directive
@@ -51,6 +52,9 @@ class DirectivesOnVariableDefinitionSpec extends BaseIntegrationTestSpecificatio
5152
ExecutionResult executionResult = specUnderTest.execute(executionInput).get()
5253

5354
then:
55+
compareQueryToExecutionInput(null,
56+
'query TestQuery($stringVar: String @directiveOnVar(dirArg : "dirArgValue")){field(stringArg: $stringVar)}',
57+
(SimpleMockServiceProvider) testService)
5458
executionResult.getErrors().isEmpty()
5559
Map<String, Object> data = executionResult.getData()
5660
data.field instanceof String && data.field == "SomeString"

src/test/groovy/com/intuit/graphql/orchestrator/integration/DownstreamVariableSplittingSpec.groovy

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.intuit.graphql.orchestrator.integration
22

33
import com.intuit.graphql.orchestrator.GraphQLOrchestrator
4+
import com.intuit.graphql.orchestrator.testhelpers.SimpleMockServiceProvider
45
import graphql.ExecutionInput
56
import graphql.ExecutionResult
67
import helpers.BaseIntegrationTestSpecification
@@ -69,6 +70,12 @@ class DownstreamVariableSplittingSpec extends BaseIntegrationTestSpecification {
6970
ExecutionResult executionResult = specUnderTest.execute(executionInput).get()
7071

7172
then:
73+
compareQueryToExecutionInput(null,
74+
'query TestQuery($objectVarA: InputA){fieldA(objectArgA: $objectVarA)}',
75+
(SimpleMockServiceProvider) testServiceA)
76+
compareQueryToExecutionInput(null,
77+
'query TestQuery($stringVarB: String){fieldB(stringArgB: $stringVarB)}',
78+
(SimpleMockServiceProvider) testServiceB)
7279
executionResult.getErrors().isEmpty()
7380
Map<String, Object> data = executionResult.getData()
7481
data.fieldA instanceof String && data.fieldA == "SomeStringA"

src/test/groovy/com/intuit/graphql/orchestrator/integration/XtextConflictResolverSpec.groovy

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@ class XtextConflictResolverSpec extends BaseIntegrationTestSpecification {
178178
ExecutionResult executionResult = specUnderTest.execute(executionInput).get()
179179

180180
then:
181+
compareQueryToExecutionInput(null,
182+
"query QUERY { a { test alpha } }", (SimpleMockServiceProvider) serviceA)
183+
compareQueryToExecutionInput(null,
184+
null, (SimpleMockServiceProvider) serviceB)
181185
executionResult.getErrors().isEmpty()
182186

183187
specUnderTest.runtimeGraph?.getType("MyType1") != null
@@ -215,6 +219,10 @@ class XtextConflictResolverSpec extends BaseIntegrationTestSpecification {
215219
ExecutionResult executionResult = specUnderTest.execute(executionInput).get()
216220

217221
then:
222+
compareQueryToExecutionInput(null,
223+
null, (SimpleMockServiceProvider) serviceA)
224+
compareQueryToExecutionInput(null,
225+
"query QUERY { b { test beta } }", (SimpleMockServiceProvider) serviceB)
218226
executionResult.getErrors().isEmpty()
219227

220228
specUnderTest.runtimeGraph?.getType("MyType1") != null
@@ -305,6 +313,10 @@ class XtextConflictResolverSpec extends BaseIntegrationTestSpecification {
305313
ExecutionResult executionResult = specUnderTest.execute(executionInput).get()
306314

307315
then:
316+
compareQueryToExecutionInput(null,
317+
"query QUERY { a { test alpha } }", (SimpleMockServiceProvider) serviceA)
318+
compareQueryToExecutionInput(null,
319+
null, (SimpleMockServiceProvider) serviceB)
308320
executionResult.getErrors().isEmpty()
309321

310322
specUnderTest.runtimeGraph?.getExecutableSchema().getType("Query").getFieldDefinition("b") == null
@@ -342,6 +354,10 @@ class XtextConflictResolverSpec extends BaseIntegrationTestSpecification {
342354
ExecutionResult executionResult = specUnderTest.execute(executionInput).get()
343355

344356
then:
357+
compareQueryToExecutionInput(null,
358+
null, (SimpleMockServiceProvider) serviceA)
359+
compareQueryToExecutionInput(null,
360+
"query QUERY { bb { test beta } }", (SimpleMockServiceProvider) serviceB)
345361
executionResult.getErrors().isEmpty()
346362

347363
specUnderTest.runtimeGraph?.getExecutableSchema().getType("Query").getFieldDefinition("b") == null
@@ -450,6 +466,10 @@ class XtextConflictResolverSpec extends BaseIntegrationTestSpecification {
450466
ExecutionResult executionResult = specUnderTest.execute(executionInput).get()
451467

452468
then:
469+
compareQueryToExecutionInput(null,
470+
"fragment NameFragment on IName { name } query QUERY { a {...NameFragment test alpha}}", (SimpleMockServiceProvider) serviceA)
471+
compareQueryToExecutionInput(null,
472+
null, (SimpleMockServiceProvider) serviceB)
453473
executionResult.getErrors().isEmpty()
454474
Map<String, Object> data = executionResult.getData()
455475
data.a?.name instanceof String && data.a?.name == "A A"
@@ -487,6 +507,10 @@ class XtextConflictResolverSpec extends BaseIntegrationTestSpecification {
487507
ExecutionResult executionResult = specUnderTest.execute(executionInput).get()
488508

489509
then:
510+
compareQueryToExecutionInput(null,
511+
null, (SimpleMockServiceProvider) serviceA)
512+
compareQueryToExecutionInput(null,
513+
"fragment NameFragment on ITheName { name } query QUERY { b {...NameFragment test beta}}", (SimpleMockServiceProvider) serviceB)
490514
executionResult.getErrors().isEmpty()
491515
Map<String, Object> data = executionResult.getData()
492516
data.b?.name instanceof String && data.b?.name == "B B"

0 commit comments

Comments
 (0)