Skip to content

Commit

Permalink
Merge pull request #181 from ameytotawar/assert_for_outgoing_queries_…
Browse files Browse the repository at this point in the history
…202310

test: add assert for outgoing queries in integration tests - (Issue #179)
  • Loading branch information
ashpak-shaikh authored Oct 26, 2023
2 parents c75b8ae + ec8d424 commit d9b316b
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.intuit.graphql.orchestrator.integration

import com.intuit.graphql.orchestrator.GraphQLOrchestrator
import com.intuit.graphql.orchestrator.testhelpers.SimpleMockServiceProvider
import graphql.ExecutionInput
import graphql.ExecutionResult
import graphql.schema.GraphQLArgument
Expand Down Expand Up @@ -64,6 +65,8 @@ class CustomScalarsSpec extends BaseIntegrationTestSpecification {
ExecutionResult executionResult = specUnderTest.execute(executionInput).get()

then:
compareQueryToExecutionInput(null,
"query QUERY { uuid url }", (SimpleMockServiceProvider) testService)
executionResult.getErrors().isEmpty()
Map<String, Object> data = executionResult.getData()
data.uuid instanceof String && data.uuid == "123e4567-e89b-12d3-a456-426614174000"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.intuit.graphql.orchestrator.integration

import com.intuit.graphql.orchestrator.GraphQLOrchestrator
import com.intuit.graphql.orchestrator.testhelpers.SimpleMockServiceProvider
import graphql.ExecutionInput
import graphql.ExecutionResult
import helpers.BaseIntegrationTestSpecification
Expand Down Expand Up @@ -53,6 +54,9 @@ class DeprecatedSpec extends BaseIntegrationTestSpecification {
ExecutionResult executionResult = specUnderTest.execute(executionInput).get()

then:
compareQueryToExecutionInput(null,
'query TestQuery($a1: String, $a2: InputType) {x(arg1: $a1, arg2: $a2)}',
(SimpleMockServiceProvider) testService)
executionResult.getErrors().isEmpty()
Map<String, Object> data = executionResult.getData()
data.x instanceof String && data.x == "some value for x"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.intuit.graphql.orchestrator.integration

import com.intuit.graphql.orchestrator.GraphQLOrchestrator
import com.intuit.graphql.orchestrator.testhelpers.SimpleMockServiceProvider
import graphql.ExecutionInput
import graphql.ExecutionResult
import graphql.language.Directive
Expand Down Expand Up @@ -51,6 +52,9 @@ class DirectivesOnVariableDefinitionSpec extends BaseIntegrationTestSpecificatio
ExecutionResult executionResult = specUnderTest.execute(executionInput).get()

then:
compareQueryToExecutionInput(null,
'query TestQuery($stringVar: String @directiveOnVar(dirArg : "dirArgValue")){field(stringArg: $stringVar)}',
(SimpleMockServiceProvider) testService)
executionResult.getErrors().isEmpty()
Map<String, Object> data = executionResult.getData()
data.field instanceof String && data.field == "SomeString"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.intuit.graphql.orchestrator.integration

import com.intuit.graphql.orchestrator.GraphQLOrchestrator
import com.intuit.graphql.orchestrator.testhelpers.SimpleMockServiceProvider
import graphql.ExecutionInput
import graphql.ExecutionResult
import helpers.BaseIntegrationTestSpecification
Expand Down Expand Up @@ -69,6 +70,12 @@ class DownstreamVariableSplittingSpec extends BaseIntegrationTestSpecification {
ExecutionResult executionResult = specUnderTest.execute(executionInput).get()

then:
compareQueryToExecutionInput(null,
'query TestQuery($objectVarA: InputA){fieldA(objectArgA: $objectVarA)}',
(SimpleMockServiceProvider) testServiceA)
compareQueryToExecutionInput(null,
'query TestQuery($stringVarB: String){fieldB(stringArgB: $stringVarB)}',
(SimpleMockServiceProvider) testServiceB)
executionResult.getErrors().isEmpty()
Map<String, Object> data = executionResult.getData()
data.fieldA instanceof String && data.fieldA == "SomeStringA"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ class XtextConflictResolverSpec extends BaseIntegrationTestSpecification {
ExecutionResult executionResult = specUnderTest.execute(executionInput).get()

then:
compareQueryToExecutionInput(null,
"query QUERY { a { test alpha } }", (SimpleMockServiceProvider) serviceA)
compareQueryToExecutionInput(null,
null, (SimpleMockServiceProvider) serviceB)
executionResult.getErrors().isEmpty()

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

then:
compareQueryToExecutionInput(null,
null, (SimpleMockServiceProvider) serviceA)
compareQueryToExecutionInput(null,
"query QUERY { b { test beta } }", (SimpleMockServiceProvider) serviceB)
executionResult.getErrors().isEmpty()

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

then:
compareQueryToExecutionInput(null,
"query QUERY { a { test alpha } }", (SimpleMockServiceProvider) serviceA)
compareQueryToExecutionInput(null,
null, (SimpleMockServiceProvider) serviceB)
executionResult.getErrors().isEmpty()

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

then:
compareQueryToExecutionInput(null,
null, (SimpleMockServiceProvider) serviceA)
compareQueryToExecutionInput(null,
"query QUERY { bb { test beta } }", (SimpleMockServiceProvider) serviceB)
executionResult.getErrors().isEmpty()

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

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

then:
compareQueryToExecutionInput(null,
null, (SimpleMockServiceProvider) serviceA)
compareQueryToExecutionInput(null,
"fragment NameFragment on ITheName { name } query QUERY { b {...NameFragment test beta}}", (SimpleMockServiceProvider) serviceB)
executionResult.getErrors().isEmpty()
Map<String, Object> data = executionResult.getData()
data.b?.name instanceof String && data.b?.name == "B B"
Expand Down

0 comments on commit d9b316b

Please sign in to comment.