diff --git a/src/test/kotlin/com/github/avrokotlin/avro4k/schema/MultipleGenericsSchemaTest.kt b/src/test/kotlin/com/github/avrokotlin/avro4k/schema/MultipleGenericsSchemaTest.kt new file mode 100644 index 00000000..d591465f --- /dev/null +++ b/src/test/kotlin/com/github/avrokotlin/avro4k/schema/MultipleGenericsSchemaTest.kt @@ -0,0 +1,26 @@ +package com.github.avrokotlin.avro4k.schema + +import com.github.avrokotlin.avro4k.Avro +import com.github.avrokotlin.avro4k.AvroName +import io.kotest.matchers.shouldBe +import io.kotest.core.spec.style.FunSpec +import kotlinx.serialization.Serializable + +class MultipleGenericsSchemaTest : FunSpec({ + + test("encode different generics") { + + val schema = Avro.default.schema(WrapperTest.serializer()) + val expected = org.apache.avro.Schema.Parser().parse(javaClass.getResourceAsStream("/multiple_generics.json")) + schema.toString(true) shouldBe expected.toString(true) + } + + +}) { + @Serializable + data class GenericValue(val z: T) + + @Serializable + @AvroName("WrapperTest") + data class WrapperTest(val a: GenericValue, val b: GenericValue) +} diff --git a/src/test/resources/multiple_generics.json b/src/test/resources/multiple_generics.json new file mode 100644 index 00000000..004bf141 --- /dev/null +++ b/src/test/resources/multiple_generics.json @@ -0,0 +1,26 @@ +{ + "type" : "record", + "name" : "WrapperTest", + "namespace" : "com.github.avrokotlin.avro4k.schema.MultipleGenericsSchemaTest", + "fields" : [ { + "name" : "a", + "type" : { + "type" : "record", + "name" : "GenericValue", + "fields" : [ { + "name" : "z", + "type" : "string" + } ] + } + }, { + "name" : "b", + "type" : { + "type" : "record", + "name" : "GenericValue", + "fields" : [ { + "name" : "z", + "type" : "double" + } ] + } + } ] +} \ No newline at end of file