|
1 | 1 | package org.apache.flinkx.api
|
2 | 2 |
|
3 | 3 | import org.apache.flink.api.common.typeinfo.TypeInformation
|
| 4 | +import org.apache.flinkx.api.serializer.{CoproductSerializer, ListCCSerializer, ScalaCaseClassSerializer} |
4 | 5 | import org.apache.flinkx.api.serializers.*
|
5 |
| -import org.apache.flinkx.api.typeinfo.ProductTypeInformation |
| 6 | +import org.apache.flinkx.api.typeinfo.{CoproductTypeInformation, ProductTypeInformation} |
6 | 7 | import org.scalatest.flatspec.AnyFlatSpec
|
7 | 8 | import org.scalatest.matchers.should
|
8 | 9 |
|
@@ -45,6 +46,28 @@ class GenericCaseClassScala3Test extends AnyFlatSpec with should.Matchers {
|
45 | 46 | aBasketInfo.asInstanceOf[ProductTypeInformation[A]].getFieldTypes()(0) should be theSameInstanceAs aInfo
|
46 | 47 | }
|
47 | 48 |
|
| 49 | + "Nested generics" should "be resolved correctly" in { |
| 50 | + val intTypeInfo: TypeInformation[Option[Option[Int]]] = generateTypeInfo[Int] |
| 51 | + val stringTypeInfo: TypeInformation[Option[Option[String]]] = generateTypeInfo[String] |
| 52 | + |
| 53 | + intTypeInfo shouldNot be theSameInstanceAs stringTypeInfo |
| 54 | + } |
| 55 | + |
| 56 | + it should "work with multiple type parameters" in { |
| 57 | + val intTypeInfo = generateEitherTypeInfo[Int] |
| 58 | + val boolTypeInfo = generateEitherTypeInfo[Boolean] |
| 59 | + |
| 60 | + intTypeInfo shouldNot be theSameInstanceAs boolTypeInfo |
| 61 | + |
| 62 | + } |
| 63 | + |
| 64 | + def generateTypeInfo[A: TypeInformation]: TypeInformation[Option[Option[A]]] = { |
| 65 | + deriveTypeInformation |
| 66 | + } |
| 67 | + |
| 68 | + def generateEitherTypeInfo[A: TypeInformation]: TypeInformation[Either[Option[A], Int]] = { |
| 69 | + deriveTypeInformation |
| 70 | + } |
48 | 71 | }
|
49 | 72 |
|
50 | 73 | object GenericCaseClassScala3Test {
|
|
0 commit comments