@Test
public void testGetApplicationIdsFromLog() throws Exception {

  testSetUpForRunningFlows();
  this.runningExecutions.get().put(1, new Pair<>(this.ref1, this.flow1));
  // Verify that application ids are obtained successfully from the log data.
  final String logData1 = "Submitted application_12345_6789.";
  when(this.apiGateway.callWithReference(any(), eq(ConnectorParams.LOG_ACTION), any()))
      .then(getLogChunksMock(logData1));
  Set<String> appIds = this.manager.getApplicationIds(this.flow1, "job1", 0);
  Assert.assertEquals(1, appIds.size());
  Assert.assertEquals("12345_6789", appIds.iterator().next());
  final String logData2 = " Submitted application_12345_6789.\n AttemptID: attempt_12345_6789. "
      + "Accepted application_98765_4321.";
  when(this.apiGateway.callWithReference(any(), eq(ConnectorParams.LOG_ACTION), any()))
      .then(getLogChunksMock(logData2));
  appIds = this.manager.getApplicationIds(this.flow1, "job1", 0);
  Assert.assertEquals(2, appIds.size());
  final Iterator iterator = appIds.iterator();
  Assert.assertEquals("12345_6789", iterator.next());
  Assert.assertEquals("98765_4321", iterator.next());
  // Verify that an empty list is returned when log data length is 0 (no new data available).
  when(this.apiGateway.callWithReference(any(), eq(ConnectorParams.LOG_ACTION), any()))
      .then(getLogChunksMock(""));
  Assert.assertEquals(0, this.manager.getApplicationIds(this.flow1, "job1", 0).size());
}