Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import aQute.bnd.gradle.BundleTaskExtension
import net.ltgt.gradle.errorprone.CheckSeverity
import org.gradle.api.file.DuplicatesStrategy
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

Expand Down Expand Up @@ -127,7 +127,8 @@ dependencies {
implementation 'org.antlr:antlr4-runtime:' + antlrVersion
implementation 'com.google.guava:guava:' + guavaVersion

testImplementation 'junit:junit:4.13.2'
testImplementation 'org.junit.jupiter:junit-jupiter:5.14.1'

testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0'
testImplementation 'net.bytebuddy:byte-buddy:1.17.8'
testImplementation 'org.objenesis:objenesis:3.4'
Expand All @@ -148,7 +149,7 @@ dependencies {
testImplementation 'org.openjdk.jmh:jmh-core:1.37' // required for ArchUnit to check JMH tests

// JUnit Platform launcher required for Gradle 9
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.14.1'

antlr 'org.antlr:antlr4:' + antlrVersion

Expand All @@ -166,8 +167,6 @@ dependencies {
testImplementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
}

import aQute.bnd.gradle.BundleTaskExtension

shadowJar {
minimize()
archiveClassifier.set('')
Expand Down Expand Up @@ -362,12 +361,30 @@ tasks.register('testWithJava17', Test) {
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(17)
}
testClassesDirs = sourceSets.test.output.classesDirs
classpath = sourceSets.test.runtimeClasspath
classpath += sourceSets.jmh.output
dependsOn "jmhClasses"


dependsOn tasks.named('testClasses')

}

tasks.register('testWithJava11', Test) {
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(11)
}
testClassesDirs = sourceSets.test.output.classesDirs
classpath = sourceSets.test.runtimeClasspath

dependsOn tasks.named('testClasses')

classpath += sourceSets.jmh.output
dependsOn "jmhClasses"

}

test.dependsOn testWithJava17
test.dependsOn testWithJava11

Expand Down
4 changes: 2 additions & 2 deletions src/test/groovy/graphql/HelloWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

import graphql.schema.GraphQLObjectType;
import graphql.schema.GraphQLSchema;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.util.Map;

import static graphql.Scalars.GraphQLString;
import static graphql.schema.GraphQLFieldDefinition.newFieldDefinition;
import static graphql.schema.GraphQLObjectType.newObject;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class HelloWorld {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class JMHForkArchRuleTest extends Specification {
def importedClasses = new ClassFileImporter()
.importPackages("benchmark", "performance", "graphql.execution")


def rule = classes()
.that().areAnnotatedWith(Fork.class)
.and().areTopLevelClasses()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,8 @@ import graphql.TestUtil
import graphql.parser.Parser
import graphql.schema.GraphQLSchema
import graphql.validation.Validator
import org.junit.Assert
import spock.lang.Specification

import static org.junit.Assert.assertEquals
import static org.junit.Assert.assertFalse
import static org.junit.Assert.assertNotNull
import static org.junit.Assert.assertTrue

class QueryGeneratorTest extends Specification {
def "generate query for simple type"() {
Expand Down Expand Up @@ -51,10 +46,10 @@ class QueryGeneratorTest extends Specification {
def result = executeTest(schema, fieldPath, expectedNoOperation)

then:
assertNotNull(result)
assertEquals("Bar", result.usedType)
assertEquals(4, result.totalFieldCount)
assertFalse(result.reachedMaxFieldCount)
result != null
"Bar" == result.usedType
4 == result.totalFieldCount
!result.reachedMaxFieldCount

when: "operation and arguments are passed"
def expectedWithOperation = """
Expand All @@ -81,7 +76,7 @@ query barTestOperation {
)

then:
assertNotNull(result)
result != null
}


Expand Down Expand Up @@ -113,7 +108,7 @@ query barTestOperation {
def result = executeTest(schema, fieldPath, expectedNoOperation)

then:
assertNotNull(result)
result != null
}

def "generate query field of non-nullable type"() {
Expand Down Expand Up @@ -144,7 +139,7 @@ query barTestOperation {
def result = executeTest(schema, fieldPath, expectedNoOperation)

then:
assertNotNull(result)
result != null
}

def "generate query for type with nested type"() {
Expand Down Expand Up @@ -189,7 +184,7 @@ query barTestOperation {
def result = executeTest(schema, fieldPath, expected)

then:
assertNotNull(result)
result != null
}

def "generate query for deeply nested field"() {
Expand Down Expand Up @@ -236,7 +231,7 @@ query barTestOperation {
def result = executeTest(schema, fieldPath, expectedNoOperation)

then:
assertNotNull(result)
result != null
}

def "straight forward cyclic dependency"() {
Expand Down Expand Up @@ -272,7 +267,7 @@ query barTestOperation {
def result = executeTest(schema, fieldPath, expected)

then:
assertNotNull(result)
result != null
}

def "cyclic dependency with 2 fields of the same type"() {
Expand Down Expand Up @@ -313,7 +308,7 @@ query barTestOperation {
def result = executeTest(schema, fieldPath, expected)

then:
assertNotNull(result)
result != null
}

def "transitive cyclic dependency"() {
Expand Down Expand Up @@ -370,7 +365,7 @@ query barTestOperation {
def result = executeTest(schema, fieldPath, expected)

then:
assertNotNull(result)
result != null
}

def "generate mutation and subscription for simple type"() {
Expand Down Expand Up @@ -411,7 +406,7 @@ mutation {
def result = executeTest(schema, fieldPath, expected)

then:
assertNotNull(result)
result != null

when: "operation and arguments are passed"

Expand All @@ -434,7 +429,7 @@ subscription {
)

then:
assertNotNull(result)
result != null
}

def "generate query containing fields with arguments"() {
Expand Down Expand Up @@ -471,7 +466,7 @@ subscription {
def result = executeTest(schema, fieldPath, expected)

then:
assertNotNull(result)
result != null
}

def "generate query for the 'node' field, which returns an interface"() {
Expand Down Expand Up @@ -530,7 +525,7 @@ subscription {
result = executeTest(schema, fieldPath, null, "(id: \"1\")", classifierType, expected, QueryGeneratorOptions.newBuilder().build())

then:
assertNotNull(result)
result != null

when: "passing typeName on field that doesn't return an interface"
fieldPath = "Query.foo"
Expand Down Expand Up @@ -605,7 +600,7 @@ subscription {
result = executeTest(schema, fieldPath, null, null, classifierType, expected, QueryGeneratorOptions.newBuilder().build())

then:
assertNotNull(result)
result != null

when: "passing typeName that is not part of the union"
fieldPath = "Query.something"
Expand Down Expand Up @@ -657,9 +652,9 @@ subscription {
def result = executeTest(schema, fieldPath, null, null, null, expected, options)

then:
assertNotNull(result)
assertEquals(3, result.totalFieldCount)
assertTrue(result.reachedMaxFieldCount)
result != null
3 == result.totalFieldCount
result.reachedMaxFieldCount
}

def "field limit enforcement may result in less fields than the MAX"() {
Expand Down Expand Up @@ -704,7 +699,7 @@ subscription {
def result = executeTest(schema, fieldPath, null, null, null, expected, options)

then:
assertNotNull(result)
result != null
}

def "max field limit is enforced"() {
Expand Down Expand Up @@ -743,9 +738,9 @@ $resultFields
def result = executeTest(schema, fieldPath, expected)

then:
assertNotNull(result)
assertEquals(10_000, result.totalFieldCount)
assertTrue(result.reachedMaxFieldCount)
result != null
10_000 == result.totalFieldCount
result.reachedMaxFieldCount
}

def "filter types and field"() {
Expand Down Expand Up @@ -800,7 +795,7 @@ $resultFields
def result = executeTest(schema, fieldPath, null, null, null, expected, options)

then:
assertNotNull(result)
result != null
}

def "union fields"() {
Expand Down Expand Up @@ -855,7 +850,7 @@ $resultFields
def result = executeTest(schema, fieldPath, expected)

then:
assertNotNull(result)
result != null
}

def "interface fields"() {
Expand Down Expand Up @@ -912,7 +907,7 @@ $resultFields
def result = executeTest(schema, fieldPath, expected)

then:
assertNotNull(result)
result != null
}

def "interface fields with a single implementing type"() {
Expand Down Expand Up @@ -960,7 +955,7 @@ $resultFields
def result = executeTest(schema, fieldPath, expected)

then:
assertNotNull(result)
result != null
}

def "cyclic dependency with union"() {
Expand Down Expand Up @@ -1018,7 +1013,7 @@ $resultFields
def result = executeTest(schema, fieldPath, expected)

then:
assertNotNull(result)
result != null
}

def "union fields with a single type in union"() {
Expand Down Expand Up @@ -1064,7 +1059,7 @@ $resultFields
def result = executeTest(schema, fieldPath, expected)

then:
assertNotNull(result)
result != null
}

def "generates query for large type"() {
Expand All @@ -1079,7 +1074,7 @@ $resultFields
def result = executeTest(schema, fieldPath, null, "(id: \"issue-id-1\")", "JiraIssue", expected, QueryGeneratorOptions.newBuilder().build())

then:
assertNotNull(result)
result != null
}

private static QueryGeneratorResult executeTest(
Expand Down Expand Up @@ -1115,7 +1110,7 @@ $resultFields

executeQuery(query, schema)

assertEquals(expected.trim(), query.trim())
expected.trim() == query.trim()

return result
}
Expand All @@ -1126,7 +1121,7 @@ $resultFields
def errors = new Validator().validateDocument(schema, document, Locale.ENGLISH)

if (!errors.isEmpty()) {
Assert.fail("Validation errors: " + errors.collect { it.getMessage() }.join(", "))
throw new Exception("Validation errors: " + errors.collect { it.getMessage() }.join(", "))
}

}
Expand Down
Loading