AfterCompletion { public void executeRollback() { executeAction(Action.ROLLBACK); }  synchronized void doOp(TXState txState, CancelCriterion cancelCriterion); void executeCommit(); void executeRollback(); synchronized void cancel(); synchronized boolean isStarted();  }
@Test public void executeCallsDoAfterCompletionRollback() { startDoOp(); afterCompletion.executeRollback(); verifyDoOpFinished(); verify(txState).doAfterCompletionRollback(); }
@Test public void executeThrowsDoAfterCompletionRollbackThrows() { startDoOp(); doThrow(new RuntimeException()).when(txState).doAfterCompletionRollback(); assertThatThrownBy(() -> afterCompletion.executeRollback()) .isInstanceOf(RuntimeException.class); verifyDoOpFinished(); }