SingleThreadJTAExecutor { public void executeBeforeCompletion(TXState txState, Executor executor, CancelCriterion cancelCriterion) { executor.execute(() -> doOps(txState, cancelCriterion)); beforeCompletion.execute(cancelCriterion); } SingleThreadJTAExecutor();  SingleThreadJTAExecutor(BeforeCompletion beforeCompletion,
      AfterCompletion afterCompletion); void executeBeforeCompletion(TXState txState, Executor executor,
      CancelCriterion cancelCriterion); void executeAfterCompletionCommit(); void executeAfterCompletionRollback(); void cleanup(); boolean shouldDoCleanup();  }
@Test public void executeBeforeCompletionCallsDoOps() { InOrder inOrder = inOrder(beforeCompletion, afterCompletion); singleThreadJTAExecutor.executeBeforeCompletion(txState, executor, cancelCriterion); verify(beforeCompletion, times(1)).execute(eq(cancelCriterion)); await() .untilAsserted(() -> inOrder.verify(beforeCompletion, times(1)).doOp(eq(txState))); await().untilAsserted( () -> inOrder.verify(afterCompletion, times(1)).doOp(eq(txState), eq(cancelCriterion))); }