Created
October 9, 2013 16:12
-
-
Save ittaiz/6903795 to your computer and use it in GitHub Desktop.
Test showing classes with an option[JsonNode] stopped serializing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.fasterxml.jackson.databind.{ObjectMapper, JsonNode} | |
import scala.Some | |
import org.specs2.mutable.SpecificationWithJUnit | |
import com.fasterxml.jackson.module.scala.DefaultScalaModule | |
class JsonNodeOptionDeserializerTest extends SpecificationWithJUnit { | |
"Option[JsonNode] " should { | |
"serialize its content when contained in an object" in { | |
val mapper = new ObjectMapper().registerModule(DefaultScalaModule) | |
val json: String = """{"prop":"value"}""" | |
val tree: JsonNode = mapper.readTree( json) | |
val wrapperOfOptionOfJsonNode = WrapperOfOptionOfJsonNode(Some(tree)) | |
val actualJson: String = mapper.writeValueAsString(wrapperOfOptionOfJsonNode) | |
actualJson mustEqual """{"jsonNode":{"prop":"value"}}""" | |
} | |
} | |
} | |
case class WrapperOfOptionOfJsonNode(jsonNode: Option[JsonNode]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment