BeforeCompletion { public synchronized void execute(CancelCriterion cancelCriterion) { started = true; waitUntilFinished(cancelCriterion); if (exception != null) { throw exception; } }  synchronized void doOp(TXState txState); synchronized void execute(CancelCriterion cancelCriterion); synchronized boolean isStarted(); synchronized boolean isFinished();  }
@Test public void executeThrowsIfCancelCriterionThrows() { doThrow(new RuntimeException()).when(cancelCriterion).checkCancelInProgress(null); assertThatThrownBy(() -> beforeCompletion.execute(cancelCriterion)) .isInstanceOf(RuntimeException.class); }