TransactionAccountTo accToAfter = pm.getByKey(TransactionAccountTo.class, accTo.id);
assertTrue(1100L == accToAfter.amount);
}
public void testTransactionSaveFailure() {
TransactionAccountFromModel accFrom = new TransactionAccountFromModel(1000L);
TransactionAccountToModel accTo = new TransactionAccountToModel(1000L);
accFrom.insert();
accTo.insert();
try {
accFrom.getPersistenceManager().beginTransaction();
accFrom.amount-=100L;
accFrom.save();
accTo.amount+=100L;
accTo.save();
throw new SienaException("test");
}catch(SienaException e){
accFrom.getPersistenceManager().rollbackTransaction();
}finally{
accFrom.getPersistenceManager().closeConnection();
}
TransactionAccountFrom accFromAfter = pm.getByKey(TransactionAccountFrom.class, accFrom.id);
assertTrue(1000L == accFromAfter.amount);
TransactionAccountTo accToAfter = pm.getByKey(TransactionAccountTo.class, accTo.id);