ValidationUtils { public static String assertStringNotEmpty(String string, String fieldName) throws IllegalArgumentException { assertNotNull(string, fieldName); if (string.isEmpty()) { throw new IllegalArgumentException(String.format("%s cannot be empty", fieldName)); } return string; }  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);  }
@Test(expected = IllegalArgumentException.class) public void assertStringNotEmpty_NullString_ThrowsException() { ValidationUtils.assertStringNotEmpty(null, "someString"); }
@Test(expected = IllegalArgumentException.class) public void assertStringNotEmpty_EmptyString_ThrowsException() { ValidationUtils.assertStringNotEmpty("", "someString"); }
@Test public void assertStringNotEmpty_NonEmptyString_ReturnsSameString() { final String string = "foo"; assertEquals(string, ValidationUtils.assertStringNotEmpty(string, "someString")); }