Advertisement
Guest User

Untitled

a guest
Nov 6th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.50 KB | None | 0 0
  1. class TestT {
  2.  
  3.     @Test
  4.     fun shouldDeserializeWithMissingField() {
  5.         val objectMapper = ObjectMapper()
  6.                 .registerModule(KotlinModule())
  7.  
  8.         val readValue = objectMapper.readValue("{\"first\" : \"hi\" }", TestClass::class.java)
  9.  
  10.         assertEquals("hi", readValue.first)
  11.         assertNull(readValue.second)
  12.         assertNull(readValue.map)
  13.     }
  14.  
  15. }
  16.  
  17.  
  18. data class TestClass(
  19.         val first: String,
  20.         val second: String?,
  21.         val map: Map<String, String>?
  22. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement