Transaction { public void rollback() { if (state != ACTIVE && state != PARTIALLY_COMMITTED && state != FAILED) { throw new IllegalStateException("Cannot rollback transaction. Current state is " + state); } this.state = FAILED; }  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 testRollback() { transaction.begin(); transaction.rollback(); assertEquals(TransactionState.FAILED, transaction.getState()); assertFalse(transaction.isActive()); }