public Set<Long> findCmdIds(List<Status> statusList) throws JobDoesNotExistException {
    Set<Long> set = new HashSet<>();
    for (Map.Entry<Long, CmdInfo> x : mInfoMap.entrySet()) {
      if (statusList.isEmpty()
              || statusList.contains(getCmdStatus(
                      x.getValue().getJobControlId()))) {
        Long key = x.getKey();
        set.add(key);
      }
    }
    return set;
  }
@Test
  public void testFindCmdIdsForMultipleCmds() throws Exception {
    long cancelId = generateMigrateCommandForStatus(Status.CANCELED);
    long runningIdA = generateMigrateCommandForStatus(Status.RUNNING);
    long runningIdB = generateMigrateCommandForStatus(Status.RUNNING);
    long failedId = generateMigrateCommandForStatus(Status.FAILED);
    long completedIdA = generateMigrateCommandForStatus(Status.COMPLETED);
    long completedIB = generateMigrateCommandForStatus(Status.COMPLETED);
    long createdId = generateMigrateCommandForStatus(Status.CREATED);

    // test cancel cmd ids.
    mSearchingCriteria.add(Status.CANCELED);
    Set<Long> cancelCmdIds = mCmdJobTracker.findCmdIds(mSearchingCriteria);
    Assert.assertEquals(cancelCmdIds.size(), 1);
    Assert.assertTrue(cancelCmdIds.contains(cancelId));

    // test completed cmd ids.
    mSearchingCriteria.clear();
    mSearchingCriteria.add(Status.COMPLETED);
    Set<Long> completedCmdIds = mCmdJobTracker.findCmdIds(mSearchingCriteria);
    Assert.assertEquals(completedCmdIds.size(), 2);
    Assert.assertTrue(completedCmdIds.contains(completedIdA));
    Assert.assertTrue(completedCmdIds.contains(completedIB));

    // test failed cmd ids.
    mSearchingCriteria.clear();
    mSearchingCriteria.add(Status.FAILED);
    Set<Long> failCmdIds = mCmdJobTracker.findCmdIds(mSearchingCriteria);
    Assert.assertEquals(failCmdIds.size(), 1);
    Assert.assertTrue(failCmdIds.contains(failedId));

    // test running cmd ids.
    mSearchingCriteria.clear();
    mSearchingCriteria.add(Status.RUNNING);
    Set<Long> runningCmdIds = mCmdJobTracker.findCmdIds(mSearchingCriteria);
    Assert.assertEquals(runningCmdIds.size(), 3); // 2 running commands + 1 created command.
    Assert.assertTrue(runningCmdIds.contains(runningIdA));
    Assert.assertTrue(runningCmdIds.contains(runningIdB));
    Assert.assertTrue(runningCmdIds.contains(createdId));

    // test running and completed cmd ids.
    mSearchingCriteria.clear();
    mSearchingCriteria.add(Status.COMPLETED);
    mSearchingCriteria.add(Status.RUNNING);
    Set<Long> ids = mCmdJobTracker.findCmdIds(mSearchingCriteria);
    Assert.assertEquals(ids.size(), 5);
    Assert.assertTrue(ids.contains(completedIdA));
    Assert.assertTrue(ids.contains(completedIB));
    Assert.assertTrue(ids.contains(runningIdA));
    Assert.assertTrue(ids.contains(runningIdB));
    Assert.assertTrue(ids.contains(createdId));
  }