Package org.axonframework.unitofwork

Examples of org.axonframework.unitofwork.UnitOfWork.commit()


                if (nestingCounter.decrementAndGet() > 0) {
                    UnitOfWork uow = DefaultUnitOfWork.startAndGet();
                    try {
                        testSubject.handle(event);
                    } finally {
                        uow.commit();
                    }
                }
                return null;
            }
        }).when(mockSaga1).handle(isA(EventMessage.class));
View Full Code Here


        aggregate.doSomething();
        aggregate.doSomething();

        assertEquals("Return value", result);
        uow.commit();

        verify(mockAuditDataProvider, atLeast(1)).provideAuditDataFor(command);
        verify(mockAuditLogger, times(1)).logSuccessful(eq(command), any(Object.class), listWithTwoEventMessages());
        DomainEventMessage eventFromAggregate = aggregate.getUncommittedEvents().next();
        assertEquals("value", eventFromAggregate.getMetaData().get("key"));
View Full Code Here

        assertNull(entityManager.find(SagaEntry.class, identifier));
        assertTrue(entityManager.createQuery("SELECT ae FROM AssociationValueEntry ae WHERE ae.sagaId = :id")
                                .setParameter("id", identifier)
                                .getResultList().isEmpty());

        uow.commit();
    }

    public static class MyOtherTestSaga extends AbstractAnnotatedSaga {

        private static final long serialVersionUID = -1562911263884220240L;
View Full Code Here

            public Object answer(InvocationOnMock invocation) throws Throwable {
                CurrentUnitOfWork.get().publishEvent(new GenericEventMessage<String>("Second"), eventBus);
                return null;
            }
        }).when(eventListener).handle(event);
        uow.commit();
        verify(eventListener, times(2)).handle(isA(EventMessage.class));
    }
}
View Full Code Here

        middleUnit.registerListener(listener);
        innerUnit.registerListener(listener);
        middleUnit.registerListener(middleListener);
        innerUnit.registerListener(innerListener);

        innerUnit.commit();
        middleUnit.commit();

        verify(innerListener, never()).afterCommit(any(UnitOfWork.class));
        verify(middleListener, never()).afterCommit(any(UnitOfWork.class));
View Full Code Here

        assertNotNull(innerUoW.getResource("inheritedAfterAll"));
        assertNull(innerUoW.getResource("notInherited"));
        assertNull(innerUoW.getResource("explicitlyNotInherited"));
        assertNull(innerUoW.getResource("inheritanceOverwritten"));

        innerUoW.commit();
        outerUoW.commit();
    }
}
View Full Code Here

    @Test
    public void testStoreAndLoadNewAggregate() {
        UnitOfWork uow = DefaultUnitOfWork.startAndGet();
        JpaAggregate originalAggregate = new JpaAggregate("Hello");
        repository.add(originalAggregate);
        uow.commit();

        entityManager.flush();
        entityManager.clear();
        List<JpaAggregate> results = entityManager.createQuery("SELECT a FROM JpaAggregate a").getResultList();
        assertEquals(1, results.size());
View Full Code Here

        assertEquals(originalAggregate.getIdentifier(), aggregate.getIdentifier());
        assertEquals(0, aggregate.getUncommittedEventCount());

        uow = DefaultUnitOfWork.startAndGet();
        JpaAggregate storedAggregate = repository.load(originalAggregate.getIdentifier());
        uow.commit();
        assertEquals(storedAggregate.getIdentifier(), originalAggregate.getIdentifier());
        assertEquals((Long) 0L, originalAggregate.getVersion());
        assertTrue(capturedEvents.isEmpty());
    }
View Full Code Here

        UnitOfWork uow = DefaultUnitOfWork.startAndGet();
        JpaAggregate aggregate = repository.load(agg.getIdentifier());
        aggregate.setMessage("And again");
        aggregate.setMessage("And more");
        uow.commit();

        assertEquals((Long) 1L, aggregate.getVersion());
        assertEquals(0L, aggregate.getUncommittedEventCount());
        assertEquals(2, capturedEvents.size());
        assertEquals(0L, capturedEvents.get(0).getSequenceNumber());
View Full Code Here

        UnitOfWork uow = DefaultUnitOfWork.startAndGet();
        JpaAggregate aggregate = repository.load(agg.getIdentifier());
        aggregate.setMessage("And again");
        aggregate.setMessage("And more");
        aggregate.delete();
        uow.commit();
        entityManager.flush();
        entityManager.clear();

        assertEquals(0L, aggregate.getUncommittedEventCount());
        assertEquals(2, capturedEvents.size());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.