@Test(expected = IllegalArgumentException.class) public void assertNotEmpty_EmptyCollection_ThrowsException() { List<String> testList = new ArrayList<String>(); ValidationUtils.assertNotEmpty(testList, "testList"); }
public static <T extends Collection<?>> T assertNotEmpty(T collection, String fieldName) throws IllegalArgumentException{ assertNotNull(collection, fieldName); if (collection.isEmpty()) { throw new IllegalArgumentException(String.format("%s cannot be empty", fieldName)); } return collection; }
ValidationUtils { public static <T extends Collection<?>> T assertNotEmpty(T collection, String fieldName) throws IllegalArgumentException{ assertNotNull(collection, fieldName); if (collection.isEmpty()) { throw new IllegalArgumentException(String.format("%s cannot be empty", fieldName)); } return collection; } }
ValidationUtils { public static <T extends Collection<?>> T assertNotEmpty(T collection, String fieldName) throws IllegalArgumentException{ assertNotNull(collection, fieldName); if (collection.isEmpty()) { throw new IllegalArgumentException(String.format("%s cannot be empty", fieldName)); } return collection; }  }
ValidationUtils { public static <T extends Collection<?>> T assertNotEmpty(T collection, String fieldName) throws IllegalArgumentException{ assertNotNull(collection, fieldName); if (collection.isEmpty()) { throw new IllegalArgumentException(String.format("%s cannot be empty", fieldName)); } return collection; }  static T assertNotNull(T object, String fieldName); static void assertAllAreNull(String messageIfNull, Object... objects); static int assertIsPositive(int num, String fieldName); static T assertNotEmpty(T collection, String fieldName); static T[] assertNotEmpty(T[] array, String fieldName); static String assertStringNotEmpty(String string, String fieldName); }
ValidationUtils { public static <T extends Collection<?>> T assertNotEmpty(T collection, String fieldName) throws IllegalArgumentException{ assertNotNull(collection, fieldName); if (collection.isEmpty()) { throw new IllegalArgumentException(String.format("%s cannot be empty", fieldName)); } return collection; }  static T assertNotNull(T object, String fieldName); static void assertAllAreNull(String messageIfNull, Object... objects); static int assertIsPositive(int num, String fieldName); static T assertNotEmpty(T collection, String fieldName); static T[] assertNotEmpty(T[] array, String fieldName); static String assertStringNotEmpty(String string, String fieldName);  }