1 package net.pterodactylus.rhynodge.states
3 import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
4 import com.spotify.hamcrest.jackson.JsonMatchers.jsonObject
5 import org.hamcrest.MatcherAssert.assertThat
7 import java.io.StringWriter
12 fun `json state can be serialized`() {
13 val jsonState = JsonState(jsonObject)
14 StringWriter().use { stringWriter ->
15 objectMapper.writeValue(stringWriter, jsonState)
16 val deserializedState = objectMapper.readValue(stringWriter.toString(), AbstractState::class.java) as JsonState
17 assertThat(deserializedState.jsonNode, jsonObject(jsonObject))
21 private val jsonObject = objectMapper.createObjectNode()
28 it.putObject("object")
37 private val objectMapper = jacksonObjectMapper()