AnnotationBasedSanitizer extends AbstractFieldSanitizer<Object> { @Override public Optional<Object> apply(Object entity) { return apply(entity, NOTHING); } AnnotationBasedSanitizer(EvaluationContext spelContext,
                                    Function<Class<?>, Boolean> innerEntityPredicate); @Override Optional<Object> apply(Object entity);  }
@Test public void testSanitizerOption() throws Exception { Root root = new Root( "root1", new Child("child1", 20, 1), new NullableChild("child2") ); Root sanitized = apply(root); Child child = sanitized.getChild(); assertThat(child.getChildName()).isEqualTo("child1"); assertThat(child.getMin()).isEqualTo(20); assertThat(child.getMax()).isEqualTo(20); }
@Test public void testAtLeastOption() throws Exception { Root root = new Root( "root1", new Child("child1", 2, 5), new NullableChild("child2") ); Root sanitized = apply(root); assertThat(sanitized.getChild().getMax()).isEqualTo(10); }
@Test public void testAtMostOption() throws Exception { Root root = new Root( "root1", new Child("child1", 2, 150), new NullableChild("child2") ); Root sanitized = apply(root); assertThat(sanitized.getChild().getMax()).isEqualTo(100); }
@Test public void testAdjusterOption() throws Exception { Root root = new Root( "root1", new Child("child1", 5, 25), new NullableChild("child2") ); Root sanitized = apply(root); assertThat(sanitized.getChild().getMax()).isEqualTo(24); }