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