@Test
public void testJobManagerUpdate() {

    StepVerifier.create(healthService.events(false))
            // Task launched, but not in Eureka yet.
            .then(() -> jobManagerStub.moveTaskToState(taskId1, TaskState.Launched))
            .assertNext(event -> assertContainerHealthAndEvent(event, healthService.getHealthStatus(taskId1), taskId1, ContainerHealthState.Unknown))
            // Task started and registered with Eureka
            .then(() -> {
                eurekaServer.register(newInstanceInfo(taskId1, InstanceStatus.UP));
                jobManagerStub.moveTaskToState(taskId1, TaskState.Started);
            })
            .assertNext(event -> assertContainerHealthAndEvent(event, healthService.getHealthStatus(taskId1), taskId1, ContainerHealthState.Healthy))
            // Task terminated
            .then(() -> jobManagerStub.moveTaskToState(task1, TaskState.Finished))
            .assertNext(event -> assertContainerHealthAndEvent(event, healthService.getHealthStatus(taskId1), taskId1, ContainerHealthState.Terminated))
            .thenCancel()
            .verify(Duration.ofSeconds(5));
}