JobInfoConverter { public static JobStepStatusEnum parseToJobStepStatus(ExecutableState state) { switch (state) { case READY: return JobStepStatusEnum.PENDING; case RUNNING: return JobStepStatusEnum.RUNNING; case ERROR: return JobStepStatusEnum.ERROR; case DISCARDED: return JobStepStatusEnum.DISCARDED; case SUCCEED: return JobStepStatusEnum.FINISHED; case STOPPED: return JobStepStatusEnum.STOPPED; default: throw new RuntimeException("invalid state:" + state); } }  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 testParseToJobStepStatusReturnsJobStepStatusStopped() { ExecutableState executableState = ExecutableState.STOPPED; JobStepStatusEnum jobStepStatusEnum = JobInfoConverter.parseToJobStepStatus(executableState); assertFalse(jobStepStatusEnum.isComplete()); assertFalse(jobStepStatusEnum.isRunable()); assertEquals(128, jobStepStatusEnum.getCode()); assertEquals(JobStepStatusEnum.STOPPED, jobStepStatusEnum); }
@Test public void testParseToJobStepStatusReturnsJobStepStatusFinished() { ExecutableState executableState = ExecutableState.SUCCEED; JobStepStatusEnum jobStepStatusEnum = JobInfoConverter.parseToJobStepStatus(executableState); assertTrue(jobStepStatusEnum.isComplete()); assertEquals(4, jobStepStatusEnum.getCode()); assertFalse(jobStepStatusEnum.isRunable()); assertEquals(JobStepStatusEnum.FINISHED, jobStepStatusEnum); }
@Test public void testParseToJobStepStatusReturnsJobStepStatusDiscarded() { ExecutableState executableState = ExecutableState.DISCARDED; JobStepStatusEnum jobStepStatusEnum = JobInfoConverter.parseToJobStepStatus(executableState); assertTrue(jobStepStatusEnum.isComplete()); assertFalse(jobStepStatusEnum.isRunable()); assertEquals(16, jobStepStatusEnum.getCode()); assertEquals(JobStepStatusEnum.DISCARDED, jobStepStatusEnum); }
@Test public void testParseToJobStepStatusReturnsJobStepStatusRunning() { ExecutableState executableState = ExecutableState.RUNNING; JobStepStatusEnum jobStepStatusEnum = JobInfoConverter.parseToJobStepStatus(executableState); assertEquals(2, jobStepStatusEnum.getCode()); assertFalse(jobStepStatusEnum.isComplete()); assertFalse(jobStepStatusEnum.isRunable()); assertEquals(JobStepStatusEnum.RUNNING, jobStepStatusEnum); }
@Test public void testParseToJobStepStatusReturnsJobStepStatusError() { ExecutableState executableState = ExecutableState.ERROR; JobStepStatusEnum jobStepStatusEnum = JobInfoConverter.parseToJobStepStatus(executableState); assertTrue(jobStepStatusEnum.isRunable()); assertTrue(jobStepStatusEnum.isComplete()); assertEquals(8, jobStepStatusEnum.getCode()); assertEquals(JobStepStatusEnum.ERROR, jobStepStatusEnum); }
@Test public void testParseToJobStepStatusReturnsJobStepStatusPending() { ExecutableState executableState = ExecutableState.READY; JobStepStatusEnum jobStepStatusEnum = JobInfoConverter.parseToJobStepStatus(executableState); assertTrue(jobStepStatusEnum.isRunable()); assertEquals(1, jobStepStatusEnum.getCode()); assertEquals(JobStepStatusEnum.PENDING, jobStepStatusEnum); }