add to json model tests

This commit is contained in:
Sambo Chea 2020-11-21 11:02:01 +07:00
parent e5710d8a26
commit a1c02b739d
2 changed files with 25 additions and 2 deletions

View File

@ -7,6 +7,8 @@ plugins {
} }
dependencies { dependencies {
implementation(project(":cubetiq-utils"))
implementation("org.springframework.boot:spring-boot-starter-web") implementation("org.springframework.boot:spring-boot-starter-web")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin") implementation("com.fasterxml.jackson.module:jackson-module-kotlin")

View File

@ -1,10 +1,31 @@
package com.cubetiqs.modules.example package com.cubetiqs.modules.example
import com.cubetiqs.enterprise.comutils.json.toJson
import com.cubetiqs.enterprise.comutils.json.toModel
import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.context.event.ApplicationReadyEvent
import org.springframework.boot.runApplication import org.springframework.boot.runApplication
import org.springframework.context.event.EventListener
@SpringBootApplication @SpringBootApplication
class SampleModuleExampleApplication class SampleModuleExampleApplication {
data class Person (
val name: String,
val age: Int,
)
@EventListener(ApplicationReadyEvent::class)
fun onApplicationReady() {
val json = """
{
"name": "Sambo",
"age": 24
}
""".trimIndent()
val node = json.toModel<Person>()
print(node)
}
}
fun main(args: Array<String>) { fun main(args: Array<String>) {
runApplication<SampleModuleExampleApplication>(*args) runApplication<SampleModuleExampleApplication>(*args)