### Question:
JsonDocumentSearchResponseUnmarshaller { public <T extends Document> T unmarshall(final Map<String, List<String>> fields, final Class<T> documentClass) { try { final String fieldJson = mapper.writeValueAsString(fields); final JsonNode fieldsNode = mapper.readValue(fieldJson, JsonNode.class); final String documentString = mapper.writeValueAsString(fieldsNode); final T document = mapper.readValue(documentString, documentClass); return document; } catch (final IOException e) { throw new IllegalStateException(e); } } JsonDocumentSearchResponseUnmarshaller(); T unmarshall(final Map<String, List<String>> fields, final Class<T> documentClass);  }### Answer:
@Test public void shouldUnmarshall_withFieldsAndDocumentClass() { final Map<String, List<String>> fields = new HashMap<>(); final String stringProperty = randomString(10); fields.put("stringproperty", Arrays.asList(stringProperty)); final String[] stringListValues = new String[3]; stringListValues[0] = randomString(10); stringListValues[1] = randomString(10); stringListValues[2] = randomString(10); fields.put("collectionproperty", Arrays.asList(stringListValues[0], stringListValues[1], stringListValues[2])); final MyEnum myEnum = randomEnum(MyEnum.class); fields.put("myenum", Arrays.asList(myEnum.name())); final DateTime dateTimeValue = randomDateTime(); fields.put("datetimevalue", Arrays.asList(ISODateTimeFormat.dateTime().withZoneUTC().print(dateTimeValue))); final JsonDocumentSearchResponseUnmarshaller jsonDocumentSearchResponseUnmarshaller = new JsonDocumentSearchResponseUnmarshaller(); final StubDocument document = jsonDocumentSearchResponseUnmarshaller.unmarshall(fields, StubDocument.class); assertNotNull(document); assertEquals(stringProperty, document.getStringProperty()); final List<String> collectionProperty = (List<String>) document.getCollectionProperty(); for (int i = 0; i < collectionProperty.size(); i++) { assertEquals(stringListValues[i], collectionProperty.get(i)); } assertEquals(myEnum, document.getMyEnum()); assertEquals(dateTimeValue.getMillis(), document.getDateTimeValue().getMillis()); }