Code review comment: ```suggestion         final CompletableFuture<Void> jobFinishedNotification = new CompletableFuture<>(); ```

Code before review:
public void testJobStatusListenerNotifiedOfJobStatusChanges() throws Exception {
final JobGraph jobGraph = createJobGraph();
final DefaultDeclarativeSlotPool declarativeSlotPool =
createDeclarativeSlotPool(jobGraph.getJobID());
final Configuration configuration = new Configuration();
configuration.set(JobManagerOptions.RESOURCE_WAIT_TIMEOUT, Duration.ofMillis(1L));
final CompletableFuture<Void> jobRunningNotification = new CompletableFuture<>();
final CompletableFuture<Void> jobFinishedNotificaiton = new CompletableFuture<>();
final CompletableFuture<JobStatus> unexpectedJobStatusNotification =
new CompletableFuture<>();
final AdaptiveScheduler scheduler =
new AdaptiveSchedulerBuilder(jobGraph, singleThreadMainThreadExecutor)
.setJobMasterConfiguration(configuration)
.setJobStatusListener(
(jobId, newJobStatus, timestamp) -> {
switch (newJobStatus) {
case RUNNING:
jobRunningNotification.complete(null);
break;
case FINISHED:
jobFinishedNotificaiton.complete(null);
break;
default:
unexpectedJobStatusNotification.complete(newJobStatus);
}
})
.setDeclarativeSlotPool(declarativeSlotPool)
.build();
final SubmissionBufferingTaskManagerGateway taskManagerGateway =
new SubmissionBufferingTaskManagerGateway(1 + PARALLELISM);
singleThreadMainThreadExecutor.execute(
() -> {
scheduler.startScheduling();
offerSlots(
declarativeSlotPool,
createSlotOffersForResourceRequirements(
ResourceCounter.withResource(ResourceProfile.UNKNOWN, 1)),
taskManagerGateway);
});
final TaskDeploymentDescriptor submittedTask = taskManagerGateway.submittedTasks.take();
singleThreadMainThreadExecutor.execute(
() ->
scheduler.updateTaskExecutionState(
new TaskExecutionState(
submittedTask.getExecutionAttemptId(),
ExecutionState.FINISHED)));
jobRunningNotification.get();
jobFinishedNotificaiton.get();
assertThat(unexpectedJobStatusNotification.getNow(null), is(nullValue()));
}

Line under review: final CompletableFuture<Void> jobFinishedNotificaiton = new CompletableFuture<>();

Code after addressing the review:
public void testJobStatusListenerNotifiedOfJobStatusChanges() throws Exception {
final JobGraph jobGraph = createJobGraph();
final DefaultDeclarativeSlotPool declarativeSlotPool =
createDeclarativeSlotPool(jobGraph.getJobID());
final Configuration configuration = new Configuration();
configuration.set(JobManagerOptions.RESOURCE_WAIT_TIMEOUT, Duration.ofMillis(1L));
final CompletableFuture<Void> jobRunningNotification = new CompletableFuture<>();
final CompletableFuture<Void> jobFinishedNotification = new CompletableFuture<>();
final CompletableFuture<JobStatus> unexpectedJobStatusNotification =
new CompletableFuture<>();
final AdaptiveScheduler scheduler =
new AdaptiveSchedulerBuilder(jobGraph, singleThreadMainThreadExecutor)
.setJobMasterConfiguration(configuration)
.setJobStatusListener(
(jobId, newJobStatus, timestamp) -> {
switch (newJobStatus) {
case RUNNING:
jobRunningNotification.complete(null);
break;
case FINISHED:
jobFinishedNotification.complete(null);
break;
default:
unexpectedJobStatusNotification.complete(newJobStatus);
}
})
.setDeclarativeSlotPool(declarativeSlotPool)
.build();
final SubmissionBufferingTaskManagerGateway taskManagerGateway =
new SubmissionBufferingTaskManagerGateway(1 + PARALLELISM);
singleThreadMainThreadExecutor.execute(
() -> {
scheduler.startScheduling();
offerSlots(
declarativeSlotPool,
createSlotOffersForResourceRequirements(
ResourceCounter.withResource(ResourceProfile.UNKNOWN, 1)),
taskManagerGateway);
});
final TaskDeploymentDescriptor submittedTask = taskManagerGateway.submittedTasks.take();
singleThreadMainThreadExecutor.execute(
() ->
scheduler.updateTaskExecutionState(
new TaskExecutionState(
submittedTask.getExecutionAttemptId(),
ExecutionState.FINISHED)));
jobRunningNotification.get();
jobFinishedNotification.get();
assertThat(unexpectedJobStatusNotification.isDone(), is(false));
}