ValidationPreconditions { public static void validateNotNull(Object value, String message) { validate(value != null, 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 validateNotNullRequiresMessage() { thrown.expect(NullPointerException.class); ValidationPreconditions.validateNotNull(new Object(), null); }
@Test public void validateNotNullRequiresMessageSentenceUpperCaseFirstLetter() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Message must start with an upper-case letter"); ValidationPreconditions.validateNotNull(new Object(), "lower case first letter."); }
@Test public void validateNotNullRequiresMessageSentenceEndsWithPeriod() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Message must end with a period"); ValidationPreconditions.validateNotNull(new Object(), "Must have period"); }
@Test public void validateNotNull() { ValidationPreconditions.validateNotNull(new Object(), "Must provide a value."); thrown.expect(ValidationException.class); thrown.expectMessage("Must provide a value."); ValidationPreconditions.validateNotNull(null, "Must provide a value."); }