Skip to content

Commit 00b1731

Browse files
authored
build: migrate remaining gradle plugin integration tests (#1658)
### 📝 Description Migrate last remaining Gradle integration tests to a composite build. ### 🔗 Related Issues * #1654 * #1656 * #1657
1 parent 6c54938 commit 00b1731

File tree

80 files changed

+1541
-2352
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+1541
-2352
lines changed

gradle/libs.versions.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ icu = "71.1"
3030
junit = "5.8.2"
3131
logback = "1.2.1"
3232
mockk = "1.12.5"
33-
mustache = "0.9.10"
3433
rxjava = "3.1.5"
3534
wiremock = "2.33.2"
3635

@@ -97,7 +96,6 @@ ktor-server-cio = { group = "io.ktor", name = "ktor-server-cio", version.ref = "
9796
ktor-server-netty = { group = "io.ktor", name = "ktor-server-netty", version.ref = "ktor" }
9897
ktor-server-test-host = { group = "io.ktor", name = "ktor-server-test-host", version.ref = "ktor" }
9998
mockk = { group = "io.mockk", name = "mockk", version.ref = "mockk" }
100-
mustache = { group = "com.github.spullara.mustache.java", name = "compiler", version.ref = "mustache" }
10199
reactor-core = { group = "io.projectreactor", name = "reactor-core", version.ref = "reactor-core" }
102100
reactor-extensions = { group = "io.projectreactor.kotlin", name = "reactor-kotlin-extensions", version.ref = "reactor-extensions" }
103101
reactor-test = { group = "io.projectreactor", name = "reactor-test", version.ref = "reactor-core" }

integration/gradle-plugin-integration-tests/client-generator/custom-scalars-kotlinx/src/main/kotlin/com/expediagroup/scalars/KtorGraphQLServer.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.expediagroup.scalars
22

33
import com.expediagroup.graphql.generator.SchemaGeneratorConfig
44
import com.expediagroup.graphql.generator.TopLevelObject
5-
import com.expediagroup.graphql.generator.scalars.ID
65
import com.expediagroup.graphql.generator.scalars.IDValueUnboxer
76
import com.expediagroup.graphql.generator.toSchema
87
import com.expediagroup.graphql.server.execution.GraphQLContextFactory
@@ -13,8 +12,6 @@ import com.expediagroup.graphql.server.types.GraphQLServerRequest
1312
import com.expediagroup.scalars.queries.ScalarQuery
1413
import com.fasterxml.jackson.databind.ObjectMapper
1514
import graphql.GraphQL
16-
import graphql.execution.DefaultValueUnboxer
17-
import graphql.execution.ValueUnboxer
1815
import io.ktor.server.request.ApplicationRequest
1916
import io.ktor.server.request.receiveText
2017
import java.io.IOException

integration/gradle-plugin-integration-tests/client-generator/custom-scalars-kotlinx/src/test/kotlin/com/expediagroup/scalars/CustomScalarKotlinxTests.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@ class CustomScalarKotlinxTests {
3131

3232
@Test
3333
fun `verify custom scalars are correctly serialized and deserialized`() {
34-
val engine = embeddedServer(CIO, port = 8080, module = Application::graphQLModule)
34+
val engine = embeddedServer(CIO, port = 0, module = Application::graphQLModule)
3535
try {
3636
engine.start()
3737
runBlocking {
38-
val client = GraphQLKtorClient(url = URL("http://localhost:8080/graphql"))
38+
val port = engine.resolvedConnectors().first().port
39+
val client = GraphQLKtorClient(url = URL("http://localhost:$port/graphql"))
3940

4041
val undefinedLocaleQuery = LocaleQuery(variables = LocaleQuery.Variables())
4142
val undefinedLocaleResult = client.execute(undefinedLocaleQuery)
@@ -56,11 +57,12 @@ class CustomScalarKotlinxTests {
5657

5758
@Test
5859
fun `verify undefined optionals are correctly serialized and deserialized`() {
59-
val engine = embeddedServer(CIO, port = 8080, module = Application::graphQLModule)
60+
val engine = embeddedServer(CIO, port = 0, module = Application::graphQLModule)
6061
try {
6162
engine.start()
6263
runBlocking {
63-
val client = GraphQLKtorClient(url = URL("http://localhost:8080/graphql"))
64+
val port = engine.resolvedConnectors().first().port
65+
val client = GraphQLKtorClient(url = URL("http://localhost:$port/graphql"))
6466

6567
val undefinedWrapperQuery = OptionalScalarQuery(variables = OptionalScalarQuery.Variables())
6668
val undefinedWrapperResult = client.execute(undefinedWrapperQuery).data?.optionalScalarQuery
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import com.expediagroup.graphql.plugin.gradle.config.GraphQLSerializer
2+
3+
plugins {
4+
id 'com.expediagroup.graphql'
5+
alias(libs.plugins.kotlin.jvm)
6+
}
7+
8+
dependencies {
9+
implementation "com.expediagroup:graphql-kotlin-spring-client"
10+
implementation(libs.kotlin.stdlib)
11+
}
12+
13+
graphql {
14+
client {
15+
schemaFile = file("${project.projectDir}/schema.graphql")
16+
packageName = "com.expediagroup.generated"
17+
// optional configuration
18+
allowDeprecatedFields = true
19+
headers = ["X-Custom-Header": "My-Custom-Header-Value"]
20+
queryFiles = [
21+
file("${project.projectDir}/src/main/resources/queries/HelloWorldQuery.graphql"),
22+
file("${project.projectDir}/src/main/resources/queries/UpdateNameMutation.graphql")
23+
]
24+
serializer = GraphQLSerializer.JACKSON
25+
timeout { t ->
26+
t.connect = 10000
27+
t.read = 30000
28+
}
29+
}
30+
}
31+
32+
tasks.named("test", Test) {
33+
dependsOn("graphqlGenerateClient")
34+
35+
doLast {
36+
// verify files were generated
37+
if (!new File(project.buildDir, "generated/source/graphql/main/com/expediagroup/generated/HelloWorldQuery.kt").exists()) {
38+
throw new RuntimeException("failed to generate client for HelloWorldQuery")
39+
}
40+
if (!new File(project.buildDir, "generated/source/graphql/main/com/expediagroup/generated/UpdateNameMutation.kt").exists()) {
41+
throw new RuntimeException("failed to generate client for UpdateNameMutation")
42+
}
43+
}
44+
}
45+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
type Query {
2+
helloWorld(name: String): String! @deprecated(reason: "this is a test schema")
3+
}
4+
5+
type Mutation {
6+
updateName(name: String!): String!
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
query HelloWorldQuery {
2+
helloWorld
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
mutation UpdateNameMutation($name: String!) {
2+
updateName(name: $name)
3+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import com.expediagroup.graphql.plugin.gradle.config.GraphQLSerializer
2+
3+
plugins {
4+
id 'com.expediagroup.graphql'
5+
alias(libs.plugins.kotlin.jvm)
6+
}
7+
8+
dependencies {
9+
implementation "com.expediagroup:graphql-kotlin-spring-client"
10+
implementation(libs.kotlin.stdlib)
11+
}
12+
13+
graphqlGenerateClient {
14+
packageName = "com.expediagroup.generated"
15+
schemaFile = file("${project.projectDir}/schema.graphql")
16+
// optional config
17+
allowDeprecatedFields = true
18+
serializer = GraphQLSerializer.JACKSON
19+
queryFiles.from("${project.projectDir}/src/main/resources/queries/HelloWorldQuery.graphql",
20+
"${project.projectDir}/src/main/resources/queries/UpdateNameMutation.graphql")
21+
}
22+
23+
tasks.named("test", Test) {
24+
dependsOn("graphqlGenerateClient")
25+
26+
doLast {
27+
// verify files were generated
28+
if (!new File(project.buildDir, "generated/source/graphql/main/com/expediagroup/generated/HelloWorldQuery.kt").exists()) {
29+
throw new RuntimeException("failed to generate client for HelloWorldQuery")
30+
}
31+
if (!new File(project.buildDir, "generated/source/graphql/main/com/expediagroup/generated/UpdateNameMutation.kt").exists()) {
32+
throw new RuntimeException("failed to generate client for UpdateNameMutation")
33+
}
34+
}
35+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
type Query {
2+
helloWorld(name: String): String! @deprecated(reason: "this is a test schema")
3+
}
4+
5+
type Mutation {
6+
updateName(name: String!): String!
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
query HelloWorldQuery {
2+
helloWorld
3+
}

0 commit comments

Comments
 (0)