use of siena.base.test.model.TransactionAccountFrom in project siena by mandubian.
the class GaeTest method testTransactionDelete.
public void testTransactionDelete() {
TransactionAccountFrom accFrom = new TransactionAccountFrom(1000L);
pm.insert(accFrom);
try {
pm.beginTransaction(Connection.TRANSACTION_READ_COMMITTED);
pm.delete(accFrom);
pm.commitTransaction();
} catch (SienaException e) {
pm.rollbackTransaction();
fail();
} finally {
pm.closeConnection();
}
TransactionAccountFrom accFromAfter = pm.getByKey(TransactionAccountFrom.class, accFrom.id);
assertNull(accFromAfter);
}
use of siena.base.test.model.TransactionAccountFrom in project siena by mandubian.
the class GaeTest method testTransactionInsertFailure.
public void testTransactionInsertFailure() {
TransactionAccountFrom accFrom = new TransactionAccountFrom(1000L);
try {
pm.beginTransaction(Connection.TRANSACTION_READ_COMMITTED);
accFrom.amount = 1000L;
pm.insert(accFrom);
throw new SienaException("test");
} catch (SienaException e) {
pm.rollbackTransaction();
} finally {
pm.closeConnection();
}
TransactionAccountFrom accFromAfter = pm.getByKey(TransactionAccountFrom.class, accFrom.id);
assertNull(accFromAfter);
}
use of siena.base.test.model.TransactionAccountFrom in project siena by mandubian.
the class GaeTest method testTransactionDeleteBatch.
public void testTransactionDeleteBatch() {
TransactionAccountFrom accFrom = new TransactionAccountFrom(1000L);
pm.insert(accFrom);
try {
pm.beginTransaction(Connection.TRANSACTION_READ_COMMITTED);
pm.delete(accFrom);
pm.commitTransaction();
} catch (SienaException e) {
pm.rollbackTransaction();
fail();
} finally {
pm.closeConnection();
}
TransactionAccountFrom accFromAfter = pm.getByKey(TransactionAccountFrom.class, accFrom.id);
assertNull(accFromAfter);
}
use of siena.base.test.model.TransactionAccountFrom in project siena by mandubian.
the class GaeTest method testTransactionSaveBatch.
public void testTransactionSaveBatch() {
TransactionAccountFrom accFrom = new TransactionAccountFrom(1000L);
pm.insert(accFrom);
try {
pm.beginTransaction(Connection.TRANSACTION_READ_COMMITTED);
accFrom.amount -= 100L;
pm.save(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 testTransactionUpdateFailure.
@Override
public void testTransactionUpdateFailure() {
TransactionAccountFrom accFrom = new TransactionAccountFrom(1000L);
pm.insert(accFrom);
try {
pm.beginTransaction(Connection.TRANSACTION_READ_COMMITTED);
accFrom.amount -= 100L;
pm.update(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);
}
Aggregations