➕ springmockk
This commit is contained in:
@@ -42,6 +42,7 @@ subprojects {
|
|||||||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
||||||
|
|
||||||
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
||||||
|
implementation("com.ninja-squad:springmockk:3.1.1")
|
||||||
|
|
||||||
// implementation("com.google.code.gson:gson:2.9.0")
|
// implementation("com.google.code.gson:gson:2.9.0")
|
||||||
// implementation("org.jetbrains:annotations:23.0.0")
|
// implementation("org.jetbrains:annotations:23.0.0")
|
||||||
|
|||||||
@@ -5,18 +5,15 @@ import com.google.gson.GsonBuilder
|
|||||||
import com.google.gson.TypeAdapter
|
import com.google.gson.TypeAdapter
|
||||||
import com.google.gson.stream.JsonReader
|
import com.google.gson.stream.JsonReader
|
||||||
import com.google.gson.stream.JsonWriter
|
import com.google.gson.stream.JsonWriter
|
||||||
import mu.KotlinLogging
|
|
||||||
import java.time.LocalDate
|
import java.time.LocalDate
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
import java.time.LocalTime
|
import java.time.LocalTime
|
||||||
import java.time.format.DateTimeFormatter
|
import java.time.format.DateTimeFormatter
|
||||||
|
|
||||||
object GsonUtils {
|
object GsonUtils {
|
||||||
private val logger = KotlinLogging.logger {}
|
private const val patternDate = "yyyy-MM-dd"
|
||||||
|
private const val patternTime = "HH:mm:ss"
|
||||||
private val patternDate = "yyyy-MM-dd"
|
private const val patternDateTime = "yyyy-MM-dd HH:mm:ss"
|
||||||
private val patternTime = "HH:mm:ss"
|
|
||||||
private val patternDateTime = "yyyy-MM-dd HH:mm:ss"
|
|
||||||
|
|
||||||
private val gson = GsonBuilder()
|
private val gson = GsonBuilder()
|
||||||
.disableHtmlEscaping()
|
.disableHtmlEscaping()
|
||||||
@@ -34,20 +31,6 @@ object GsonUtils {
|
|||||||
fun <T> fromJson(str: String, clazz: Class<T>): T {
|
fun <T> fromJson(str: String, clazz: Class<T>): T {
|
||||||
return gson.fromJson(str, clazz)
|
return gson.fromJson(str, clazz)
|
||||||
}
|
}
|
||||||
|
|
||||||
// fun toJson(obj: Any): String? {
|
|
||||||
// val result = gson.toJson(obj)
|
|
||||||
// return if("null" == result) null else result
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// fun <T> fromJson(str: String, clazz: Class<T>): T? {
|
|
||||||
// try {
|
|
||||||
// return gson.fromJson(str, clazz)
|
|
||||||
// } catch (e: JsonSyntaxException) {
|
|
||||||
// logger.error{ e.message }
|
|
||||||
// }
|
|
||||||
// return null
|
|
||||||
// }
|
|
||||||
|
|
||||||
class LocalDateAdapter : TypeAdapter<LocalDate>() {
|
class LocalDateAdapter : TypeAdapter<LocalDate>() {
|
||||||
private val format: DateTimeFormatter = DateTimeFormatter.ofPattern(patternDate)
|
private val format: DateTimeFormatter = DateTimeFormatter.ofPattern(patternDate)
|
||||||
|
|||||||
Reference in New Issue
Block a user