ValidationPreconditions { public static void validateNotNullOrEmpty(String value, String message) { validate(value != null && !value.trim().isEmpty(), message); } private  ValidationPreconditions(); static void validateNotNull(Object value, String message); static void validateNotNullOrEmpty(String value, String message); static void validateRequired(String value, String propertyName); static void validate(boolean condition, String message);  }
@Test public void validateNotNullOrEmpty() { ValidationPreconditions.validateNotNullOrEmpty("Not empty", "Must provide a value."); thrown.expect(ValidationException.class); thrown.expectMessage("Must provide a value."); ValidationPreconditions.validateNotNullOrEmpty(" ", "Must provide a value."); }
@Test public void validateNotNullOrEmptyNull() { thrown.expect(ValidationException.class); thrown.expectMessage("Must provide a value."); ValidationPreconditions.validateNotNullOrEmpty(null, "Must provide a value."); }