Compare commits
3 Commits
e880d53938
...
f64c30de1c
| Author | SHA1 | Date | |
|---|---|---|---|
| f64c30de1c | |||
| a1c02b739d | |||
| e5710d8a26 |
@@ -1,10 +1,14 @@
|
|||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
|
id("org.springframework.boot")
|
||||||
|
|
||||||
kotlin("jvm")
|
kotlin("jvm")
|
||||||
|
kotlin("plugin.spring")
|
||||||
|
kotlin("plugin.jpa")
|
||||||
}
|
}
|
||||||
|
|
||||||
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")
|
||||||
|
|
||||||
@@ -16,11 +20,4 @@ dependencies {
|
|||||||
|
|
||||||
tasks.withType<Test> {
|
tasks.withType<Test> {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<KotlinCompile> {
|
|
||||||
kotlinOptions {
|
|
||||||
freeCompilerArgs = listOf("-Xjsr305=strict")
|
|
||||||
jvmTarget = "11"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +1,25 @@
|
|||||||
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() {
|
||||||
|
println("Application running....")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
runApplication<SampleModuleExampleApplication>(*args)
|
runApplication<SampleModuleExampleApplication>(*args)
|
||||||
}
|
}
|
||||||
|
|||||||
39
src/test/kotlin/com/cubetiqs/modules/example/JsonTests.kt
Normal file
39
src/test/kotlin/com/cubetiqs/modules/example/JsonTests.kt
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
package com.cubetiqs.modules.example
|
||||||
|
|
||||||
|
import com.cubetiqs.enterprise.comutils.json.toJsonNode
|
||||||
|
import com.cubetiqs.enterprise.comutils.json.toModel
|
||||||
|
import org.junit.jupiter.api.Assertions
|
||||||
|
import org.junit.jupiter.api.Test
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest
|
||||||
|
|
||||||
|
@SpringBootTest
|
||||||
|
class JsonTests {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun jsonToModel() {
|
||||||
|
val json = """
|
||||||
|
{
|
||||||
|
"name": "Sambo",
|
||||||
|
"age": 24
|
||||||
|
}
|
||||||
|
""".trimIndent()
|
||||||
|
val node = json.toModel<SampleModuleExampleApplication.Person>()
|
||||||
|
|
||||||
|
Assertions.assertEquals(SampleModuleExampleApplication.Person("Sambo", 24), node)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun jsonToJsonNode() {
|
||||||
|
val json = """
|
||||||
|
{
|
||||||
|
"name": "Sambo",
|
||||||
|
"age": 24
|
||||||
|
}
|
||||||
|
""".trimIndent()
|
||||||
|
val node = json.toJsonNode()
|
||||||
|
|
||||||
|
Assertions.assertEquals("Sambo", node?.get("name")?.asText())
|
||||||
|
Assertions.assertEquals(24, node?.get("age")?.asInt())
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -6,8 +6,8 @@ import org.springframework.boot.test.context.SpringBootTest
|
|||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
class SampleModuleExampleApplicationTests {
|
class SampleModuleExampleApplicationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun contextLoads() {
|
fun contextLoads() {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user