@Test public void shouldCheckIsValidThrowExceptionWhenInputIsNull() throws Exception { expectedException.expect(NullPointerException.class); EmailSchedulerProperties.checkIsValid(null); fail("IllegalStateException expected"); }
public static void checkIsValid(@NonNull final EmailSchedulerProperties emailSchedulerProperties) { Preconditions.checkState(emailSchedulerProperties.getPriorityLevels() > 0, "Expected at least one priority level. Review property 'spring.mail.scheduler.priorityLevels'."); Preconditions.checkState(isNull(emailSchedulerProperties.getPersistence()) || emailSchedulerProperties.getPersistence().getDesiredBatchSize() > 0, "Expected at least a batch of size one, otherwise the persistence layer will not work. Review property 'spring.mail.scheduler.persistence.desiredBatchSize'."); Preconditions.checkState(isNull(emailSchedulerProperties.getPersistence()) || emailSchedulerProperties.getPersistence().getMinKeptInMemory() >= 0, "Expected a non negative amount of email to be kept in memory. Review property 'spring.mail.scheduler.persistence.minKeptInMemory'."); Preconditions.checkState(isNull(emailSchedulerProperties.getPersistence()) || emailSchedulerProperties.getPersistence().getMaxKeptInMemory() > 0, "Expected at least one email to be available in memory, otherwise the persistence layer will not work. Review property 'spring.mail.scheduler.persistence.maxKeptInMemory'."); Preconditions.checkState(isNull(emailSchedulerProperties.getPersistence()) || (emailSchedulerProperties.getPersistence().getMaxKeptInMemory() >= emailSchedulerProperties.getPersistence().getMinKeptInMemory()), "The application properties key '%s' should not have a value smaller than the value in property '%s'.", "spring.mail.scheduler.persistence.maxKeptInMemory", "spring.mail.scheduler.persistence.minKeptInMemory"); Preconditions.checkState(isNull(emailSchedulerProperties.getPersistence()) || (emailSchedulerProperties.getPersistence().getMaxKeptInMemory() >= emailSchedulerProperties.getPersistence().getDesiredBatchSize()), "The application properties key '%s' should not have a value smaller than the value in property '%s'.", "spring.mail.scheduler.persistence.maxKeptInMemory", "spring.mail.scheduler.persistence.desiredBatchSize"); }
EmailSchedulerProperties { public static void checkIsValid(@NonNull final EmailSchedulerProperties emailSchedulerProperties) { Preconditions.checkState(emailSchedulerProperties.getPriorityLevels() > 0, "Expected at least one priority level. Review property 'spring.mail.scheduler.priorityLevels'."); Preconditions.checkState(isNull(emailSchedulerProperties.getPersistence()) || emailSchedulerProperties.getPersistence().getDesiredBatchSize() > 0, "Expected at least a batch of size one, otherwise the persistence layer will not work. Review property 'spring.mail.scheduler.persistence.desiredBatchSize'."); Preconditions.checkState(isNull(emailSchedulerProperties.getPersistence()) || emailSchedulerProperties.getPersistence().getMinKeptInMemory() >= 0, "Expected a non negative amount of email to be kept in memory. Review property 'spring.mail.scheduler.persistence.minKeptInMemory'."); Preconditions.checkState(isNull(emailSchedulerProperties.getPersistence()) || emailSchedulerProperties.getPersistence().getMaxKeptInMemory() > 0, "Expected at least one email to be available in memory, otherwise the persistence layer will not work. Review property 'spring.mail.scheduler.persistence.maxKeptInMemory'."); Preconditions.checkState(isNull(emailSchedulerProperties.getPersistence()) || (emailSchedulerProperties.getPersistence().getMaxKeptInMemory() >= emailSchedulerProperties.getPersistence().getMinKeptInMemory()), "The application properties key '%s' should not have a value smaller than the value in property '%s'.", "spring.mail.scheduler.persistence.maxKeptInMemory", "spring.mail.scheduler.persistence.minKeptInMemory"); Preconditions.checkState(isNull(emailSchedulerProperties.getPersistence()) || (emailSchedulerProperties.getPersistence().getMaxKeptInMemory() >= emailSchedulerProperties.getPersistence().getDesiredBatchSize()), "The application properties key '%s' should not have a value smaller than the value in property '%s'.", "spring.mail.scheduler.persistence.maxKeptInMemory", "spring.mail.scheduler.persistence.desiredBatchSize"); } }
EmailSchedulerProperties { public static void checkIsValid(@NonNull final EmailSchedulerProperties emailSchedulerProperties) { Preconditions.checkState(emailSchedulerProperties.getPriorityLevels() > 0, "Expected at least one priority level. Review property 'spring.mail.scheduler.priorityLevels'."); Preconditions.checkState(isNull(emailSchedulerProperties.getPersistence()) || emailSchedulerProperties.getPersistence().getDesiredBatchSize() > 0, "Expected at least a batch of size one, otherwise the persistence layer will not work. Review property 'spring.mail.scheduler.persistence.desiredBatchSize'."); Preconditions.checkState(isNull(emailSchedulerProperties.getPersistence()) || emailSchedulerProperties.getPersistence().getMinKeptInMemory() >= 0, "Expected a non negative amount of email to be kept in memory. Review property 'spring.mail.scheduler.persistence.minKeptInMemory'."); Preconditions.checkState(isNull(emailSchedulerProperties.getPersistence()) || emailSchedulerProperties.getPersistence().getMaxKeptInMemory() > 0, "Expected at least one email to be available in memory, otherwise the persistence layer will not work. Review property 'spring.mail.scheduler.persistence.maxKeptInMemory'."); Preconditions.checkState(isNull(emailSchedulerProperties.getPersistence()) || (emailSchedulerProperties.getPersistence().getMaxKeptInMemory() >= emailSchedulerProperties.getPersistence().getMinKeptInMemory()), "The application properties key '%s' should not have a value smaller than the value in property '%s'.", "spring.mail.scheduler.persistence.maxKeptInMemory", "spring.mail.scheduler.persistence.minKeptInMemory"); Preconditions.checkState(isNull(emailSchedulerProperties.getPersistence()) || (emailSchedulerProperties.getPersistence().getMaxKeptInMemory() >= emailSchedulerProperties.getPersistence().getDesiredBatchSize()), "The application properties key '%s' should not have a value smaller than the value in property '%s'.", "spring.mail.scheduler.persistence.maxKeptInMemory", "spring.mail.scheduler.persistence.desiredBatchSize"); }  }
EmailSchedulerProperties { public static void checkIsValid(@NonNull final EmailSchedulerProperties emailSchedulerProperties) { Preconditions.checkState(emailSchedulerProperties.getPriorityLevels() > 0, "Expected at least one priority level. Review property 'spring.mail.scheduler.priorityLevels'."); Preconditions.checkState(isNull(emailSchedulerProperties.getPersistence()) || emailSchedulerProperties.getPersistence().getDesiredBatchSize() > 0, "Expected at least a batch of size one, otherwise the persistence layer will not work. Review property 'spring.mail.scheduler.persistence.desiredBatchSize'."); Preconditions.checkState(isNull(emailSchedulerProperties.getPersistence()) || emailSchedulerProperties.getPersistence().getMinKeptInMemory() >= 0, "Expected a non negative amount of email to be kept in memory. Review property 'spring.mail.scheduler.persistence.minKeptInMemory'."); Preconditions.checkState(isNull(emailSchedulerProperties.getPersistence()) || emailSchedulerProperties.getPersistence().getMaxKeptInMemory() > 0, "Expected at least one email to be available in memory, otherwise the persistence layer will not work. Review property 'spring.mail.scheduler.persistence.maxKeptInMemory'."); Preconditions.checkState(isNull(emailSchedulerProperties.getPersistence()) || (emailSchedulerProperties.getPersistence().getMaxKeptInMemory() >= emailSchedulerProperties.getPersistence().getMinKeptInMemory()), "The application properties key '%s' should not have a value smaller than the value in property '%s'.", "spring.mail.scheduler.persistence.maxKeptInMemory", "spring.mail.scheduler.persistence.minKeptInMemory"); Preconditions.checkState(isNull(emailSchedulerProperties.getPersistence()) || (emailSchedulerProperties.getPersistence().getMaxKeptInMemory() >= emailSchedulerProperties.getPersistence().getDesiredBatchSize()), "The application properties key '%s' should not have a value smaller than the value in property '%s'.", "spring.mail.scheduler.persistence.maxKeptInMemory", "spring.mail.scheduler.persistence.desiredBatchSize"); }  static void checkIsValid(@NonNull final EmailSchedulerProperties emailSchedulerProperties); }
EmailSchedulerProperties { public static void checkIsValid(@NonNull final EmailSchedulerProperties emailSchedulerProperties) { Preconditions.checkState(emailSchedulerProperties.getPriorityLevels() > 0, "Expected at least one priority level. Review property 'spring.mail.scheduler.priorityLevels'."); Preconditions.checkState(isNull(emailSchedulerProperties.getPersistence()) || emailSchedulerProperties.getPersistence().getDesiredBatchSize() > 0, "Expected at least a batch of size one, otherwise the persistence layer will not work. Review property 'spring.mail.scheduler.persistence.desiredBatchSize'."); Preconditions.checkState(isNull(emailSchedulerProperties.getPersistence()) || emailSchedulerProperties.getPersistence().getMinKeptInMemory() >= 0, "Expected a non negative amount of email to be kept in memory. Review property 'spring.mail.scheduler.persistence.minKeptInMemory'."); Preconditions.checkState(isNull(emailSchedulerProperties.getPersistence()) || emailSchedulerProperties.getPersistence().getMaxKeptInMemory() > 0, "Expected at least one email to be available in memory, otherwise the persistence layer will not work. Review property 'spring.mail.scheduler.persistence.maxKeptInMemory'."); Preconditions.checkState(isNull(emailSchedulerProperties.getPersistence()) || (emailSchedulerProperties.getPersistence().getMaxKeptInMemory() >= emailSchedulerProperties.getPersistence().getMinKeptInMemory()), "The application properties key '%s' should not have a value smaller than the value in property '%s'.", "spring.mail.scheduler.persistence.maxKeptInMemory", "spring.mail.scheduler.persistence.minKeptInMemory"); Preconditions.checkState(isNull(emailSchedulerProperties.getPersistence()) || (emailSchedulerProperties.getPersistence().getMaxKeptInMemory() >= emailSchedulerProperties.getPersistence().getDesiredBatchSize()), "The application properties key '%s' should not have a value smaller than the value in property '%s'.", "spring.mail.scheduler.persistence.maxKeptInMemory", "spring.mail.scheduler.persistence.desiredBatchSize"); }  static void checkIsValid(@NonNull final EmailSchedulerProperties emailSchedulerProperties);  }