Skip to content

Commit

Permalink
fix: coroutines tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aoudiamoncef committed Sep 16, 2023
1 parent f2ac325 commit a1e9087
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion COPYING
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (C) 2017, Cox Automotive, Inc.
Copyright (C) 2023, Cox Automotive, Inc.
All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License

Copyright (c) 2017 Cox Automotive, Inc. https://www.coxautoinc.com
Copyright (c) 2023 Cox Automotive, Inc. https://www.coxautoinc.com

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 6 additions & 0 deletions apollo-client-maven-plugin-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-coroutines-test</artifactId>
<version>${kotlinx-coroutines-test.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ import graphql.servlet.SimpleGraphQLHttpServlet
import io.undertow.Undertow
import io.undertow.servlet.Servlets
import io.undertow.servlet.util.ImmediateInstanceFactory
import jakarta.servlet.Servlet
import kotlinx.coroutines.runBlocking
import okhttp3.OkHttpClient
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.*
import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
import java.net.InetSocketAddress
import javax.servlet.Servlet

@TestInstance(PER_CLASS)
class ApolloClientMavenPluginTest {
Expand Down Expand Up @@ -63,18 +64,11 @@ class ApolloClientMavenPluginTest {

val longCustomScalarTypeAdapter = object : Adapter<Long> {
override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Long {
return customScalarAdapters.responseAdapterFor<Long>(com.lahzouz.apollo.graphql.client.type.Long.type).fromJson(
reader,
customScalarAdapters,
)
return reader.nextLong() // Assuming the Long value is directly parseable from JSON
}

override fun toJson(writer: JsonWriter, customScalarAdapters: CustomScalarAdapters, value: Long) {
return customScalarAdapters.responseAdapterFor<Long>(com.lahzouz.apollo.graphql.client.type.Long.type).toJson(
writer,
customScalarAdapters,
value,
)
writer.value(value) // Write the Long value to JSON
}
}

Expand All @@ -92,14 +86,14 @@ class ApolloClientMavenPluginTest {

@Test
@DisplayName("generated book query returns data")
suspend fun bookQueryTest() {
fun bookQueryTest(): Unit = runBlocking {
val response = client.query(GetBooksQuery()).execute()
assertThat(response.data?.books).isNotEmpty.hasSize(4)
}

@Test
@DisplayName("generated author query returns data")
suspend fun authorQueryTest() {
fun authorQueryTest(): Unit = runBlocking {
val response = client.query(GetAuthorsQuery()).execute()
assertThat(response.data?.authors).isNotEmpty.hasSize(2)
}
Expand Down
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@
<graphql-java-tools.version>5.2.4</graphql-java-tools.version>
<jackson-databind.version>2.14.2</jackson-databind.version>
<junit.jupiter.version>5.9.2</junit.jupiter.version>
<kotlinx-coroutines-test.version>1.7.2</kotlinx-coroutines-test.version>
<moshi.version>1.14.0</moshi.version>
<okhttp.version>4.10.0</okhttp.version>
<okio.version>3.3.0</okio.version>
<slf4j-simple.version>2.0.7</slf4j-simple.version>
<undertow.version>2.3.5.Final</undertow.version>
<undertow.version>2.2.26.Final</undertow.version>

<maven-project.version>2.2.1</maven-project.version>
<maven.version>3.8.1</maven.version>
Expand Down

0 comments on commit a1e9087

Please sign in to comment.