@Test public void shouldReturnNullIfJobHistoryIsBlank() throws Exception { StageInstanceModel stageHistoryItem = new StageInstanceModel(); stageHistoryItem.setBuildHistory(new JobHistory()); assertThat(stageHistoryItem.getScheduledDate(), is(nullValue())); }
@Test public void shouldReturnDateIfJobHistoryIsNotBlank() throws Exception { StageInstanceModel stageHistoryItem = new StageInstanceModel(); JobHistory jobHistory = new JobHistory(); Date date = new Date(1367472329111L); jobHistory.addJob("jobName", JobState.Building, JobResult.Passed, date); stageHistoryItem.setBuildHistory(jobHistory); assertThat(stageHistoryItem.getScheduledDate(), is(date)); } }
public static StageInstanceModels stagePerJob(String baseName, List<JobHistory> histories) { StageInstanceModels stageInstanceModels = new StageInstanceModels(); for (int i = 0; i < histories.size(); i++) { String stageName = baseName + "-" + i; StageInstanceModel stage = new StageInstanceModel(stageName, "1", StageResult.Passed, new StageIdentifier("pipeline", 1, "1", stageName, "1")); stage.setBuildHistory(histories.get(i)); stageInstanceModels.add(stage); stageInstanceModels.latestStage().setApprovedBy("cruise"); } return stageInstanceModels; }
public static StageInstanceModel toStageInstanceModel(Stage stage) { StageInstanceModel stageInstanceModel = new StageInstanceModel(stage.getName(), String.valueOf(stage.getCounter()), stage.getResult(), stage.getIdentifier()); stageInstanceModel.setApprovalType(stage.getApprovalType()); stageInstanceModel.setApprovedBy(stage.getApprovedBy()); stageInstanceModel.setRerunOfCounter(stage.getRerunOfCounter()); JobHistory jobHistory = new JobHistory(); for (JobInstance jobInstance : stage.getJobInstances()) { jobHistory.addJob(jobInstance.getName(), jobInstance.getState(), jobInstance.getResult(), jobInstance.getScheduledDate()); } stageInstanceModel.setBuildHistory(jobHistory); return stageInstanceModel; }