当前位置: 首页>>代码示例>>Java>>正文


Java UnitOfWork类代码示例

本文整理汇总了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);
}
 
开发者ID:arturgaleno,项目名称:cqrs-tutorial,代码行数:17,代码来源:MemberRegistrationTest.java

示例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();
}
 
开发者ID:binkley,项目名称:axon-spring-boot-starter,代码行数:9,代码来源:HandlerInterceptorsTestConfiguration.java

示例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();
  }
 
开发者ID:arturgaleno,项目名称:cqrs-tutorial,代码行数:8,代码来源:MemberRegistrationTest.java

示例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");
  }
 
开发者ID:benwilcock,项目名称:axon-cqrs-sample,代码行数:15,代码来源:ToDoItemDemoRunner.java

示例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();
  }
 
开发者ID:arturgaleno,项目名称:cqrs-tutorial,代码行数:7,代码来源:MemberRegistrationTest.java

示例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);
}
 
开发者ID:arturgaleno,项目名称:cqrs-tutorial,代码行数:17,代码来源:MemberRegistrationTest.java

示例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;
}
 
开发者ID:arturgaleno,项目名称:cqrs-tutorial,代码行数:12,代码来源:DebitAccountHandler.java

示例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;
}
 
开发者ID:arturgaleno,项目名称:cqrs-tutorial,代码行数:12,代码来源:CreditAccountHandler.java

示例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);
}
 
开发者ID:arturgaleno,项目名称:cqrs-tutorial,代码行数:15,代码来源:MemberRegistrationTest.java

示例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);
}
 
开发者ID:arturgaleno,项目名称:cqrs-tutorial,代码行数:15,代码来源:MemberRegistrationTest.java

示例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);
}
 
开发者ID:arturgaleno,项目名称:cqrs-tutorial,代码行数:15,代码来源:MemberRegistrationTest.java


注:本文中的org.axonframework.unitofwork.UnitOfWork类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。