-
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
4 changed files
with
55 additions
and
51 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
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: 49 additions & 0 deletions
49
.../pl/touk/nussknacker/engine/flink/api/typeinformation/FlinkBaseTypeInfoRegisterTest.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,49 @@ | ||
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 FlinkBaseTypeInfoRegisterTest extends AnyFunSuite with Matchers { | ||
|
||
private val reqByNuTypesMapping: Map[Class[_], TypeInformation[_]] = Map( | ||
classOf[LocalDate] -> Types.LOCAL_DATE, | ||
classOf[LocalTime] -> Types.LOCAL_TIME, | ||
classOf[LocalDateTime] -> Types.LOCAL_DATE_TIME, | ||
) | ||
|
||
private val otherTypesMapping: Map[Class[_], TypeInformation[_]] = Map( | ||
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 base klass should return a GenericTypeInfo") { | ||
FlinkBaseTypeInfoRegister.baseTypes.foreach { base => | ||
val typeInfo = TypeInformation.of(base.klass) | ||
typeInfo shouldBe new GenericTypeInfo(base.klass) | ||
} | ||
} | ||
|
||
test("Looking for TypeInformation for a base klass with register should return a SpecificTypeInformation") { | ||
FlinkBaseTypeInfoRegister.makeSureBaseTypesAreRegistered() | ||
|
||
FlinkBaseTypeInfoRegister.baseTypes.foreach { base => | ||
val typeInfo = TypeInformation.of(base.klass) | ||
Some(typeInfo) shouldBe reqByNuTypesMapping.get(base.klass) | ||
} | ||
} | ||
|
||
test("Verify TypeInformation.of for other types") { | ||
otherTypesMapping.foreach { case (klass, expected) => | ||
val typeInfo = TypeInformation.of(klass) | ||
typeInfo shouldBe expected | ||
} | ||
} | ||
|
||
} |