@@ -0,0 +1,2375 @@
+package router.client.api2;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.concurrent.atomic.AtomicInteger;%0Aimport java.util.function.Consumer;%0Aimport javax.annotation.Nonnull;%0Aimport org.testng.annotations.Test;%0Aimport static org.mockito.Mockito.*;%0Aimport static org.testng.Assert.*;%0A%0A@SuppressWarnings( %22NonJREEmulationClassesInClientCode%22 )%0Apublic final class OnLeaveCallbackChainTest%0A%7B%0A  @Test%0A  public void emptyChain_goesToNext()%0A  %7B%0A    final ArrayList%3CRouteEntry%3COnLeaveCallbackAsync%3E%3E elements = new ArrayList%3C%3E();%0A    final OnLeaveCallbackChain chain = new OnLeaveCallbackChain( elements );%0A%0A    final Runnable nextAction = mock( Runnable.class );%0A%0A    chain.onLeave( nextAction );%0A%0A    verify( nextAction ).run();%0A  %7D%0A%0A  @Test%0A  public void basicChain()%0A  %7B%0A    final AtomicInteger count = new AtomicInteger();%0A    final ArrayList%3CRouteEntry%3COnLeaveCallbackAsync%3E%3E elements = new ArrayList%3C%3E();%0A    elements.add( newEntry( count, ChainControl::proceed ) );%0A    elements.add( newEntry( count, ChainControl::proceed ) );%0A    elements.add( newEntry( count, ChainControl::proceed ) );%0A    final OnLeaveCallbackChain chain = new OnLeaveCallbackChain( elements );%0A%0A    final Runnable nextAction = mock( Runnable.class );%0A%0A    chain.onLeave( nextAction );%0A%0A    verify( nextAction ).run();%0A%0A    assertEquals( count.intValue(), 3 );%0A  %7D%0A%0A  @Test%0A  public void basicChainWithHalt()%0A  %7B%0A    final AtomicInteger count = new AtomicInteger();%0A    final ArrayList%3CRouteEntry%3COnLeaveCallbackAsync%3E%3E elements = new ArrayList%3C%3E();%0A    elements.add( newEntry( count, ChainControl::proceed ) );%0A    elements.add( newEntry( count, ChainControl::proceed ) );%0A    elements.add( newEntry( count, ChainControl::halt ) );%0A    elements.add( newEntry( count, ChainControl::proceed ) );%0A    final OnLeaveCallbackChain chain = new OnLeaveCallbackChain( elements );%0A%0A    final Runnable nextAction = mock( Runnable.class );%0A%0A    chain.onLeave( nextAction );%0A%0A    verify( nextAction ).run();%0A%0A    assertEquals( count.intValue(), 3 );%0A  %7D%0A%0A  @Nonnull%0A  private RouteEntry%3COnLeaveCallbackAsync%3E newEntry( @Nonnull final AtomicInteger count,%0A                                                     @Nonnull final Consumer%3COnLeaveControl%3E callback )%0A  %7B%0A    return new RouteEntry%3C%3E( FactoryUtil.createLocation(), ( l, c ) -%3E%0A    %7B%0A      count.incrementAndGet();%0A      callback.accept( c );%0A    %7D );%0A  %7D%0A%7D%0A

Add test for OnLeaveCallbackChain