CheckUtilities { public static void checkNullArgument(Object obj, String variableName) { if (null == obj) { throw new NullPointerException(ExceptionMessageMap.getMessage("000003") + " { variableName=[" + 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 testCheckNullArgument() { try { CheckUtilities.checkNullArgument(null, "Test variable name"); assertTrue("No NPE thrown when one was expected. Error!", false); } catch (NullPointerException e) { assertEquals("NPE didn't contain expected message. Error!", "000003: An Object argument was not specified but is required. " + "{ variableName=[Test variable name] }", e.getMessage()); } try { CheckUtilities.checkNullArgument("There is an object here.", "Test variable name"); } catch (NullPointerException e) { e.printStackTrace(); assertTrue("Caught NPE when none was expected. Error!", false); } }