HasSelectedPagesValidator implements ConstraintValidator<HasSelectedPages, ExtractPagesParameters> { @Override public boolean isValid(ExtractPagesParameters value, ConstraintValidatorContext context) { if (value != null) { return value.getPredefinedSetOfPages() != PredefinedSetOfPages.NONE || !value.getPageSelection().isEmpty(); } return true; }  @Override void initialize(HasSelectedPages constraintAnnotation); @Override boolean isValid(ExtractPagesParameters value, ConstraintValidatorContext context);  }
@Test public void testNull() { assertTrue(victim.isValid(null, null)); }
@Test public void testHasDefault() { when(params.getPredefinedSetOfPages()).thenReturn(PredefinedSetOfPages.EVEN_PAGES); assertTrue(victim.isValid(params, null)); }
@Test public void testHasTransitions() { when(params.getPredefinedSetOfPages()).thenReturn(null); when(params.getPageSelection()).thenReturn(Collections.singleton(range)); assertTrue(victim.isValid(params, null)); }
@Test public void testHasBoth() { when(params.getPredefinedSetOfPages()).thenReturn(PredefinedSetOfPages.EVEN_PAGES); when(params.getPageSelection()).thenReturn(Collections.singleton(range)); assertTrue(victim.isValid(params, null)); }
@Test public void testHasNone() { when(params.getPredefinedSetOfPages()).thenReturn(PredefinedSetOfPages.NONE); when(params.getPageSelection()).thenReturn(Collections.EMPTY_SET); assertFalse(victim.isValid(params, null)); }