Search in sources :

Example 1 with InheritableBehaviorCommandHook

use of org.dbflute.hook.CallbackContext.InheritableBehaviorCommandHook in project dbflute-core by dbflute.

the class CallbackContextTest method test_BehaviorCommandHook_twoSet_terminateLast.

public void test_BehaviorCommandHook_twoSet_terminateLast() throws Exception {
    // ## Arrange ##
    CallbackContext context = new CallbackContext();
    assertNull(context.getBehaviorCommandHook());
    setupTwoBehaviorCommandHook(context);
    assertNotNull(context.getBehaviorCommandHook());
    assertTrue(context.getBehaviorCommandHook() instanceof InheritableBehaviorCommandHook);
    assertEquals(2, ((InheritableBehaviorCommandHook) context.getBehaviorCommandHook()).countManagedHook());
    // ## Act ##
    context.terminateLastBehaviorCommandHook();
    // ## Assert ##
    BehaviorCommandHook hook = context.getBehaviorCommandHook();
    assertNotNull(hook);
    hook.hookBefore(null);
    hook.hookFinally(null, null);
    assertMarked("firstBefore");
    assertMarked("firstFinally");
    assertFalse(context.getBehaviorCommandHook() instanceof InheritableBehaviorCommandHook);
}
Also used : InheritableBehaviorCommandHook(org.dbflute.hook.CallbackContext.InheritableBehaviorCommandHook) BehaviorCommandHook(org.dbflute.bhv.core.BehaviorCommandHook) InheritableBehaviorCommandHook(org.dbflute.hook.CallbackContext.InheritableBehaviorCommandHook)

Example 2 with InheritableBehaviorCommandHook

use of org.dbflute.hook.CallbackContext.InheritableBehaviorCommandHook in project dbflute-core by dbflute.

the class CallbackContextTest method test_BehaviorCommandHook_threeSet_terminateLast.

public void test_BehaviorCommandHook_threeSet_terminateLast() throws Exception {
    // ## Arrange ##
    CallbackContext context = new CallbackContext();
    assertNull(context.getBehaviorCommandHook());
    setupThreeBehaviorCommandHook(context);
    assertNotNull(context.getBehaviorCommandHook());
    assertTrue(context.getBehaviorCommandHook() instanceof InheritableBehaviorCommandHook);
    assertEquals(3, ((InheritableBehaviorCommandHook) context.getBehaviorCommandHook()).countManagedHook());
    // ## Act ##
    context.terminateLastBehaviorCommandHook();
    // ## Assert ##
    BehaviorCommandHook hook = context.getBehaviorCommandHook();
    assertNotNull(hook);
    hook.hookBefore(null);
    hook.hookFinally(null, null);
    assertMarked("firstBefore");
    assertMarked("secondBefore");
    assertMarked("secondFinally");
    assertMarked("firstFinally");
    assertTrue(context.getBehaviorCommandHook() instanceof InheritableBehaviorCommandHook);
}
Also used : InheritableBehaviorCommandHook(org.dbflute.hook.CallbackContext.InheritableBehaviorCommandHook) BehaviorCommandHook(org.dbflute.bhv.core.BehaviorCommandHook) InheritableBehaviorCommandHook(org.dbflute.hook.CallbackContext.InheritableBehaviorCommandHook)

Aggregations

BehaviorCommandHook (org.dbflute.bhv.core.BehaviorCommandHook)2 InheritableBehaviorCommandHook (org.dbflute.hook.CallbackContext.InheritableBehaviorCommandHook)2