Skip to content

Commit

Permalink
Test for #29.
Browse files Browse the repository at this point in the history
  • Loading branch information
christophercurrie committed May 2, 2013
1 parent 39996b3 commit fe15b83
Showing 1 changed file with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.fasterxml.jackson.module.scala.deser

import org.scalatest.matchers.ShouldMatchers
import org.scalatest.FlatSpec
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import com.fasterxml.jackson.module.scala.DefaultScalaModule

object Dog
{
def apply(n: String, thinking: Boolean) = {
val dog = new Dog
dog.name = n
dog.brain = new dog.Brain
dog.brain.isThinking = thinking
dog
}
}
class Dog
{
var name: String = _
var brain: Brain = _

class Brain {
var isThinking: Boolean = _
def parentName = name
}

}

// Cribbed from the same named test in jackson-databind
@RunWith(classOf[JUnitRunner])
class TestInnerClass extends DeserializerTest with FlatSpec with ShouldMatchers {

def module = DefaultScalaModule

"Deserializer" should "support nested inner classes as values" in {
val input = Dog("Smurf", thinking = true)
val json = mapper.writeValueAsString(input)
val output = deserialize[Dog](json)

output.name should be === ("Smurf")
output.brain should not be (null)
output.brain.isThinking should be (true)
output.brain.parentName should be === ("Smurf")
output.name = "Foo"
output.brain.parentName should be === ("Foo")
}

}

0 comments on commit fe15b83

Please sign in to comment.