@Test
public void testOutOfServiceJobWithRealStateDown() {

    jobManagerStub.moveTaskToState(taskId1, TaskState.Started);
    StepVerifier.create(healthService.events(false))
            // Register first with DOWN state
            .then(() -> registerAndRefresh(InstanceStatus.DOWN))
            .assertNext(event -> assertContainerHealthAndEvent(event, healthService.getHealthStatus(taskId1), taskId1, ContainerHealthState.Unhealthy))
            // Disable job and change state to OUT_OF_SERVICE
            .then(() -> jobManagerStub.changeJobEnabledStatus(job1, false))
            .assertNext(event -> assertContainerHealthAndEvent(event, healthService.getHealthStatus(taskId1), taskId1, ContainerHealthState.Healthy))
            .then(() -> registerAndRefresh(InstanceStatus.OUT_OF_SERVICE))
            .assertNext(event -> assertContainerHealthAndEvent(event, healthService.getHealthStatus(taskId1), taskId1, ContainerHealthState.Healthy))
            // Enable job and remove OUT_OF_SERVICE override
            .then(() -> jobManagerStub.changeJobEnabledStatus(job1, true))
            .assertNext(event -> assertContainerHealthAndEvent(event, healthService.getHealthStatus(taskId1), taskId1, ContainerHealthState.Unhealthy))
            .then(() -> registerAndRefresh(InstanceStatus.UP))
            .assertNext(event -> assertContainerHealthAndEvent(event, healthService.getHealthStatus(taskId1), taskId1, ContainerHealthState.Healthy))
            .thenCancel()
            .verify(Duration.ofSeconds(5_000));
}