Skip to content

Commit dc51439

Browse files
committed
Update MergeTest.scala
(cherry picked from commit 98bc8e1)
1 parent 9a56d6e commit dc51439

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
@@ -35,17 +35,17 @@ class MergeTest extends DeserializerTest {
3535
behavior of "The DefaultScalaModule when reading for updating"
3636

3737
it should "merge both lists" in {
38-
val typeReference = new TypeReference[ClassWithLists] {}
39-
val initial = deserialize(classJson(firstListJson), typeReference)
40-
val result = updateValue(newMergeableScalaMapper, initial, typeReference, classJson(secondListJson))
38+
val clazz = classOf[ClassWithLists]
39+
val initial = deserialize(classJson(firstListJson), clazz)
40+
val result = updateValue(newMergeableScalaMapper, initial, clazz, classJson(secondListJson))
4141

4242
result shouldBe ClassWithLists(mergedList, mergedList)
4343
}
4444

4545
it should "merge only the annotated list" in {
46-
val typeReference = new TypeReference[ClassWithLists] {}
47-
val initial = deserialize(classJson(firstListJson), typeReference)
48-
val result = updateValue(newScalaMapper, initial, typeReference, classJson(secondListJson))
46+
val clazz = classOf[ClassWithLists]
47+
val initial = deserialize(classJson(firstListJson), clazz)
48+
val result = updateValue(newScalaMapper, initial, clazz, classJson(secondListJson))
4949

5050
result shouldBe ClassWithLists(secondList, mergedList)
5151
}
@@ -120,8 +120,18 @@ class MergeTest extends DeserializerTest {
120120
objectReaderFor(mapper, valueToUpdate, typeReference).readValue(src)
121121
}
122122

123+
private def updateValue[T](mapper: ObjectMapper, valueToUpdate: T,
124+
clazz: Class[T], src: String): T = {
125+
objectReaderFor(mapper, valueToUpdate, clazz).readValue(src)
126+
}
127+
123128
private def objectReaderFor[T](mapper: ObjectMapper, valueToUpdate: T,
124129
typeReference: TypeReference[T]): ObjectReader = {
125130
mapper.readerForUpdating(valueToUpdate).forType(typeReference)
126131
}
132+
133+
private def objectReaderFor[T](mapper: ObjectMapper, valueToUpdate: T,
134+
clazz: Class[T]): ObjectReader = {
135+
mapper.readerForUpdating(valueToUpdate).forType(clazz)
136+
}
127137
}

0 commit comments

Comments
 (0)