本文整理汇总了Java中org.axonframework.unitofwork.UnitOfWork类的典型用法代码示例。如果您正苦于以下问题:Java UnitOfWork类的具体用法?Java UnitOfWork怎么用?Java UnitOfWork使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UnitOfWork类属于org.axonframework.unitofwork包,在下文中一共展示了UnitOfWork类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: debitEventShouldReflectStateChange
import org.axonframework.unitofwork.UnitOfWork; //导入依赖的package包/类
@Test
public void debitEventShouldReflectStateChange() throws Exception {
double value = 100.00;
String account = "cc-1";
UnitOfWork unitOfWork = DefaultUnitOfWork.startAndGet(new JPATransationManager(tx));
Account acc = creditAccount(account, value);
acc = debitAccount(account, value);
unitOfWork.commit();
AccountView accountView = em.find(AccountView.class, acc.getIdentifier());
Assert.assertEquals(Double.valueOf(value), accountView.getAmmount(), 0.001);
Assert.assertEquals(acc.getBalance(), accountView.getBalance(), 0.001);
}
示例2: handle
import org.axonframework.unitofwork.UnitOfWork; //导入依赖的package包/类
@Override
public Object handle(final CommandMessage<?> commandMessage,
final UnitOfWork unitOfWork,
final InterceptorChain interceptorChain)
throws Throwable {
handlings.add(2);
return interceptorChain.proceed();
}
示例3: afterTeste
import org.axonframework.unitofwork.UnitOfWork; //导入依赖的package包/类
@After
public void afterTeste() {
UnitOfWork unitOfWork = DefaultUnitOfWork.startAndGet(new JPATransationManager(tx));
Account acc = repository.load("cc-1");
acc.markDeleted();
unitOfWork.commit();
}
示例4: loadAggregate
import org.axonframework.unitofwork.UnitOfWork; //导入依赖的package包/类
private static void loadAggregate(EventSourcingRepository repository, String toDoItemId) {
System.out.println("\n------------------- LOADING AGGREGATE -----------------------");
System.out.println("Loading 'ToDoItem' with Id: " + toDoItemId);
System.out.println("Events being re-applied...");
UnitOfWork unitOfWork = new DefaultUnitOfWorkFactory().createUnitOfWork();
ToDoItem item = (ToDoItem) repository.load(toDoItemId);
unitOfWork.commit();
System.out.println("Loaded...");
System.out.println(
"ToDoItem (" + item.getId() + ") " + "'" + item.getDescription() + "' " + "Complete?: "
+ item.isComplete());
System.out.println("---------------------- AGGREGATE LOADED -----------------------\n");
}
示例5: beforeTest
import org.axonframework.unitofwork.UnitOfWork; //导入依赖的package包/类
@Before
public void beforeTest() {
UnitOfWork unitOfWork = DefaultUnitOfWork.startAndGet(new JPATransationManager(tx));
repository.add(new Account("cc-1"));
unitOfWork.commit();
}
示例6: debitShouldDecreaseBalance
import org.axonframework.unitofwork.UnitOfWork; //导入依赖的package包/类
@Test
public void debitShouldDecreaseBalance() throws Exception {
UnitOfWork unitOfWork = DefaultUnitOfWork.startAndGet(new JPATransationManager(tx));
double value = 100.00;
String account = "cc-1";
Account acc = creditAccount(account, value);
acc = debitAccount(account, value);
unitOfWork.commit();
Assert.assertEquals(acc.getBalance(), 0.0000, 0.001);
}
示例7: handle
import org.axonframework.unitofwork.UnitOfWork; //导入依赖的package包/类
@Override
public Object handle(CommandMessage<DebitAccount> commandMessage, UnitOfWork unitOfWork) throws Throwable {
DebitAccount debitAccount = (DebitAccount) commandMessage.getPayload();
Account accountToDebit = repository.load(debitAccount.getAccount());
accountToDebit.debit(debitAccount.getAmount());
return null;
}
示例8: handle
import org.axonframework.unitofwork.UnitOfWork; //导入依赖的package包/类
@Override
public Object handle(CommandMessage<CreditAccount> commandMessage, UnitOfWork unitOfWork) throws Throwable {
CreditAccount creditAccount = (CreditAccount) commandMessage.getPayload();
Account accountToCredit = repository.load(creditAccount.getAccount());
accountToCredit.credit(creditAccount.getAmount());
return null;
}
示例9: debitShouldNotResultInNegativeBalance
import org.axonframework.unitofwork.UnitOfWork; //导入依赖的package包/类
@Test
public void debitShouldNotResultInNegativeBalance() throws Exception {
UnitOfWork unitOfWork = DefaultUnitOfWork.startAndGet(new JPATransationManager(tx));
double debitValue = 100.00;
String account = "cc-1";
Account acc = debitAccount(account, debitValue);
unitOfWork.commit();
Assert.assertEquals(acc.getBalance(), 0.0000, 0.001);
}
示例10: shouldNotCreditNegativeValue
import org.axonframework.unitofwork.UnitOfWork; //导入依赖的package包/类
@Test
public void shouldNotCreditNegativeValue() throws Exception {
UnitOfWork unitOfWork = DefaultUnitOfWork.startAndGet(new JPATransationManager(tx));
double creditValue = -100.00;
String account = "cc-1";
Account acc = creditAccount(account, creditValue);
unitOfWork.commit();
Assert.assertEquals(acc.getBalance(), 0.0000, 0.001);
}
示例11: creditShouldIncreaseBalance
import org.axonframework.unitofwork.UnitOfWork; //导入依赖的package包/类
@Test
public void creditShouldIncreaseBalance() throws Exception {
UnitOfWork unitOfWork = DefaultUnitOfWork.startAndGet(new JPATransationManager(tx));
double creditValue = 100.00;
String account = "cc-1";
Account acc = creditAccount(account, creditValue);
unitOfWork.commit();
Assert.assertEquals(acc.getBalance(), creditValue, 0.001);
}