Package org.axonframework.commandhandling

Examples of org.axonframework.commandhandling.CommandHandler


    @Test
    public void testFixture_DispatchMetaDataInCommand() throws Throwable {
        List<?> givenEvents = Arrays.asList(new MyEvent("aggregateId", 1), new MyEvent("aggregateId", 2),
                                            new MyEvent("aggregateId", 3));
        CommandHandler mockCommandHandler = mock(CommandHandler.class);
        fixture.registerCommandHandler(StrangeCommand.class, mockCommandHandler);
        fixture
                .given(givenEvents)
                .when(new StrangeCommand("aggregateId"), Collections.singletonMap("meta", "value"));
View Full Code Here


    }

    @Test
    public void testAggregateCommandHandlersOverwrittenByCustomHandlers() {
        final AtomicBoolean invoked = new AtomicBoolean(false);
        fixture.registerCommandHandler(CreateAggregateCommand.class, new CommandHandler() {
            @Override
            public Object handle(CommandMessage commandMessage, UnitOfWork unitOfWork) throws Throwable {
                invoked.set(true);
                return null;
            }
View Full Code Here

        map.put("ignored", mockCommandBus);
        when(mockApplicationContext.getBeansOfType(CommandBus.class)).thenReturn(map);

        AnnotationCommandHandlerAdapter adapter = mock(AnnotationCommandHandlerAdapter.class);
        when(adapter.supportedCommands()).thenReturn(Collections.singleton("test"));
        CommandHandler handler = mock(CommandHandler.class);

        testSubject.subscribe(handler, adapter);

        verify(mockApplicationContext).getBeansOfType(CommandBus.class);
        verify(mockCommandBus).subscribe(anyString(), eq(handler));
View Full Code Here

    @SuppressWarnings({"unchecked"})
    @Test
    public void testEventHandlerAdapterIsInitializedAndDestroyedProperly_NoStopSignal() throws Exception {
        Object result1 = testSubject.postProcessBeforeInitialization(new AnnotatedCommandHandler(), "beanName");
        CommandHandler postProcessedBean = (CommandHandler) testSubject.postProcessAfterInitialization(result1,
                                                                                                       "beanName");

        verify(mockCommandBus, never()).subscribe(eq(MyCommand.class.getName()), isA(CommandHandler.class));
        verify(mockCommandBus, never()).unsubscribe(eq(MyCommand.class.getName()), isA(CommandHandler.class));
View Full Code Here

    @SuppressWarnings({"unchecked"})
    @Test
    public void testEventHandlerAdapterIsInitializedAndDestroyedProperly_NormalLifecycle() throws Exception {
        Object result1 = testSubject.postProcessBeforeInitialization(new AnnotatedCommandHandler(), "beanName");
        CommandHandler postProcessedBean = (CommandHandler) testSubject.postProcessAfterInitialization(result1,
                                                                                                       "beanName");

        verify(mockCommandBus, never()).subscribe(eq(MyCommand.class.getName()), isA(CommandHandler.class));
        verify(mockCommandBus, never()).unsubscribe(eq(MyCommand.class.getName()), isA(CommandHandler.class));
View Full Code Here

TOP

Related Classes of org.axonframework.commandhandling.CommandHandler

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.