LongTermIntervalAndLongTermIntervalTypeValidator implements ConstraintValidator<LongTermIntervalAndLongTermIntervalType, Configuration> { @Override public boolean isValid(final Configuration value, final ConstraintValidatorContext context) { if (value == null) { return true; } if (value.getLongTermHistoryInterval() == null && value.getLongTermHistoryIntervalType() == null) { return true; } final Integer interval = value.getLongTermHistoryInterval(); final LongTermIntervalType type = value.getLongTermHistoryIntervalType(); return this.checkRanges(interval, type); }  @Override void initialize(final LongTermIntervalAndLongTermIntervalType constraintAnnotation); @Override boolean isValid(final Configuration value, final ConstraintValidatorContext context);  }
@Test public void testValidDayLowerRange() { final Configuration input = this.createConfigurationInstance(1, LongTermIntervalType.DAYS); assertThat(this.validator.isValid(input, null)).isTrue(); }
@Test public void testValidDayUpperRange() { final Configuration input = this.createConfigurationInstance(30, LongTermIntervalType.DAYS); assertThat(this.validator.isValid(input, null)).isTrue(); }
@Test public void testInvalidDayLowerRange() { final Configuration input = this.createConfigurationInstance(0, LongTermIntervalType.DAYS); assertThat(this.validator.isValid(input, null)).isFalse(); }
@Test public void testInvalidDayUpperRange() { final Configuration input = this.createConfigurationInstance(31, LongTermIntervalType.DAYS); assertThat(this.validator.isValid(input, null)).isFalse(); }
@Test public void testValidMonthLowerRange() { final Configuration input = this.createConfigurationInstance(1, LongTermIntervalType.MONTHS); assertThat(this.validator.isValid(input, null)).isTrue(); }
@Test public void testValidMonthUpperRange() { final Configuration input = this.createConfigurationInstance(12, LongTermIntervalType.MONTHS); assertThat(this.validator.isValid(input, null)).isTrue(); }
@Test public void testInvalidMonthLowerRange() { final Configuration input = this.createConfigurationInstance(0, LongTermIntervalType.MONTHS); assertThat(this.validator.isValid(input, null)).isFalse(); }
@Test public void testInvalidMonthUpperRange() { final Configuration input = this.createConfigurationInstance(13, LongTermIntervalType.MONTHS); assertThat(this.validator.isValid(input, null)).isFalse(); }