@@ -0,0 +1,2687 @@
+/*%0A * Copyright 2017, TeamDev Ltd. All rights reserved.%0A *%0A * Redistribution and use in source and/or binary forms, with or without%0A * modification, must retain the above copyright notice and the following%0A * disclaimer.%0A *%0A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS%0A * %22AS IS%22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT%0A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR%0A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT%0A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,%0A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT%0A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,%0A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY%0A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT%0A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE%0A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.%0A */%0A%0Apackage io.spine.server.commandbus;%0A%0Aimport com.google.common.collect.ImmutableSet;%0Aimport io.spine.client.TestActorRequestFactory;%0Aimport io.spine.core.CommandClass;%0Aimport io.spine.core.CommandEnvelope;%0Aimport org.junit.Test;%0A%0Aimport java.util.Set;%0A%0Aimport static io.spine.test.TestValues.newUuidValue;%0Aimport static org.junit.Assert.assertTrue;%0A%0Apublic class DelegatingCommandDispatcherShould %7B%0A%0A    @Test%0A    public void delegate_onError() throws Exception %7B%0A        final EmptyCommandDispatcherDelegate delegate = new EmptyCommandDispatcherDelegate();%0A%0A        final DelegatingCommandDispatcher%3CString%3E delegatingDispatcher =%0A                DelegatingCommandDispatcher.of(delegate);%0A%0A        final CommandEnvelope commandEnvelope = CommandEnvelope.of(%0A                TestActorRequestFactory.newInstance(getClass()).createCommand(newUuidValue())%0A        );%0A%0A        delegatingDispatcher.onError(commandEnvelope, new RuntimeException(getClass().getName()));%0A%0A        assertTrue(delegate.onErrorCalled());%0A    %7D%0A%0A    private static final class EmptyCommandDispatcherDelegate%0A            implements CommandDispatcherDelegate%3CString%3E %7B%0A%0A        private boolean onErrorCalled;%0A%0A        @Override%0A        public Set%3CCommandClass%3E getCommandClasses() %7B%0A            return ImmutableSet.of();%0A        %7D%0A%0A        @Override%0A        public String dispatchCommand(CommandEnvelope envelope) %7B%0A            return getClass().getName();%0A        %7D%0A%0A        @Override%0A        public void onError(CommandEnvelope envelope, RuntimeException exception) %7B%0A            onErrorCalled = true;%0A        %7D%0A%0A        boolean onErrorCalled() %7B%0A            return onErrorCalled;%0A        %7D%0A    %7D%0A%7D%0A

Test `onError()` delegation