Source:
<code>public void testGetLastScheduledTaskExecInfo() throws Exception { String queueName = TestHelper.getTestMethodName(); <START> List<Long> startTimesWithStuckTasks = setupTasks(queueName, 5, 99999999, 2); <END> _driver.pollForJobState(queueName, queueName + "_job_0", TaskState.IN_PROGRESS); Assert.assertEquals(startTimesWithStuckTasks.get(0).longValue(), INVALID_TIMESTAMP); Assert.assertEquals(startTimesWithStuckTasks.get(1).longValue(), INVALID_TIMESTAMP); boolean hasQueueReachedDesiredState = TestHelper.verify(() -> { Long lastScheduledTaskTs = _driver.getLastScheduledTaskTimestamp(queueName); TaskExecutionInfo execInfo = _driver.getLastScheduledTaskExecutionInfo(queueName); return (execInfo.getJobName().equals(queueName + "_job_0") && execInfo.getTaskPartitionState() == TaskPartitionState.RUNNING && execInfo.getStartTimeStamp().equals(lastScheduledTaskTs) && startTimesWithStuckTasks.get(4).equals(lastScheduledTaskTs)); }, 30 * 1000); Assert.assertTrue(hasQueueReachedDesiredState); _driver.stop(queueName); _driver.deleteAndWaitForCompletion(queueName, 30 * 1000); List<Long> startTimesFastTasks = setupTasks(queueName, 4, 10, 4); _driver.pollForJobState(queueName, queueName + "_job_0", TaskState.IN_PROGRESS); hasQueueReachedDesiredState = TestHelper.verify(() -> { Long lastScheduledTaskTs = _driver.getLastScheduledTaskTimestamp(queueName); TaskExecutionInfo execInfo = _driver.getLastScheduledTaskExecutionInfo(queueName); return (execInfo.getJobName().equals(queueName + "_job_0") && execInfo.getTaskPartitionState() == TaskPartitionState.COMPLETED && execInfo.getStartTimeStamp().equals(lastScheduledTaskTs) && startTimesFastTasks.get(startTimesFastTasks.size() - 1).equals(lastScheduledTaskTs)); }, 30 * 1000); Assert.assertTrue(hasQueueReachedDesiredState); }</code><technical_language>Nit: 99999999 a constant name more appropriate</technical_language>

Target:
public void testGetLastScheduledTaskExecInfo() throws Exception { String queueName = TestHelper.getTestMethodName(); List<Long> startTimesWithStuckTasks = setupTasks(queueName, 5, LONG_EXECUTION_TIME, 2); _driver.pollForJobState(queueName, queueName + "_job_0", TaskState.IN_PROGRESS); Assert.assertEquals(startTimesWithStuckTasks.get(0).longValue(), INVALID_TIMESTAMP); Assert.assertEquals(startTimesWithStuckTasks.get(1).longValue(), INVALID_TIMESTAMP); boolean hasQueueReachedDesiredState = TestHelper.verify(() -> { Long lastScheduledTaskTs = _driver.getLastScheduledTaskTimestamp(queueName); TaskExecutionInfo execInfo = _driver.getLastScheduledTaskExecutionInfo(queueName); return (execInfo.getJobName().equals(queueName + "_job_0") && execInfo.getTaskPartitionState() == TaskPartitionState.RUNNING && execInfo.getStartTimeStamp().equals(lastScheduledTaskTs) && startTimesWithStuckTasks.get(4).equals(lastScheduledTaskTs)); }, TestHelper.WAIT_DURATION); Assert.assertTrue(hasQueueReachedDesiredState); _driver.stop(queueName); _driver.deleteAndWaitForCompletion(queueName, DELETE_DELAY); List<Long> startTimesFastTasks = setupTasks(queueName, 4, SHORT_EXECUTION_TIME, 4); _driver.pollForJobState(queueName, queueName + "_job_0", TaskState.IN_PROGRESS, TaskState.COMPLETED); hasQueueReachedDesiredState = TestHelper.verify(() -> { Long lastScheduledTaskTs = _driver.getLastScheduledTaskTimestamp(queueName); TaskExecutionInfo execInfo = _driver.getLastScheduledTaskExecutionInfo(queueName); return (execInfo.getJobName().equals(queueName + "_job_0") && execInfo.getTaskPartitionState() == TaskPartitionState.COMPLETED && execInfo.getStartTimeStamp().equals(lastScheduledTaskTs) && startTimesFastTasks.get(startTimesFastTasks.size() - 1).equals(lastScheduledTaskTs)); }, TestHelper.WAIT_DURATION); Assert.assertTrue(hasQueueReachedDesiredState); }