Skip to content

Commit

Permalink
migrate to assertj, disable dome modules
Browse files Browse the repository at this point in the history
  • Loading branch information
robfrank committed Nov 18, 2024
1 parent fef38b1 commit 596078c
Show file tree
Hide file tree
Showing 23 changed files with 8,878 additions and 8,789 deletions.
56 changes: 29 additions & 27 deletions common/src/main/kotlin/com/arcadeanalytics/provider/TypeMapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,36 @@ import java.util.Locale.ENGLISH

val log: Logger = LoggerFactory.getLogger("com.arcadeanalytics.provider.TypeMapper")

fun mapType(type: String): String = when (
type.trim()
.toLowerCase(ENGLISH)
.removePrefix("http://www.w3.org/2001/xmlschema#")
) {
"string", "varchar", "text", "char",
"varchar2", "nvarchar2", "clob", "nclob",
"char varying", "character varying", "ntext", "nchar",
"national char", "national character", "nvarchar", "national char varying",
"national character varying", "longvarchar", "character large object",
"mediumtext", "longtext", "tinytext",
-> "String"
fun mapType(type: String): String =
when (
type
.trim()
.lowercase(ENGLISH)
.removePrefix("http://www.w3.org/2001/xmlschema#")
) {
"string", "varchar", "text", "char",
"varchar2", "nvarchar2", "clob", "nclob",
"char varying", "character varying", "ntext", "nchar",
"national char", "national character", "nvarchar", "national char varying",
"national character varying", "longvarchar", "character large object",
"mediumtext", "longtext", "tinytext",
-> "String"

"decimal", "dec", "numeric", "real", "integer",
"int", "int2", "int4", "tinyint",
"smallint unsigned", "tinyint unsigned", "mediumint unsigned",
"float", "double precision",
"long", "smallint", "money", "smallmoney", "double",
-> "Numeric"
"decimal", "dec", "numeric", "real", "integer",
"int", "int2", "int4", "tinyint",
"smallint unsigned", "tinyint unsigned", "mediumint unsigned",
"float", "double precision",
"long", "smallint", "money", "smallmoney", "double",
-> "Numeric"

"date", "datetime", "datetime2", "timestamp", "year",
"smalldatetime", "datetimeoffset", "time with time zone",
-> "Date"
"date", "datetime", "datetime2", "timestamp", "year",
"smalldatetime", "datetimeoffset", "time with time zone",
-> "Date"

"bool", "boolean",
-> "Boolean"
else -> {
if (log.isDebugEnabled) log.debug("type not mapped:: {} ", type)
type
"bool", "boolean",
-> "Boolean"
else -> {
if (log.isDebugEnabled) log.debug("type not mapped:: {} ", type)
type
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,30 @@
package com.arcadeanalytics.provider

import org.assertj.core.api.Assertions
import org.junit.Test
import org.junit.jupiter.api.Test

class TypeMapperKtTest {

@Test
fun shouldMapNumericTypes() {
listOf(
"decimal", "dec", "numeric", "real", "integer",
"int", "int2", "int4", "tinyint",
"smallint unsigned", "tinyint unsigned", "mediumint unsigned",
"float", "double precision",
"smallint", "money", "double", "smallmoney",
"decimal",
"dec",
"numeric",
"real",
"integer",
"int",
"int2",
"int4",
"tinyint",
"smallint unsigned",
"tinyint unsigned",
"mediumint unsigned",
"float",
"double precision",
"smallint",
"money",
"double",
"smallmoney",
).forEach {
Assertions.assertThat(mapType(it)).isEqualTo("Numeric")
}
Expand All @@ -40,16 +52,31 @@ class TypeMapperKtTest {
@Test
fun shouldMapTextTypes() {
listOf(
"string", "varchar", "text", "char",
"varchar2", "nvarchar2", "clob", "nclob",
"char varying", "character varying", "ntext", "nchar",
"national char", "national character", "nvarchar", "national char varying",
"national character varying", "longvarchar", "character large object",
"mediumtext", "longtext", "tinytext",
)
.forEach {
Assertions.assertThat(mapType(it)).isEqualTo("String")
}
"string",
"varchar",
"text",
"char",
"varchar2",
"nvarchar2",
"clob",
"nclob",
"char varying",
"character varying",
"ntext",
"nchar",
"national char",
"national character",
"nvarchar",
"national char varying",
"national character varying",
"longvarchar",
"character large object",
"mediumtext",
"longtext",
"tinytext",
).forEach {
Assertions.assertThat(mapType(it)).isEqualTo("String")
}
}

@Test
Expand All @@ -63,10 +90,9 @@ class TypeMapperKtTest {
"smalldatetime",
"datetimeoffset",
"time with time zone",
)
.forEach {
Assertions.assertThat(mapType(it)).isEqualTo("Date")
}
).forEach {
Assertions.assertThat(mapType(it)).isEqualTo("Date")
}
}

@Test
Expand Down
Loading

0 comments on commit 596078c

Please sign in to comment.