Transaction { public void afterCommit() { if (state != PARTIALLY_COMMITTED) { throw new IllegalStateException("Cannot finish commit. Current state is " + state); } this.state = COMMITTED; }  void begin(); void commit(); void afterCommit(); void rollback(); void afterRollback(); boolean isActive(); TransactionState getState(); void verifyActive(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test void testAfterCommit() { transaction.begin(); transaction.commit(); assertEquals(TransactionState.PARTIALLY_COMMITTED, transaction.getState()); transaction.afterCommit(); assertEquals(TransactionState.COMMITTED, transaction.getState()); assertFalse(transaction.isActive()); }