Skip to content

Commit c0f2dc0

Browse files
committed
Fix unit test configuration allowing testng dependency
1 parent 1e354bf commit c0f2dc0

File tree

5 files changed

+29
-34
lines changed

5 files changed

+29
-34
lines changed

pom.xml

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
34
<modelVersion>4.0.0</modelVersion>
45

56
<groupId>com.graphql-java-kickstart</groupId>
@@ -119,12 +120,6 @@
119120
<version>1.0-groovy-2.4</version>
120121
<scope>test</scope>
121122
</dependency>
122-
<dependency>
123-
<groupId>junit</groupId>
124-
<artifactId>junit</artifactId>
125-
<version>4.12</version>
126-
<scope>test</scope>
127-
</dependency>
128123
<dependency>
129124
<groupId>cglib</groupId>
130125
<artifactId>cglib-nodep</artifactId>
@@ -142,12 +137,6 @@
142137
<artifactId>reactive-streams-tck</artifactId>
143138
<version>1.0.2</version>
144139
<scope>test</scope>
145-
<exclusions>
146-
<exclusion>
147-
<groupId>org.testng</groupId>
148-
<artifactId>testng</artifactId>
149-
</exclusion>
150-
</exclusions>
151140
</dependency>
152141
</dependencies>
153142

@@ -226,17 +215,18 @@
226215
<plugin>
227216
<artifactId>maven-surefire-plugin</artifactId>
228217
<version>2.22.2</version>
218+
<dependencies>
219+
<dependency>
220+
<groupId>org.apache.maven.surefire</groupId>
221+
<artifactId>surefire-junit4</artifactId>
222+
<version>2.22.2</version>
223+
</dependency>
224+
</dependencies>
229225
<configuration>
230226
<includes>
231227
<include>**/*Spec.*</include>
232228
<include>**/*Test.*</include>
233229
</includes>
234-
<properties>
235-
<property>
236-
<name>junit</name>
237-
<value>true</value>
238-
</property>
239-
</properties>
240230
</configuration>
241231
</plugin>
242232
<plugin>
@@ -331,7 +321,8 @@
331321
</distributionManagement>
332322
<scm>
333323
<connection>scm:git:https://github.com/graphql-java-kickstart/graphql-java-tools.git</connection>
334-
<developerConnection>scm:git:https://github.com/graphql-java-kickstart/graphql-java-tools.git</developerConnection>
324+
<developerConnection>scm:git:https://github.com/graphql-java-kickstart/graphql-java-tools.git
325+
</developerConnection>
335326
<url>https://github.com/graphql-java-kickstart/graphql-java-tools</url>
336327
<tag>HEAD</tag>
337328
</scm>

src/main/kotlin/com/coxautodev/graphql/tools/MethodFieldResolver.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ internal class MethodFieldResolver(field: FieldDefinition, search: FieldResolver
9191

9292
// Add DataFetchingEnvironment/Context argument
9393
if (this.additionalLastArgument) {
94-
val lastArgumentType = this.method.parameterTypes.last()
95-
when (lastArgumentType) {
94+
when (this.method.parameterTypes.last()) {
9695
null -> throw ResolverError("Expected at least one argument but got none, this is most likely a bug with graphql-java-tools")
9796
options.contextClass -> args.add { environment -> environment.getContext() }
9897
else -> args.add { environment -> environment }

src/main/kotlin/com/coxautodev/graphql/tools/SchemaParserBuilder.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class SchemaParserBuilder constructor(private val dictionary: SchemaParserDictio
5757
* Add a GraphQL schema string directly.
5858
*/
5959
fun schemaString(string: String) = this.apply {
60-
if (!schemaString.isEmpty()) {
60+
if (schemaString.isNotEmpty()) {
6161
schemaString.append("\n")
6262
}
6363
schemaString.append(string)
@@ -180,7 +180,7 @@ class SchemaParserBuilder constructor(private val dictionary: SchemaParserDictio
180180
try {
181181
files.forEach { documents.add(parser.parseDocument(readFile(it), it)) }
182182

183-
if (!schemaString.isEmpty()) {
183+
if (schemaString.isNotEmpty()) {
184184
documents.add(parser.parseDocument(this.schemaString.toString()))
185185
}
186186
} catch (pce: ParseCancellationException) {

src/test/groovy/com/coxautodev/graphql/tools/MethodFieldResolverDataFetcherSpec.groovy

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,11 @@ class MethodFieldResolverDataFetcherSpec extends Specification {
197197
}
198198
199199
private static DataFetcher createFetcher(SchemaParserOptions options, String methodName, List<InputValueDefinition> arguments = [], GraphQLResolver<?> resolver) {
200-
def field = new FieldDefinition(methodName, new TypeName('Boolean')).with { getInputValueDefinitions().addAll(arguments); it }
200+
def field = FieldDefinition.newFieldDefinition()
201+
.name(methodName)
202+
.type(new TypeName('Boolean'))
203+
.inputValueDefinitions(arguments)
204+
.build()
201205
202206
new FieldResolverScanner(options).findFieldResolver(field, resolver instanceof GraphQLQueryResolver ? new RootResolverInfo([resolver], options) : new NormalResolverInfo(resolver, options)).createDataFetcher()
203207
}
@@ -227,12 +231,12 @@ class MethodFieldResolverDataFetcherSpec extends Specification {
227231
}
228232
ExecutionId executionId = ExecutionId.from("executionId123")
229233
ExecutionContextBuilder.newExecutionContextBuilder()
230-
.instrumentation(SimpleInstrumentation.INSTANCE)
231-
.executionId(executionId)
232-
.queryStrategy(executionStrategy)
233-
.mutationStrategy(executionStrategy)
234-
.subscriptionStrategy(executionStrategy)
235-
.build()
234+
.instrumentation(SimpleInstrumentation.INSTANCE)
235+
.executionId(executionId)
236+
.queryStrategy(executionStrategy)
237+
.mutationStrategy(executionStrategy)
238+
.subscriptionStrategy(executionStrategy)
239+
.build()
236240
}
237241
238242
class DataClass {

src/test/groovy/com/coxautodev/graphql/tools/SchemaParserBuilderSpec.groovy

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.coxautodev.graphql.tools
22

3+
import graphql.parser.InvalidSyntaxException
34
import spock.lang.Specification
45
import spock.lang.Unroll
56

@@ -16,12 +17,12 @@ class SchemaParserBuilderSpec extends Specification {
1617
.build()
1718

1819
then:
19-
def e = thrown(InvalidSchemaError)
20+
def e = thrown(InvalidSyntaxException)
2021
e.toString().contains(error)
2122

2223
where:
2324
schema | error
24-
"invalid" | "0,0:6='invalid'"
25-
"type Query {\ninvalid!\n}" | "4,20:20='!'"
25+
"invalid" | "offending token 'invalid' at line 1 column 1"
26+
"type Query {\ninvalid!\n}" | "offending token '!' at line 2 column 8"
2627
}
2728
}

0 commit comments

Comments
 (0)