-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
73 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 0 additions & 49 deletions
49
.../pl/touk/nussknacker/engine/flink/api/typeinformation/FlinkBaseTypeInfoRegisterTest.scala
This file was deleted.
Oops, something went wrong.
60 changes: 60 additions & 0 deletions
60
...pl/touk/nussknacker/engine/flink/api/typeinformation/FlinkBaseTypeInfoRegistrarTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package pl.touk.nussknacker.engine.flink.api.typeinformation | ||
|
||
import org.apache.flink.api.common.typeinfo.{TypeInformation, Types} | ||
import org.apache.flink.api.java.typeutils.GenericTypeInfo | ||
import org.scalatest.funsuite.AnyFunSuite | ||
import org.scalatest.matchers.should.Matchers | ||
|
||
import java.time.{Instant, LocalDate, LocalDateTime, LocalTime} | ||
import java.sql.{Date, Time, Timestamp} | ||
|
||
class FlinkBaseTypeInfoRegistrarTest extends AnyFunSuite with Matchers { | ||
|
||
private val baseNuTypesMapping: Map[Class[_], TypeInformation[_]] = Map( | ||
classOf[LocalDate] -> Types.LOCAL_DATE, | ||
classOf[LocalTime] -> Types.LOCAL_TIME, | ||
classOf[LocalDateTime] -> Types.LOCAL_DATE_TIME, | ||
) | ||
|
||
private val baseFlinkTypesMapping: Map[Class[_], TypeInformation[_]] = Map( | ||
classOf[String] -> Types.STRING, | ||
classOf[Boolean] -> Types.BOOLEAN, | ||
classOf[Byte] -> Types.BYTE, | ||
classOf[Short] -> Types.SHORT, | ||
classOf[Integer] -> Types.INT, | ||
classOf[Long] -> Types.LONG, | ||
classOf[Float] -> Types.FLOAT, | ||
classOf[Double] -> Types.DOUBLE, | ||
classOf[Character] -> Types.CHAR, | ||
classOf[java.math.BigDecimal] -> Types.BIG_DEC, | ||
classOf[java.math.BigInteger] -> Types.BIG_INT, | ||
classOf[Instant] -> Types.INSTANT, | ||
classOf[Date] -> Types.SQL_DATE, | ||
classOf[Time] -> Types.SQL_TIME, | ||
classOf[Timestamp] -> Types.SQL_TIMESTAMP, | ||
) | ||
|
||
test("Looking for TypeInformation for a NU base class should return a GenericTypeInfo") { | ||
baseNuTypesMapping.foreach { case (klass, _) => | ||
val typeInfo = TypeInformation.of(klass) | ||
typeInfo shouldBe new GenericTypeInfo(klass) | ||
} | ||
} | ||
|
||
test("Looking for TypeInformation for a NU base class with registrar should return a specific TypeInformation") { | ||
FlinkBaseTypeInfoRegistrar.ensureBaseTypesAreRegistered() | ||
|
||
baseNuTypesMapping.foreach { case (klass, expected) => | ||
val typeInfo = TypeInformation.of(klass) | ||
typeInfo shouldBe expected | ||
} | ||
} | ||
|
||
test("Make sure that the other types have specific TypeInformation") { | ||
baseFlinkTypesMapping.foreach { case (klass, expected) => | ||
val typeInfo = TypeInformation.of(klass) | ||
typeInfo shouldBe expected | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters