@Test
public void testTerminateTaskWithEnoughQuota() {

    Pair<Job, List<Task>> jobAndTask = createAndStartJobWithTasks(1);
    Job<?> job = jobAndTask.getLeft();
    Task task = jobAndTask.getRight().get(0);
    when(quotasManager.findEvictionQuota(Reference.job(job.getId()))).thenReturn(Optional.of(EvictionQuota.jobQuota(job.getId(), 1, "Test")));
    when(quotasManager.tryConsumeQuota(job, task)).thenReturn(ConsumptionResult.approved());
    StepVerifier.withVirtualTime(
            () -> newTerminationExecutor().terminateTask(task.getId(), EVICTION_REASON, "callerContext")
    ).verifyComplete();
    expectTaskTerminationEvent(task, true);
    verify(quotasManager, times(1)).tryConsumeQuota(job, task);
}