*
* @param afterTest the test event
*/
public void endTransactionAfterTest(@Observes(precedence = 50) After afterTest) {
TransactionProvider transactionProvider;
if (isTransactionEnabled(afterTest)) {
// retrieves the transaction mode, declared for the test method
TransactionMode transactionMode = getTransactionMode(afterTest);
if (transactionMode != TransactionMode.DISABLED) {
try {
lifecycleEvent.fire(new BeforeTransactionEnded());
transactionProvider = getTransactionProvider();
TransactionalTest transactionalTest =
new TransactionalTestImpl(getTransactionManager(afterTest));
if (transactionMode == TransactionMode.ROLLBACK || isTestRequiresRollback()) {
// rollbacks the transaction
transactionProvider.rollbackTransaction(transactionalTest);
} else {
// commits the transaction
transactionProvider.commitTransaction(transactionalTest);
}
} finally {
lifecycleEvent.fire(new AfterTransactionEnded());