public CmdStatusBlock getCmdStatusBlock(long jobControlId)
          throws JobDoesNotExistException {
    if (!mInfoMap.containsKey(jobControlId)) {
      throw new JobDoesNotExistException(
              ExceptionMessage.JOB_DEFINITION_DOES_NOT_EXIST.getMessage(jobControlId));
    }

    CmdInfo cmdInfo = mInfoMap.get(jobControlId);

    if (cmdInfo.getCmdRunAttempt().isEmpty()) { // If no attempts are created,
      // that means the files are loaded already, set status to complete
      return new CmdStatusBlock(cmdInfo.getJobControlId(), Collections.EMPTY_LIST,
              cmdInfo.getOperationType());
    }

    List<SimpleJobStatusBlock> blockList = cmdInfo.getCmdRunAttempt().stream()
            .map(attempt -> new SimpleJobStatusBlock(attempt.getJobId(),
                    attempt.checkJobStatus(),
                    attempt.getFilePath(),
                    String.join(DELIMITER, attempt.getFailedFiles())))
            .collect(Collectors.toList());
    return new CmdStatusBlock(cmdInfo.getJobControlId(), blockList, cmdInfo.getOperationType());
  }
@Test
  public void testGetCmdStatusBlock() throws Exception {
    CmdInfo cmdInfo = new CmdInfo(mMigrateJobId, OperationType.DIST_CP,
            JobSource.CLI, System.currentTimeMillis(), Lists.newArrayList());
    CmdStatusBlock expectedStatusBlock = new CmdStatusBlock(mMigrateJobId, OperationType.DIST_CP);

    int completedCount = REPEATED_ATTEMPT_COUNT;
    int runningCount = REPEATED_ATTEMPT_COUNT;
    int offset = completedCount;
    addJobStatusBlockWithStatus(Status.COMPLETED, cmdInfo, completedCount,
            expectedStatusBlock, 0);
    addJobStatusBlockWithStatus(Status.RUNNING, cmdInfo, runningCount,
            expectedStatusBlock, offset);

    prepareDistCpTest(cmdInfo, mMigrate, mMigrateJobId);

    mCmdJobTracker.run(mMigrate, mMigrateJobId);
    CmdStatusBlock actualStatusBlock = mCmdJobTracker.getCmdStatusBlock(mMigrateJobId);
    Assert.assertEquals(actualStatusBlock.getJobControlId(), expectedStatusBlock.getJobControlId());
    Assert.assertEquals(actualStatusBlock.toProto(), expectedStatusBlock.toProto());
  }