EntityTransactionImpl implements EntityTransaction { @Override public void commit() { verifyTransactionActive("commit"); try { LOG.trace("EntityTransaction commit started."); if (rollbackOnly) { throw new RollbackException("Trying to commit transaction marked as rollback only."); } else { try { wrapper.getTransactionUOW().commit(); } catch (RuntimeException ex) { wrapper.getEntityManager().removeCurrentPersistenceContext(); throw new RollbackException(ex); } } } finally { if (wrapper.getTransactionUOW().shouldReleaseAfterCommit()) { wrapper.getEntityManager().removeCurrentPersistenceContext(); } cleanup(); LOG.trace("EntityTransaction commit finished."); } } EntityTransactionImpl(EntityTransactionWrapper wrapper); @Override void begin(); @Override void commit(); @Override void rollback(); @Override void setRollbackOnly(); @Override boolean isRollbackOnly(); @Override boolean isActive();  }
@Test public void testCommit() { transaction.begin(); transaction.commit(); assertFalse(transaction.isActive()); verify(emMock).transactionFinished(transaction); }
@Test public void testCommitNotActive() { assertThrows(IllegalStateException.class, () -> transaction.commit()); }