@@ -25,21 +25,23 @@ class CodeGenerationTests : BaseTest() {
25
25
26
26
val personShortName = Person ::class .simpleName!!
27
27
28
- val dfName = (ColumnsContainer ::class ).qualifiedName
29
- val dfRowName = (DataRow ::class ).qualifiedName
30
- val dataCol = (DataColumn ::class ).qualifiedName!!
31
- val dataRow = (DataRow ::class ).qualifiedName!!
32
- val colGroup = (ColumnGroup ::class ).qualifiedName!!
28
+ val dfName = (ColumnsContainer ::class ).simpleName!!
29
+ val dfRowName = (DataRow ::class ).simpleName!!
30
+ val dataCol = (DataColumn ::class ).simpleName!!
31
+ val dataRow = (DataRow ::class ).simpleName!!
32
+ val colGroup = (ColumnGroup ::class ).simpleName!!
33
+ val stringName = String ::class .simpleName!!
34
+ val intName = Int ::class .simpleName!!
33
35
34
36
fun expectedProperties (fullTypeName : String , shortTypeName : String ) = """
35
- val $dfName <$fullTypeName >.age: $dataCol <kotlin.Int > @JvmName("${shortTypeName} _age") get() = this["age"] as $dataCol <kotlin.Int >
36
- val $dfRowName <$fullTypeName >.age: kotlin.Int @JvmName("${shortTypeName} _age") get() = this["age"] as kotlin.Int
37
- val $dfName <$fullTypeName >.city: $dataCol <kotlin.String ?> @JvmName("${shortTypeName} _city") get() = this["city"] as $dataCol <kotlin.String ?>
38
- val $dfRowName <$fullTypeName >.city: kotlin.String ? @JvmName("${shortTypeName} _city") get() = this["city"] as kotlin.String ?
39
- val $dfName <$fullTypeName >.name: $dataCol <kotlin.String > @JvmName("${shortTypeName} _name") get() = this["name"] as $dataCol <kotlin.String >
40
- val $dfRowName <$fullTypeName >.name: kotlin.String @JvmName("${shortTypeName} _name") get() = this["name"] as kotlin.String
41
- val $dfName <$fullTypeName >.weight: $dataCol <kotlin.Int ?> @JvmName("${shortTypeName} _weight") get() = this["weight"] as $dataCol <kotlin.Int ?>
42
- val $dfRowName <$fullTypeName >.weight: kotlin.Int ? @JvmName("${shortTypeName} _weight") get() = this["weight"] as kotlin.Int ?
37
+ val $dfName <$fullTypeName >.age: $dataCol <$intName > @JvmName("${shortTypeName} _age") get() = this["age"] as $dataCol <$intName >
38
+ val $dfRowName <$fullTypeName >.age: $intName @JvmName("${shortTypeName} _age") get() = this["age"] as $intName
39
+ val $dfName <$fullTypeName >.city: $dataCol <$stringName ?> @JvmName("${shortTypeName} _city") get() = this["city"] as $dataCol <$stringName ?>
40
+ val $dfRowName <$fullTypeName >.city: $stringName ? @JvmName("${shortTypeName} _city") get() = this["city"] as $stringName ?
41
+ val $dfName <$fullTypeName >.name: $dataCol <$stringName > @JvmName("${shortTypeName} _name") get() = this["name"] as $dataCol <$stringName >
42
+ val $dfRowName <$fullTypeName >.name: $stringName @JvmName("${shortTypeName} _name") get() = this["name"] as $stringName
43
+ val $dfName <$fullTypeName >.weight: $dataCol <$intName ?> @JvmName("${shortTypeName} _weight") get() = this["weight"] as $dataCol <$intName ?>
44
+ val $dfRowName <$fullTypeName >.weight: $intName ? @JvmName("${shortTypeName} _weight") get() = this["weight"] as $intName ?
43
45
""" .trimIndent()
44
46
45
47
@Test
@@ -95,23 +97,23 @@ class CodeGenerationTests : BaseTest() {
95
97
@DataSchema(isOpen = false)
96
98
interface $type1
97
99
98
- val $dfName <$type1 >.city: $dataCol <kotlin.String ?> @JvmName("${type1} _city") get() = this["city"] as $dataCol <kotlin.String ?>
99
- val $dfRowName <$type1 >.city: kotlin.String ? @JvmName("${type1} _city") get() = this["city"] as kotlin.String ?
100
- val $dfName <$type1 >.name: $dataCol <kotlin.String > @JvmName("${type1} _name") get() = this["name"] as $dataCol <kotlin.String >
101
- val $dfRowName <$type1 >.name: kotlin.String @JvmName("${type1} _name") get() = this["name"] as kotlin.String
100
+ val $dfName <$type1 >.city: $dataCol <$stringName ?> @JvmName("${type1} _city") get() = this["city"] as $dataCol <$stringName ?>
101
+ val $dfRowName <$type1 >.city: $stringName ? @JvmName("${type1} _city") get() = this["city"] as $stringName ?
102
+ val $dfName <$type1 >.name: $dataCol <$stringName > @JvmName("${type1} _name") get() = this["name"] as $dataCol <$stringName >
103
+ val $dfRowName <$type1 >.name: $stringName @JvmName("${type1} _name") get() = this["name"] as $stringName
102
104
103
105
""" .trimIndent()
104
106
105
107
val declaration2 = """
106
108
@DataSchema(isOpen = false)
107
109
interface $type2
108
110
109
- val $dfName <$type2 >.age: $dataCol <kotlin.Int > @JvmName("${type2} _age") get() = this["age"] as $dataCol <kotlin.Int >
110
- val $dfRowName <$type2 >.age: kotlin.Int @JvmName("${type2} _age") get() = this["age"] as kotlin.Int
111
+ val $dfName <$type2 >.age: $dataCol <$intName > @JvmName("${type2} _age") get() = this["age"] as $dataCol <$intName >
112
+ val $dfRowName <$type2 >.age: $intName @JvmName("${type2} _age") get() = this["age"] as $intName
111
113
val $dfName <$type2 >.nameAndCity: $colGroup <$type1 > @JvmName("${type2} _nameAndCity") get() = this["nameAndCity"] as $colGroup <$type1 >
112
114
val $dfRowName <$type2 >.nameAndCity: $dataRow <$type1 > @JvmName("${type2} _nameAndCity") get() = this["nameAndCity"] as $dataRow <$type1 >
113
- val $dfName <$type2 >.weight: $dataCol <kotlin.Int ?> @JvmName("${type2} _weight") get() = this["weight"] as $dataCol <kotlin.Int ?>
114
- val $dfRowName <$type2 >.weight: kotlin.Int ? @JvmName("${type2} _weight") get() = this["weight"] as kotlin.Int ?
115
+ val $dfName <$type2 >.weight: $dataCol <$intName ?> @JvmName("${type2} _weight") get() = this["weight"] as $dataCol <$intName ?>
116
+ val $dfRowName <$type2 >.weight: $intName ? @JvmName("${type2} _weight") get() = this["weight"] as $intName ?
115
117
""" .trimIndent()
116
118
117
119
val expectedConverter = " it.cast<$type2 >()"
@@ -128,7 +130,7 @@ class CodeGenerationTests : BaseTest() {
128
130
interface $personClass
129
131
""" .trimIndent() + " \n " + expectedProperties(personClassName, personShortName)
130
132
131
- val code = CodeGenerator .create().generate<Person >(InterfaceGenerationMode .NoFields , extensionProperties = true ).declarations
133
+ val code = CodeGenerator .create(useFqNames = false ).generate<Person >(InterfaceGenerationMode .NoFields , extensionProperties = true ).declarations
132
134
code shouldBe expected
133
135
}
134
136
@@ -168,7 +170,7 @@ class CodeGenerationTests : BaseTest() {
168
170
169
171
@Test
170
172
fun `empty interface with properties` () {
171
- val codeGen = CodeGenerator .create()
173
+ val codeGen = CodeGenerator .create(useFqNames = false )
172
174
val code = codeGen.generate(df.schema(), " Person" , false , true , true ).code.declarations
173
175
val expected = """
174
176
@DataSchema
0 commit comments