### Question:
Utils { public static Object getSubdocumentValue(Document document, String key) { return getSubdocumentValue(document, key, false); }  static Object getSubdocumentValue(Document document, String key); static Object getSubdocumentValueCollectionAware(Document document, String key); static String getDatabaseNameFromFullName(String fullName); static String getCollectionNameFromFullName(String fullName); static boolean isTrue(Object value); static Number normalizeNumber(Number value); static void markOkay(Document result); static String join(List<?> values, String delimiter); static void changeSubdocumentValue(Object document, String key, Object newValue); static void validateFieldNames(Document document); static Object removeSubdocumentValue(Object document, String key); static String describeType(Object value); static String joinTail(List<String> pathFragments); static String firstFragment(String input); static List<String> splitPath(String input); static String getShorterPathIfPrefix(String path1, String path2); static List<String> collectCommonPathFragments(String path1, String path2); static String getHostName(); static void copySubdocumentValue(Document input, Document result, String key); static final String PATH_DELIMITER; }### Answer:
@Test void testGetSubdocumentValue() throws Exception { Document document = json("foo: 25"); assertThat(Utils.getSubdocumentValue(document, "foo")).isEqualTo(25); assertThat(Utils.getSubdocumentValue(document, "foo.bar")).isInstanceOf(Missing.class); assertThat(Utils.getSubdocumentValue(document, "foo.bar.x")).isInstanceOf(Missing.class); assertThat(Utils.getSubdocumentValue(json("foo: {bar: null}"), "foo.bar")).isNull(); document.put("foo", json("a: 10").append("b", json("x: 29").append("z", 17))); assertThat(Utils.getSubdocumentValue(document, "foo.a")).isEqualTo(10); assertThat(Utils.getSubdocumentValue(document, "foo.b.x")).isEqualTo(29); assertThat(Utils.getSubdocumentValue(document, "foo.b.z")).isEqualTo(17); assertThat(Utils.getSubdocumentValue(document, "foo.c")).isInstanceOf(Missing.class); assertThatExceptionOfType(MongoServerException.class) .isThrownBy(() -> Utils.getSubdocumentValue(document, "a.")) .withMessageContaining("[Error 40353] FieldPath must not end with a '.'."); assertThatExceptionOfType(MongoServerException.class) .isThrownBy(() -> Utils.getSubdocumentValue(document, "a..1")) .withMessageContaining("[Error 15998] FieldPath field names may not be empty strings."); assertThatExceptionOfType(MongoServerException.class) .isThrownBy(() -> Utils.getSubdocumentValue(document, ".a")) .withMessageContaining("[Error 15998] FieldPath field names may not be empty strings."); }