public HandlerDecorators() { register(new SqlMethodAnnotatedHandlerDecorator()); }
@Test public void testRegisteredDecoratorReturnsBase() { handle.getConfig(HandlerDecorators.class).register((base, sqlObjectType, method) -> base); handle.attach(Dao.class).orderedFooBar(); assertThat(INVOCATIONS.get()).containsExactly("foo", "bar", "method"); }
@Test public void testRegisteredDecorator() { handle.getConfig(HandlerDecorators.class).register( (base, sqlObjectType, method) -> (obj, args, handle) -> { invoked("custom"); return base.invoke(obj, args, handle); }); handle.attach(Dao.class).orderedFooBar(); assertThat(INVOCATIONS.get()).containsExactly("custom", "foo", "bar", "method"); }
@Test public void testRegisteredDecoratorReturnsBase() { handle.getConfig(HandlerDecorators.class).register((base, sqlObjectType, method) -> base); handle.attach(Dao.class).orderedFooBar(); assertThat(INVOCATIONS.get()).containsExactly("foo", "bar", "method"); }
@Test public void testRegisteredDecorator() { handle.getConfig(HandlerDecorators.class).register( (base, sqlObjectType, method) -> (obj, args, handle) -> { invoked("custom"); return base.invoke(obj, args, handle); }); handle.attach(Dao.class).orderedFooBar(); assertThat(INVOCATIONS.get()).containsExactly("custom", "foo", "bar", "method"); }