ValidationPreconditions { public static void validate(boolean condition, String message) { checkMessage(message); if (!condition) { throw new ValidationException(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 validate() { ValidationPreconditions.validate(true, "No harm here."); thrown.expect(ValidationException.class); thrown.expectMessage("Ouch."); ValidationPreconditions.validate(false, "Ouch."); }