### Question:
Utils { public static void copySubdocumentValue(Document input, Document result, String key) { Object value = getSubdocumentValueCollectionAware(input, key); if (!(value instanceof Missing)) { changeSubdocumentValue(result, key, value); } }  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 testCopySubdocumentValue() throws Exception { Document document = json("_id: 1, foo: {bar: 1, bla: 2}, x: null, y: {a: 1, b: [1, 2, 3]}"); Document result = new Document(); Utils.copySubdocumentValue(document, result, "_id"); assertThat(result).isEqualTo(json("_id: 1")); Utils.copySubdocumentValue(document, result, "does-not-exist"); assertThat(result).isEqualTo(json("_id: 1")); Utils.copySubdocumentValue(document, result, "foo.bar"); assertThat(result).isEqualTo(json("_id: 1, foo: {bar: 1}")); Utils.copySubdocumentValue(document, result, "foo.bla"); assertThat(result).isEqualTo(json("_id: 1, foo: {bar: 1, bla: 2}")); Utils.copySubdocumentValue(document, result, "x"); assertThat(result).isEqualTo(json("_id: 1, foo: {bar: 1, bla: 2}, x: null")); Utils.copySubdocumentValue(document, result, "y"); assertThat(result).isEqualTo(json("_id: 1, foo: {bar: 1, bla: 2}, x: null, y: {a: 1, b: [1, 2, 3]}")); }