@Test public void commit() { XOTransaction xoTransaction = new XOTransactionImpl(datastoreTransaction); xoTransaction.begin(); assertThat(xoTransaction.isActive(), equalTo(true)); xoTransaction.commit(); assertThat(xoTransaction.isActive(), equalTo(false)); verify(datastoreTransaction).begin(); verify(datastoreTransaction).commit(); verify(datastoreTransaction, never()).rollback(); }
@Override public void commit() { if (rollbackOnly) { throw new XOException("Transaction is marked as rollback only."); } beforeCompletion(); boolean committed = false; try { datastoreTransaction.commit(); committed = true; } finally { afterCompletion(committed); } }
XOTransactionImpl implements XOTransaction { @Override public void commit() { if (rollbackOnly) { throw new XOException("Transaction is marked as rollback only."); } beforeCompletion(); boolean committed = false; try { datastoreTransaction.commit(); committed = true; } finally { afterCompletion(committed); } } }
XOTransactionImpl implements XOTransaction { @Override public void commit() { if (rollbackOnly) { throw new XOException("Transaction is marked as rollback only."); } beforeCompletion(); boolean committed = false; try { datastoreTransaction.commit(); committed = true; } finally { afterCompletion(committed); } } XOTransactionImpl(DatastoreTransaction datastoreTransaction); }
XOTransactionImpl implements XOTransaction { @Override public void commit() { if (rollbackOnly) { throw new XOException("Transaction is marked as rollback only."); } beforeCompletion(); boolean committed = false; try { datastoreTransaction.commit(); committed = true; } finally { afterCompletion(committed); } } XOTransactionImpl(DatastoreTransaction datastoreTransaction); @Override XOTransaction begin(); @Override void commit(); @Override void rollback(); @Override boolean isActive(); @Override void setRollbackOnly(); @Override boolean isRollbackOnly(); @Override void registerSynchronization(Synchronization synchronization); @Override void unregisterSynchronization(Synchronization synchronization); void registerDefaultSynchronization(Synchronization synchronization); @Override void close(); }
XOTransactionImpl implements XOTransaction { @Override public void commit() { if (rollbackOnly) { throw new XOException("Transaction is marked as rollback only."); } beforeCompletion(); boolean committed = false; try { datastoreTransaction.commit(); committed = true; } finally { afterCompletion(committed); } } XOTransactionImpl(DatastoreTransaction datastoreTransaction); @Override XOTransaction begin(); @Override void commit(); @Override void rollback(); @Override boolean isActive(); @Override void setRollbackOnly(); @Override boolean isRollbackOnly(); @Override void registerSynchronization(Synchronization synchronization); @Override void unregisterSynchronization(Synchronization synchronization); void registerDefaultSynchronization(Synchronization synchronization); @Override void close();  }