Skip to content

Commit 98bc8e1

Browse files
committed
Update MergeTest.scala
1 parent e86b3bb commit 98bc8e1

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/test/scala/com/fasterxml/jackson/module/scala/deser/MergeTest.scala

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@ class MergeTest extends DeserializerTest {
3232
behavior of "The DefaultScalaModule when reading for updating"
3333

3434
it should "merge both lists" in {
35-
val typeReference = new TypeReference[ClassWithLists] {}
36-
val initial = deserialize(classJson(firstListJson), typeReference)
37-
val result = updateValue(newMergeableScalaMapper, initial, typeReference, classJson(secondListJson))
35+
val clazz = classOf[ClassWithLists]
36+
val initial = deserialize(classJson(firstListJson), clazz)
37+
val result = updateValue(newMergeableScalaMapper, initial, clazz, classJson(secondListJson))
3838

3939
result shouldBe ClassWithLists(mergedList, mergedList)
4040
}
4141

4242
it should "merge only the annotated list" in {
43-
val typeReference = new TypeReference[ClassWithLists] {}
44-
val initial = deserialize(classJson(firstListJson), typeReference)
45-
val result = updateValue(newScalaMapper, initial, typeReference, classJson(secondListJson))
43+
val clazz = classOf[ClassWithLists]
44+
val initial = deserialize(classJson(firstListJson), clazz)
45+
val result = updateValue(newScalaMapper, initial, clazz, classJson(secondListJson))
4646

4747
result shouldBe ClassWithLists(secondList, mergedList)
4848
}
@@ -117,8 +117,18 @@ class MergeTest extends DeserializerTest {
117117
objectReaderFor(mapper, valueToUpdate, typeReference).readValue(src)
118118
}
119119

120+
private def updateValue[T](mapper: ObjectMapper, valueToUpdate: T,
121+
clazz: Class[T], src: String): T = {
122+
objectReaderFor(mapper, valueToUpdate, clazz).readValue(src)
123+
}
124+
120125
private def objectReaderFor[T](mapper: ObjectMapper, valueToUpdate: T,
121126
typeReference: TypeReference[T]): ObjectReader = {
122127
mapper.readerForUpdating(valueToUpdate).forType(typeReference)
123128
}
129+
130+
private def objectReaderFor[T](mapper: ObjectMapper, valueToUpdate: T,
131+
clazz: Class[T]): ObjectReader = {
132+
mapper.readerForUpdating(valueToUpdate).forType(clazz)
133+
}
124134
}

0 commit comments

Comments
 (0)