use of siena.base.test.model.TransactionAccountFrom in project siena by mandubian.
the class GaeModelTest method testTransactionSaveFailure.
public void testTransactionSaveFailure() {
TransactionAccountFromModel accFrom = new TransactionAccountFromModel(1000L);
accFrom.insert();
try {
accFrom.getPersistenceManager().beginTransaction();
accFrom.amount -= 100L;
accFrom.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);
}
use of siena.base.test.model.TransactionAccountFrom in project siena by mandubian.
the class GaeTest method testTransactionUpdateBatchFailure.
public void testTransactionUpdateBatchFailure() {
TransactionAccountFrom accFrom = new TransactionAccountFrom(1000L);
pm.insert(accFrom);
try {
pm.beginTransaction(Connection.TRANSACTION_READ_COMMITTED);
accFrom.amount -= 100L;
throw new SienaException("test");
} catch (SienaException e) {
pm.rollbackTransaction();
} finally {
pm.closeConnection();
}
TransactionAccountFrom accFromAfter = pm.getByKey(TransactionAccountFrom.class, accFrom.id);
assertTrue(1000L == accFromAfter.amount);
}
use of siena.base.test.model.TransactionAccountFrom in project siena by mandubian.
the class GaeTest method testTransactionDeleteFailure.
public void testTransactionDeleteFailure() {
TransactionAccountFrom accFrom = new TransactionAccountFrom(1000L);
pm.insert(accFrom);
try {
pm.beginTransaction(Connection.TRANSACTION_READ_COMMITTED);
pm.delete(accFrom);
throw new SienaException("test");
} catch (SienaException e) {
pm.rollbackTransaction();
} finally {
pm.closeConnection();
}
TransactionAccountFrom accFromAfter = pm.getByKey(TransactionAccountFrom.class, accFrom.id);
assertTrue(1000L == accFromAfter.amount);
}
use of siena.base.test.model.TransactionAccountFrom in project siena by mandubian.
the class GaeTest method testTransactionUpdateBatch.
public void testTransactionUpdateBatch() {
TransactionAccountFrom accFrom = new TransactionAccountFrom(1000L);
pm.insert(accFrom);
try {
pm.beginTransaction(Connection.TRANSACTION_READ_COMMITTED);
accFrom.amount -= 100L;
pm.update(accFrom);
pm.commitTransaction();
} catch (SienaException e) {
pm.rollbackTransaction();
fail();
} finally {
pm.closeConnection();
}
TransactionAccountFrom accFromAfter = pm.getByKey(TransactionAccountFrom.class, accFrom.id);
assertTrue(900L == accFromAfter.amount);
}
use of siena.base.test.model.TransactionAccountFrom in project siena by mandubian.
the class GaeTest method testTransactionInsert.
public void testTransactionInsert() {
TransactionAccountFrom accFrom = new TransactionAccountFrom(1000L);
try {
pm.beginTransaction(Connection.TRANSACTION_READ_COMMITTED);
accFrom.amount = 1000L;
pm.insert(accFrom);
pm.commitTransaction();
} catch (SienaException e) {
pm.rollbackTransaction();
fail();
} finally {
pm.closeConnection();
}
TransactionAccountFrom accFromAfter = pm.getByKey(TransactionAccountFrom.class, accFrom.id);
assertTrue(1000L == accFromAfter.amount);
}
Aggregations