use of com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel in project gocd by gocd.
the class PipelineHistoryMother method stageHistory.
public static StageInstanceModels stageHistory(PipelineConfig pipelineConfig, Date modificationDate) {
StageInstanceModels history = new StageInstanceModels();
for (StageConfig stageConfig : pipelineConfig) {
StageInstanceModel item = new StageInstanceModel(CaseInsensitiveString.str(stageConfig.name()), "1", buildHistory(stageConfig, modificationDate));
item.setCounter("1");
item.setApprovalType(new InstanceFactory().createStageInstance(stageConfig, new DefaultSchedulingContext("anyone"), md5, new TimeProvider()).getApprovalType());
if (stageConfig.requiresApproval()) {
item.setApprovedBy(APPROVED_BY);
} else {
item.setApprovedBy(GoConstants.DEFAULT_APPROVED_BY);
}
history.add(item);
}
return history;
}
use of com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel in project gocd by gocd.
the class PipelineHistoryItemMother method custom.
public static PipelineInstanceModel custom(String... stageNames) {
PipelineInstanceModel pipelineInstanceModel = PipelineInstanceModel.createEmptyModel();
pipelineInstanceModel.setStageHistory(new StageInstanceModels());
for (String stageName : stageNames) {
StageInstanceModel stageHistoryItem = new StageInstanceModel();
stageHistoryItem.setName(stageName);
pipelineInstanceModel.getStageHistory().add(stageHistoryItem);
}
return pipelineInstanceModel;
}
use of com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel in project gocd by gocd.
the class StageMother method toStageInstanceModel.
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;
}
use of com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel in project gocd by gocd.
the class PipelineHistoryJsonPresentationModel method stageHistoryAsJson.
private List stageHistoryAsJson(PipelineInstanceModel pipelineInstanceModel, StageInstanceModels stageHistory) {
List json = new ArrayList();
for (StageInstanceModel stageHistoryItem : stageHistory) {
Map<String, Object> jsonMap = new LinkedHashMap<>();
jsonMap.put("stageName", stageHistoryItem.getName());
jsonMap.put("stageId", stageHistoryItem.getId());
jsonMap.put("stageStatus", stageHistoryItem.getState().toString());
StageIdentifier stageIdentifier = new StageIdentifier(pipelineInstanceModel.getPipelineIdentifier(), stageHistoryItem.getName(), stageHistoryItem.getCounter());
jsonMap.put("stageLocator", encodeInUtf8(stageIdentifier.stageLocator()));
jsonMap.put("getCanRun", Boolean.toString(stageHistoryItem.getCanRun()));
jsonMap.put("getCanCancel", Boolean.toString(stageHistoryItem.getCanCancel()));
jsonMap.put("scheduled", Boolean.toString(stageHistoryItem.isScheduled()));
jsonMap.put("stageCounter", stageHistoryItem.getCounter());
handleApproval(stageHistoryItem, jsonMap);
json.add(jsonMap);
}
return json;
}
use of com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel in project gocd by gocd.
the class PipelineHistoryServiceIntegrationTest method shouldLoadPipelineHistory.
@Test
public void shouldLoadPipelineHistory() throws Exception {
pipelineOne.createdPipelineWithAllStagesPassed();
PipelineInstanceModels history = pipelineHistoryService.load(pipelineOne.pipelineName, Pagination.pageStartingAt(0, 1, 10), "jez", true);
assertThat(history.size(), is(1));
StageInstanceModels stageHistory = history.first().getStageHistory();
assertThat(stageHistory.size(), is(3));
for (StageInstanceModel stageHistoryItem : stageHistory) {
assertThat(stageHistoryItem.isScheduled(), is(true));
assertThat(stageHistoryItem.getCanRun(), is(true));
}
}
Aggregations