### Question:
Utils { static boolean hasFieldValueListSafe(Object document, String field) throws IllegalArgumentException { if (document == null) { return false; } if (field.equals("$") || field.contains(PATH_DELIMITER)) { throw new IllegalArgumentException("illegal field: " + field); } if (document instanceof List<?>) { if (isNumeric(field)) { int pos = Integer.parseInt(field); List<?> list = (List<?>) document; return (pos >= 0 && pos < list.size()); } else { return false; } } else if (document instanceof Document) { return ((Document) document).containsKey(field); } throw new IllegalArgumentException("illegal document: " + document); }  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 testHasFieldValueListSafe() throws Exception { assertThat(Utils.hasFieldValueListSafe(null, "foo")).isFalse(); Document document = json("foo: 25"); assertThat(Utils.hasFieldValueListSafe(document, "foo")).isTrue(); assertThat(Utils.hasFieldValueListSafe(document, "bar")).isFalse(); assertThat(Utils.hasFieldValueListSafe(Arrays.asList("a", "b", "c"), "0")).isTrue(); assertThat(Utils.hasFieldValueListSafe(Arrays.asList("a", "b", "c"), "1")).isTrue(); assertThat(Utils.hasFieldValueListSafe(Arrays.asList("a", "b", "c"), "2")).isTrue(); assertThat(Utils.hasFieldValueListSafe(Arrays.asList("a", "b", "c"), "3")).isFalse(); assertThat(Utils.hasFieldValueListSafe(Arrays.asList("a", "b", "c"), "foo")).isFalse(); }