Package org.axonframework.saga

Examples of org.axonframework.saga.SagaManager


    @Test
    @DirtiesContext
    public void testSagaManagerWiring() {
        // this part should prove correct autowiring of the saga manager
        SagaManager sagaManager = beanFactory.getBean("sagaManager", SagaManager.class);
        assertNotNull(sagaManager);

        // This type is found using component scanning
        when(sagaFactory.supports(StubSaga.class)).thenReturn(true);
        when(sagaFactory.createSaga(any(Class.class))).thenAnswer(new Answer<Object>() {
            @Override
            public Object answer(InvocationOnMock invocation) throws Throwable {
                return ((Class) invocation.getArguments()[0]).newInstance();
            }
        });

        String identifier = UUID.randomUUID().toString();
        final GenericDomainEventMessage<SimpleEvent> event = new GenericDomainEventMessage<SimpleEvent>(identifier,
                                                                                                        (long) 0,
                                                                                                        new SimpleEvent(
                                                                                                                identifier),
                                                                                                        MetaData.emptyInstance());
        sagaManager.handle(event);

        verify(correlationDataProvider, times(2)).correlationDataFor(event);
        verify(sagaFactory).createSaga(StubSaga.class);
    }
View Full Code Here


    @Test
    @DirtiesContext
    public void testAsyncSagaManagerWiring() throws InterruptedException {

        // this part should prove correct autowiring of the saga manager
        SagaManager sagaManager = beanFactory.getBean("asyncSagaManager", SagaManager.class);
        assertNotNull(sagaManager);
        assertNotNull(tm);

        when(sagaFactory.supports(StubSaga.class)).thenReturn(true);
        when(sagaFactory.createSaga(StubSaga.class)).thenReturn(new StubSaga());

        String identifier = UUID.randomUUID().toString();
        sagaManager.handle(new GenericDomainEventMessage<SimpleEvent>(identifier, (long) 0,
                                                                      new SimpleEvent(
                                                                              identifier), MetaData.emptyInstance()));
        Thread.sleep(250);
        te.shutdown();
        te.getThreadPoolExecutor().awaitTermination(2, TimeUnit.SECONDS);
View Full Code Here

TOP

Related Classes of org.axonframework.saga.SagaManager

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.