JobInfoConverter { public static JobInstance.JobStep parseToJobStep(AbstractExecutable task, int i, Output stepOutput) { JobInstance.JobStep result = new JobInstance.JobStep(); result.setId(task.getId()); result.setName(task.getName()); result.setSequenceID(i); if (stepOutput == null) { logger.warn("Cannot found output for task: id={}", task.getId()); return result; } result.setStatus(parseToJobStepStatus(stepOutput.getState())); for (Map.Entry<String, String> entry : stepOutput.getExtra().entrySet()) { if (entry.getKey() != null && entry.getValue() != null) { result.putInfo(entry.getKey(), entry.getValue()); } } result.setExecStartTime(AbstractExecutable.getStartTime(stepOutput)); result.setExecEndTime(AbstractExecutable.getEndTime(stepOutput)); if (task instanceof ShellExecutable) { result.setExecCmd(((ShellExecutable) task).getCmd()); } if (task instanceof MapReduceExecutable) { result.setExecCmd(((MapReduceExecutable) task).getMapReduceParams()); result.setExecWaitTime( AbstractExecutable.getExtraInfoAsLong(stepOutput, MapReduceExecutable.MAP_REDUCE_WAIT_TIME, 0L) / 1000); } if (task instanceof HadoopShellExecutable) { result.setExecCmd(((HadoopShellExecutable) task).getJobParams()); } return result; }  static JobInstance parseToJobInstanceQuietly(CubingJob job, Map<String, Output> outputs); static JobInstance parseToJobInstanceQuietly(CheckpointExecutable job, Map<String, Output> outputs); static JobInstance parseToJobInstance(CubingJob job, Map<String, Output> outputs); static JobInstance parseToJobInstance(CheckpointExecutable job, Map<String, Output> outputs); static JobInstance.JobStep parseToJobStep(AbstractExecutable task, int i, Output stepOutput); static JobStatusEnum parseToJobStatus(ExecutableState state); static JobStepStatusEnum parseToJobStepStatus(ExecutableState state); static JobSearchResult parseToJobSearchResult(DefaultChainedExecutable job, Map<String, ExecutableOutputPO> outputs);  }
@Test public void testParseToJobStep() { TestJob task = new TestJob(); JobInstance.JobStep step = JobInfoConverter.parseToJobStep(task, 0, null); assertEquals(step.getStatus(), JobStepStatusEnum.PENDING); step = JobInfoConverter.parseToJobStep(task, 0, new TestOutput()); assertEquals(step.getStatus(), JobStepStatusEnum.FINISHED); }