### Question:
Utils { static Object getFieldValueListSafe(Object value, String field) throws IllegalArgumentException { if (Missing.isNullOrMissing(value)) { return Missing.getInstance(); } if (field.equals("$") || field.contains(PATH_DELIMITER)) { throw new IllegalArgumentException("illegal field: " + field); } if (value instanceof List<?>) { List<?> list = (List<?>) value; if (isNumeric(field)) { int pos = Integer.parseInt(field); if (pos >= 0 && pos < list.size()) { return list.get(pos); } else { return Missing.getInstance(); } } else { List<Object> values = new ArrayList<>(); for (Object subValue : list) { if (subValue instanceof Document) { Object subDocumentValue = ((Document) subValue).getOrMissing(field); if (!(subDocumentValue instanceof Missing)) { values.add(subDocumentValue); } } } if (values.isEmpty()) { return Missing.getInstance(); } return values; } } else if (value instanceof Document) { Document document = (Document) value; return document.getOrMissing(field); } else { return Missing.getInstance(); } }  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 testGetFieldValueListSafe() throws Exception { assertThat(Utils.getFieldValueListSafe(Missing.getInstance(), "foo")).isInstanceOf(Missing.class); assertThat(Utils.getFieldValueListSafe(null, "foo")).isInstanceOf(Missing.class); assertThat(Utils.getFieldValueListSafe(json(""), "foo")).isInstanceOf(Missing.class); assertThat(Utils.getFieldValueListSafe(json("foo: null"), "foo")).isNull(); assertThat(Utils.getFieldValueListSafe(json("foo: 25"), "foo")).isEqualTo(25); assertThat(Utils.getFieldValueListSafe(Arrays.asList("a", "b", "c"), "1")).isEqualTo("b"); assertThat(Utils.getFieldValueListSafe(Arrays.asList("a", "b", "c"), "10")).isInstanceOf(Missing.class); assertThat(Utils.getFieldValueListSafe(Collections.emptyList(), "0")).isInstanceOf(Missing.class); assertThat(Utils.getFieldValueListSafe(123, "0")).isInstanceOf(Missing.class); assertThat(Utils.getFieldValueListSafe("abc", "0")).isInstanceOf(Missing.class); assertThat(Utils.getFieldValueListSafe(123, "x")).isInstanceOf(Missing.class); assertThat(Utils.getFieldValueListSafe("abc", "x")).isInstanceOf(Missing.class); List<?> values = Arrays.asList(json("a: 1"), 2, json("a: 2"), json("b: 3"), json("a: {b: 'x'}")); assertThat(Utils.getFieldValueListSafe(values, "a")) .isEqualTo(Arrays.asList(1, 2, json("b: 'x'"))); assertThat(Utils.getFieldValueListSafe(Arrays.asList(1, 2, 3), "a")).isInstanceOf(Missing.class); }