CheckUtilities { public static void checkStringListArgument(List<String> str, String variableName) { if (null == str) { throw new NullPointerException(ExceptionMessageMap.getMessage("000002") + " { variableName=[" + variableName + "] }"); } if (str.size() == 0) { throw new IllegalArgumentException(ExceptionMessageMap.getMessage("000002") + " { variableName=[" + variableName + "] }"); } for (int i = 0; i < str.size(); i++) { checkStringArgument(str.get(i), variableName); } }  static void checkFileValidity(String filename); static void checkFileValidity(File file); static void checkIntArgumentGreaterThan(int toCheck, int lowerBound, String variableName); static void checkNullArgument(Object obj, String variableName); static void checkNullListArgument(List<?> list, String variableName); static boolean checkListsEqual(List<?> l1, List<?> l2); static boolean checkObjectsEqual(Object o1, Object o2); static void checkStringArgument(String str, String variableName); static void checkStringListArgument(List<String> str, String variableName); static boolean checkUnorderedListsEqual(List<?> l1, List<?> l2); static void checkIntIndexInListRange(List<?> list, int index); static void checkIntInRange(int index, int start, int end); static void validateListRefType(List<Ref> list, Ref.RefType type, String variableName); static void validateArgumentRefType(Ref name, Ref.RefType type, String variableName); static void checkDirectoryArgument(File fileName, String variableName);  }
@Test public void testCheckStringListArgument() { assertCheckStringListArgumentThrowsNPE(null, "aVariableName", "000002: A List<String> argument was not specified but is required. " + "{ variableName=[aVariableName] }"); List<String> l = new ArrayList<String>(); l.add(null); assertCheckStringListArgumentThrowsNPE(l, "aVariableName", "000001: A String argument was not specified but is required. " + "{ variableName=[aVariableName] }"); l.clear(); l.add("str1"); l.add(null); l.add("str3"); assertCheckStringListArgumentThrowsNPE(l, "aVariableName", "000001: A String argument was not specified but is required. " + "{ variableName=[aVariableName] }"); l.clear(); l.add(""); assertCheckStringListArgumentThrowsIllegalArgException(l, "aVariableName", "000001: A String argument was not specified but is required. " + "{ variableName=[aVariableName] }"); l.clear(); l.add("str1"); l.add(""); l.add("str3"); assertCheckStringListArgumentThrowsIllegalArgException(l, "aVariableName", "000001: A String argument was not specified but is required. " + "{ variableName=[aVariableName] }"); l.clear(); assertCheckStringListArgumentThrowsIllegalArgException(l, "aVariableName", "000002: A List<String> argument was not specified but is required. " + "{ variableName=[aVariableName] }"); l.add("str1"); l.add("str2"); l.add("str3"); l.add("str4"); assertCheckStringListArgumentIsValid(l, "aVariableName"); }