Validate { public static void notEmpty(final String text, @NonNls final String errorMsg) { if (text == null || text.trim().length() == 0) { throw new IllegalArgumentException(errorMsg); } } private  Validate(); static void notNull(final Object obj, @NonNls final String errorMsg); static void notEmpty(final String text, @NonNls final String errorMsg);  }
@Test public void notEmptyShouldDoNothingIfStringHasValue() { Validate.notEmpty("a", "No exception"); }
@Test public void notEmptyShouldThrowExceptionIfStringIsNull() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("This is the message"); Validate.notEmpty(null, "This is the message"); }
@Test public void notEmptyShouldThrowExceptionIfStringIsEmpty() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("This is the message"); Validate.notEmpty("", "This is the message"); }
@Test public void notEmptyShouldThrowExceptionIfStringIsSpace() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("This is the message"); Validate.notEmpty(" ", "This is the message"); }