Skip to content

Commit

Permalink
Upgrade to kotlin 2 (#2054)
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-humla authored Nov 7, 2024
1 parent 2318398 commit 275e2ab
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 34 deletions.

This file was deleted.

4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ graphql-java = "22.1"
graalvm = "0.10.2"
jackson = "2.17.1"
# kotlin version has to match the compile-testing compiler version
kotlin = "1.9.24"
kotlin = "2.0.0"
kotlinx-benchmark = "0.4.11"
kotlinx-coroutines = "1.8.1"
# TODO kotlin 1.9 upgrade: fix GraphQLTestUtils and GenerateKotlinxClientIT
Expand All @@ -29,7 +29,7 @@ spring-boot = "3.2.7"
commons-codec = { strictly = "[1.13, 2[", prefer = "1.16.0" }

# test dependencies
compile-testing = "0.5.0"
compile-testing = "0.5.1"
icu = "75.1"
junit = "5.10.2"
logback = "1.5.6"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ internal class MetadataCapturingDataFetcherFactoryProvider(val scanResult: ScanR
// we need to capture enums
private val additionalTypes: MutableSet<String> = HashSet()

@OptIn(ExperimentalStdlibApi::class)
override fun functionDataFetcherFactory(target: Any?, kClass: KClass<*>, kFunction: KFunction<*>): DataFetcherFactory<Any?> {
val methodName = kFunction.javaMethod!!.name
val classMetadata = reflectMetadataMap.getOrPut(kClass.java.name) { MutableClassMetadata(name = kClass.java.name, methods = ArrayList()) }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import com.expediagroup.graphql.plugin.graalvm.MetadataCapturingDataFetcherFactoryProvider
import com.expediagroup.graphql.plugin.graalvm.enums.EnumQuery
import io.github.classgraph.ClassGraph
import io.github.classgraph.ScanResult
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import kotlin.reflect.KFunction

class MetadataCapturingDataFetcherFactoryProviderTest {

private lateinit var scanResult: ScanResult
private lateinit var provider: MetadataCapturingDataFetcherFactoryProvider

@BeforeEach
fun setup() {
scanResult = ClassGraph().enableAllInfo().acceptPackages("com.expediagroup.graphql.plugin.graalvm").scan()
provider = MetadataCapturingDataFetcherFactoryProvider(scanResult, listOf("com.expediagroup.graphql.plugin.graalvm"))

val kClass = EnumQuery::class
val kFunction = kClass.members.find { it.name == "enumArgQuery" } as KFunction<*>
provider.functionDataFetcherFactory(null, kClass, kFunction)
}

@Test
fun `reflectMetadata should not be empty`() {
val metadata = provider.reflectMetadata()

Assertions.assertNotNull(metadata)
Assertions.assertTrue(metadata.isNotEmpty(), "Reflect metadata should not be empty")
Assertions.assertEquals(listOf("com.expediagroup.graphql.plugin.graalvm"), provider.supportedPackages)
}
}

0 comments on commit 275e2ab

Please sign in to comment.