### Question:
JacksonDeserializer { public <T> T deserialize(String json, Class<T> clazz) { return deserialize(json, mapper.getTypeFactory().constructType(clazz)); }  T deserialize(String json, Class<T> clazz); List<T> deserializeList(String json, Class<T> clazz); @SuppressWarnings("unchecked") T convertValue(Object fromValue, Class<?> toValue);  }### Answer:
@Test(expected = APIException.class) public void deserialize_throw_exception_if_json_is_non_well_formed() throws Exception { String nonWellFormedJson = "someJsonNonWellFormedJson"; jacksonDeserializer.deserialize(nonWellFormedJson, String.class); }
@Test(expected = APIException.class) public void deserialize_throw_exception_if_mapping_bettween_class_and_json_is_incorrect() throws Exception { String notUserJson = "{\"unknownUserAttribute\": \"unknownAttributeValue\"}"; jacksonDeserializer.deserialize(notUserJson, User.class); }
@Test public void deserialize_can_deserialize_primitives_types() throws Exception { Long deserializedLong = jacksonDeserializer.deserialize("1", Long.class); assertThat(deserializedLong, is(1L)); }
@Test public void deserialize_can_deserialize_complex_types() throws Exception { User expectedUser = new User(1, "Colin", "Puy", new Date(428558400000L), new Address("310 La Gouterie", "Charnecles")); String json = "{\"address\":{\"street\":\"310 La Gouterie\",\"city\":\"Charnecles\"},\"id\":1,\"firstName\":\"Colin\",\"lastName\":\"Puy\",\"birthday\":428558400000}"; User deserializedUser = jacksonDeserializer.deserialize(json, User.class); assertThat(deserializedUser, equalTo(expectedUser)); }