Package org.axonframework.commandhandling

Examples of org.axonframework.commandhandling.CommandCallback


    }

    @Test
    public void testCommandHandlerCreatesAggregateInstance() {

        final CommandCallback callback = mock(CommandCallback.class);
        commandBus.dispatch(GenericCommandMessage.asCommandMessage(new CreateCommand("id", "Hi")), callback);
        verify(mockRepository).add(isA(StubCommandAnnotatedAggregate.class));
        // make sure the identifier was invoked in the callback
        verify(callback).onSuccess("id");
    }
View Full Code Here


    @Test(timeout = 2000)
    public void testCreateGateway_WaitForResultAndInvokeCallbacks_Success() {
        CountDownLatch cdl = new CountDownLatch(1);

        final CommandCallback callback1 = mock(CommandCallback.class);
        final CommandCallback callback2 = mock(CommandCallback.class);

        doAnswer(new Success(cdl, "OK"))
                .when(mockCommandBus).dispatch(isA(CommandMessage.class), isA(CommandCallback.class));

        Object result = gateway.fireAndWaitAndInvokeCallbacks("Command", callback1, callback2);
View Full Code Here

    }


    @Test(timeout = 2000)
    public void testCreateGateway_WaitForResultAndInvokeCallbacks_Failure() {
        final CommandCallback callback1 = mock(CommandCallback.class);
        final CommandCallback callback2 = mock(CommandCallback.class);

        final RuntimeException exception = new RuntimeException();
        doAnswer(new Failure(exception))
                .when(mockCommandBus).dispatch(isA(CommandMessage.class), isA(CommandCallback.class));
        try {
View Full Code Here

    @Test(timeout = 2000)
    public void testCreateGateway_AsyncWithCallbacks_Success() {
        CountDownLatch cdl = new CountDownLatch(1);

        final CommandCallback callback1 = mock(CommandCallback.class);
        final CommandCallback callback2 = mock(CommandCallback.class);

        doAnswer(new Success(cdl, "OK"))
                .when(mockCommandBus).dispatch(isA(CommandMessage.class), isA(CommandCallback.class));

        gateway.fireAsyncWithCallbacks("Command", callback1, callback2);
View Full Code Here

    @Test(timeout = 2000)
    public void testCreateGateway_AsyncWithCallbacks_Success_ButReturnTypeDoesntMatchCallback() {
        CountDownLatch cdl = new CountDownLatch(1);

        final CommandCallback callback1 = mock(CommandCallback.class);
        final CommandCallback callback2 = mock(CommandCallback.class);

        doAnswer(new Success(cdl, 42))
                .when(mockCommandBus).dispatch(isA(CommandMessage.class), isA(CommandCallback.class));

        gateway.fireAsyncWithCallbacks("Command", callback1, callback2);
View Full Code Here

        verify(callback, never()).onSuccess(anyObject());
    }

    @Test(timeout = 2000)
    public void testCreateGateway_AsyncWithCallbacks_Failure() {
        final CommandCallback callback1 = mock(CommandCallback.class);
        final CommandCallback callback2 = mock(CommandCallback.class);

        final RuntimeException exception = new RuntimeException();
        doAnswer(new Failure(exception))
                .when(mockCommandBus).dispatch(isA(CommandMessage.class), isA(CommandCallback.class));
View Full Code Here

                        return ((InterceptorChain) invocation.getArguments()[2]).proceed();
                    }
                });
        CommandMessage<StubCommand> command = new GenericCommandMessage<StubCommand>(
                new StubCommand(aggregateIdentifier));
        CommandCallback mockCallback = mock(CommandCallback.class);
        testSubject.dispatch(command, mockCallback);

        testSubject.stop();
        assertFalse(customExecutor.awaitTermination(250, TimeUnit.MILLISECONDS));
        customExecutor.shutdown();
View Full Code Here

                                          .createRepository(new GenericAggregateFactory<StubAggregate>(StubAggregate.class),
                                                            mockDecorator));

        CommandMessage<StubCommand> command = new GenericCommandMessage<StubCommand>(
                new StubCommand(aggregateIdentifier));
        CommandCallback mockCallback = mock(CommandCallback.class);
        testSubject.dispatch(command, mockCallback);
        testSubject.dispatch(command);

        testSubject.stop();
        assertFalse(customExecutor.awaitTermination(250, TimeUnit.MILLISECONDS));
View Full Code Here

    @SuppressWarnings("unchecked")
    @Test(timeout = 10000)
    public void testAggregatesBlacklistedAndRecoveredOnError_WithAutoReschedule() throws Throwable {
        CommandHandlerInterceptor mockInterceptor = mock(CommandHandlerInterceptor.class);
        ExecutorService customExecutor = Executors.newCachedThreadPool();
        CommandCallback mockCallback = dispatchCommands(mockInterceptor,
                                                        customExecutor,
                                                        new GenericCommandMessage<ErrorCommand>(
                                                                new ErrorCommand(aggregateIdentifier))
        );
        assertFalse(customExecutor.awaitTermination(250, TimeUnit.MILLISECONDS));
View Full Code Here

    @Test(timeout = 10000)
    public void testAggregatesBlacklistedAndRecoveredOnError_WithoutReschedule() throws Throwable {
        CommandHandlerInterceptor mockInterceptor = mock(CommandHandlerInterceptor.class);
        ExecutorService customExecutor = Executors.newCachedThreadPool();

        CommandCallback mockCallback = dispatchCommands(mockInterceptor,
                                                        customExecutor,
                                                        new GenericCommandMessage<ErrorCommand>(
                                                                new ErrorCommand(aggregateIdentifier))
        );
View Full Code Here

TOP

Related Classes of org.axonframework.commandhandling.CommandCallback

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.