Skip to content

Instantly share code, notes, and snippets.

View dinomite's full-sized avatar

Drew Stephens dinomite

View GitHub Profile
/**
* Not thread safe due to asJson() indentation switching, but good enough for testing
*/
@NotThreadSafe
@SuppressFBWarnings(value = ["ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD"],
justification = "Findbugs doesn't understand Kotlin init")
object Json {
val objectMapper: ObjectMapper = ObjectMapper()
init {
@dinomite
dinomite / Location.kt
Last active March 12, 2019 14:50
Testing data class serialization
import java.time.Instant
data class Location(@JsonProperty val userId: Int,
@JsonProperty val geohash: String,
@JsonProperty val createdAt: Instant,
@JsonProperty val updatedAt: Instant?)
@dinomite
dinomite / Location.kt
Created March 12, 2019 14:47
Testing data classes in Kotlin
import java.time.Instant
data class Location(@JsonProperty val userId: Int,
@JsonProperty val geohash: String,
@JsonProperty val createdAt: Instant,
@JsonProperty val updatedAt: Instant?)
package com.fasterxml.jackson.module.kotlin.test.github.failing
import com.fasterxml.jackson.databind.type.TypeFactory
import com.fasterxml.jackson.module.kotlin.KotlinModule
import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
import com.fasterxml.jackson.module.kotlin.jsonMapper
import com.fasterxml.jackson.module.kotlin.readValue
import org.junit.Test
import kotlin.test.assertEquals