### Question:
IsoLocalDateTimeDeSerializer extends JsonDeserializer<LocalDateTime> { @Override public LocalDateTime deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { ObjectCodec oc = p.getCodec(); JsonNode node = oc.readTree(p); if (node.get(DATE_NODE) != null) { String dateValue = node.get(DATE_NODE).asText(); return Instant.ofEpochMilli(Long.valueOf(dateValue)).atZone(ZoneOffset.systemDefault()).toLocalDateTime(); } else { return Instant.ofEpochMilli(node.asLong()).atZone(ZoneOffset.systemDefault()).toLocalDateTime(); } }  @Override LocalDateTime deserialize(JsonParser p, DeserializationContext ctxt);  }### Answer:
@Test public void deserialize() throws IOException { JsonParser jsonParser = mock(JsonParser.class); DeserializationContext ctxt = mock(DeserializationContext.class); ObjectCodec objectCodec = mock(ObjectCodec.class); when(jsonParser.getCodec()).thenReturn(objectCodec); JsonNode jsonNode = mock(JsonNode.class); when(objectCodec.readTree(jsonParser)).thenReturn(jsonNode); JsonNode jsonNode2 = mock(JsonNode.class); when(jsonNode.get(anyString())).thenReturn(jsonNode2); when(jsonNode2.asText()).thenReturn("1234567890"); new IsoLocalDateTimeDeSerializer().deserialize(jsonParser, ctxt); verify(jsonParser).getCodec(); verify(objectCodec).readTree(jsonParser); verify(jsonNode, times(2)).get("$date"); verify(jsonNode2).asText(); verify(jsonNode, never()).asLong(); verifyNoMoreInteractions(jsonParser, objectCodec, jsonNode, jsonNode2); }
@Test public void deserializeWhenMethodGetReturnsNull() throws IOException { JsonParser jsonParser = mock(JsonParser.class); DeserializationContext ctxt = mock(DeserializationContext.class); ObjectCodec objectCodec = mock(ObjectCodec.class); when(jsonParser.getCodec()).thenReturn(objectCodec); JsonNode jsonNode = mock(JsonNode.class); when(objectCodec.readTree(jsonParser)).thenReturn(jsonNode); when(jsonNode.get(anyString())).thenReturn(null); new IsoLocalDateTimeDeSerializer().deserialize(jsonParser, ctxt); verify(jsonParser).getCodec(); verify(objectCodec).readTree(jsonParser); verify(jsonNode).get("$date"); verify(jsonNode).asLong(); verifyNoMoreInteractions(jsonParser, objectCodec, jsonNode); }