### Question:
JacksonDeserializer { public <T> List<T> deserializeList(String json, Class<T> clazz) { return deserialize(json , mapper.getTypeFactory().constructCollectionType(List.class, 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 deserializeList_throw_exception_if_json_is_not_a_list() throws Exception { String json = "{\"address\":{\"street\":\"310 La Gouterie\",\"city\":\"Charnecles\"},\"id\":1,\"firstName\":\"Colin\",\"lastName\":\"Puy\",\"birthday\":428558400000}"; jacksonDeserializer.deserializeList(json, User.class); }
@Test public void deserializeList_can_deserialize_primitives_types() throws Exception { List<Long> longs = jacksonDeserializer.deserializeList("[1, 2, 3]", Long.class); assertThat(longs, hasItems(1L, 2L, 3L)); }
@Test public void deserializeList_can_deserialize_list_of_complex_type() throws Exception { User expectedUser1 = new User(1, "Colin", "Puy", new Date(428558400000L), new Address("310 La Gouterie", "Charnecles")); User expectedUser2 = new User(2, "Clara", "Morgan", new Date(349246800000L), new Address("somewhere i don't know", "Paris")); String json = "[" + "{\"address\":{\"city\":\"Charnecles\",\"street\":\"310 La Gouterie\"},\"id\":1,\"firstName\":\"Colin\",\"lastName\":\"Puy\",\"birthday\":428558400000}," + "{\"address\":{\"city\":\"Paris\",\"street\":\"somewhere i don't know\"},\"id\":2,\"firstName\":\"Clara\",\"lastName\":\"Morgan\",\"birthday\":349246800000}" + "]"; List<User> users = jacksonDeserializer.deserializeList(json, User.class); assertThat(users, hasItem(expectedUser1)); assertThat(users, hasItem(expectedUser2)); }