### Question:
ValueExtractor { public static Object extractValueForFieldName(String possiblyDottedField, DocumentRevision rev) { if (possiblyDottedField.equals("_id")) { return rev.getId(); } else if (possiblyDottedField.equals("_rev")) { return rev.getRevision(); } else { return extractValueForFieldName(possiblyDottedField, rev.getBody()); } }  static Object extractValueForFieldName(String possiblyDottedField,
                                                  DocumentRevision rev); @SuppressWarnings("unchecked") static Object extractValueForFieldName(String possiblyDottedField, DocumentBody body);  }### Answer:
@Test public void getDocIdFromRevision() { String value = (String) ValueExtractor.extractValueForFieldName("_id", revision); assertThat(value, is("dsfsdfdfs")); }
@Test public void getRevIdFromRevision() { String value = (String) ValueExtractor.extractValueForFieldName("_rev", revision); assertThat(value, is("1-qweqeqwewqe")); }
@Test public void getNameFromRevision() { String value = (String) ValueExtractor.extractValueForFieldName("name", revision); assertThat(value, is("mike")); }
@Test public void extractSingleFieldWhenEmptyFieldName() { Object v = ValueExtractor.extractValueForFieldName("", body); assertThat(v, is(nullValue())); }
@Test public void extractSingleFieldForSingleDepth() { String v = (String) ValueExtractor.extractValueForFieldName("name", body); assertThat(v, is("mike")); }
@Test public void extractSingleFieldForDoubleDepth() { String v = (String) ValueExtractor.extractValueForFieldName("name.first", getTwoLevelBody()); assertThat(v, is("mike")); }
@Test public void extractSingleFieldForTripleDepth() { String v = (String) ValueExtractor.extractValueForFieldName("aaa.bbb.ccc", getThreeLevelBody()); assertThat(v, is("mike")); }
@Test public void extractSingleFieldWhenFieldNamePrefix() { Object v = ValueExtractor.extractValueForFieldName("name.first", body); assertThat(v, is(nullValue())); v = ValueExtractor.extractValueForFieldName("name.first.mike", getThreeLevelBody()); assertThat(v, is(nullValue())); }
@Test public void extractSubDocument() { @SuppressWarnings("unchecked") Map<String, String> v = (Map) ValueExtractor.extractValueForFieldName("aaa.bbb", getThreeLevelBody()); assertThat(v.size(), is(1)); assertThat(v, hasEntry("ccc", "mike")); }