use of com.thoughtworks.go.presentation.pipelinehistory.NullStageHistoryItem in project gocd by gocd.
the class ViewCacheKeyTest method shouldGenerateKeyForPipelineModelViewFragment.
@Test
public void shouldGenerateKeyForPipelineModelViewFragment() {
PipelineModel model = new PipelineModel("pipelineName", true, true, PipelinePauseInfo.notPaused()).updateAdministrability(true);
StageInstanceModels stages = new StageInstanceModels();
stages.add(stageInstance("stageName", 13, JobState.Building, JobResult.Unknown));
stages.add(new NullStageHistoryItem("stage2", true));
PipelineInstanceModel pipelineInstance = PipelineInstanceModel.createPipeline("pipelineName", 10, "label-10", BuildCause.createExternal(), stages);
pipelineInstance.setId(12);
model.addPipelineInstance(pipelineInstance);
StageInstanceModels stages2 = new StageInstanceModels();
stages2.add(stageInstance("stageName", 7, JobState.Completed, JobResult.Passed));
stages2.add(stageInstance("stage2", 10, JobState.Assigned, JobResult.Unknown));
PipelineInstanceModel pipelineInstance2 = PipelineInstanceModel.createPipeline("pipelineName", 7, "label-7", BuildCause.createExternal(), stages2);
pipelineInstance2.setId(14);
model.addPipelineInstance(pipelineInstance2);
assertThat(viewCacheKey.forPipelineModelBox(model), is("view_dashboardPipelineFragment_pipelineName{false|false|false}[12|stageName|13|Building|stage2|0|Unknown|][14|stageName|7|Passed|stage2|10|Building|]true|true|false|||true"));
}
use of com.thoughtworks.go.presentation.pipelinehistory.NullStageHistoryItem in project gocd by gocd.
the class ViewCacheKeyTest method shouldGenerateKeyForPipelineModelViewFragmentWithoutSpecialCharactersInPauseCause.
@Test
public void shouldGenerateKeyForPipelineModelViewFragmentWithoutSpecialCharactersInPauseCause() {
PipelinePauseInfo pauseInfo = new PipelinePauseInfo(true, "pause& @Cause #with $special %char &*(){';/.,<>?", "admin");
PipelineModel model = new PipelineModel("pipelineName", true, true, pauseInfo).updateAdministrability(true);
StageInstanceModels stages = new StageInstanceModels();
stages.add(stageInstance("stageName", 13, JobState.Building, JobResult.Unknown));
stages.add(new NullStageHistoryItem("stage2", true));
PipelineInstanceModel pipelineInstance = PipelineInstanceModel.createPipeline("pipelineName", 10, "label-10", BuildCause.createExternal(), stages);
pipelineInstance.setId(12);
model.addPipelineInstance(pipelineInstance);
StageInstanceModels stages2 = new StageInstanceModels();
stages2.add(stageInstance("stageName", 7, JobState.Completed, JobResult.Passed));
stages2.add(stageInstance("stage2", 10, JobState.Assigned, JobResult.Unknown));
PipelineInstanceModel pipelineInstance2 = PipelineInstanceModel.createPipeline("pipelineName", 7, "label-7", BuildCause.createExternal(), stages2);
pipelineInstance2.setId(14);
model.addPipelineInstance(pipelineInstance2);
assertThat(viewCacheKey.forPipelineModelBox(model), is("view_dashboardPipelineFragment_pipelineName{false|false|false}[12|stageName|13|Building|stage2|0|Unknown|][14|stageName|7|Passed|stage2|10|Building|]true|true|true|pauseCausewithspecialchar|admin|true"));
}
use of com.thoughtworks.go.presentation.pipelinehistory.NullStageHistoryItem in project gocd by gocd.
the class PipelineXmlViewModel method toXml.
@Override
public Document toXml(XmlWriterContext writerContext) {
DOMElement root = new DOMElement("pipeline");
root.addAttribute("name", pipeline.getName()).addAttribute("counter", String.valueOf(pipeline.getCounter())).addAttribute("label", pipeline.getLabel());
Document document = new DOMDocument(root);
String baseUrl = writerContext.getBaseUrl();
root.addElement("link").addAttribute("rel", "self").addAttribute("href", httpUrl(baseUrl));
root.addElement("id").addCDATA(pipeline.getPipelineIdentifier().asURN());
PipelineTimelineEntry pipelineAfter = pipeline.getPipelineAfter();
if (pipelineAfter != null) {
addTimelineLink(root, baseUrl, "insertedBefore", pipelineAfter);
}
PipelineTimelineEntry pipelineBefore = pipeline.getPipelineBefore();
if (pipelineBefore != null) {
addTimelineLink(root, baseUrl, "insertedAfter", pipelineBefore);
}
root.addElement("scheduleTime").addText(DateUtils.formatISO8601(pipeline.getScheduledDate()));
Element materials = root.addElement("materials");
for (MaterialRevision materialRevision : pipeline.getCurrentRevisions()) {
populateXml(materials, materialRevision, writerContext);
}
Element stages = root.addElement("stages");
for (StageInstanceModel stage : pipeline.getStageHistory()) {
if (!(stage instanceof NullStageHistoryItem)) {
stages.addElement("stage").addAttribute("href", StageXmlViewModel.httpUrlFor(writerContext.getBaseUrl(), stage.getId()));
}
}
root.addElement("approvedBy").addCDATA(pipeline.getApprovedBy());
return document;
}
use of com.thoughtworks.go.presentation.pipelinehistory.NullStageHistoryItem in project gocd by gocd.
the class PipelineXmlRepresenter method toXml.
@Override
public Document toXml(XmlWriterContext ctx) {
String self = ctx.pipelineXmlLink(instance.getName(), instance.getCounter());
DocumentBuilder builder = DocumentBuilder.withRoot("pipeline").attr("name", instance.getName()).attr("counter", instance.getCounter()).link(self, "self").cdataNode("id", instance.getPipelineIdentifier().asURN()).textNode("scheduleTime", instance.getScheduledDate());
PipelineTimelineEntry pipelineAfter = instance.getPipelineAfter();
if (pipelineAfter != null) {
builder.link(ctx.pipelineXmlLink(pipelineAfter.getPipelineName(), pipelineAfter.getId()), "insertedBefore");
}
PipelineTimelineEntry pipelineBefore = instance.getPipelineBefore();
if (pipelineBefore != null) {
builder.link(ctx.pipelineXmlLink(pipelineBefore.getPipelineName(), pipelineBefore.getId()), "insertedAfter");
}
builder.node("materials", materialBuilder -> {
instance.getLatestRevisions().forEach(revision -> {
this.populateMaterials(materialBuilder, revision, ctx);
});
});
builder.node("stages", stagesBuilder -> {
instance.getStageHistory().stream().filter(stage -> !(stage instanceof NullStageHistoryItem)).forEach(stage -> stagesBuilder.node("stage", stageBuilder -> stageBuilder.attr("href", ctx.stageXmlLink(stage.getIdentifier()))));
});
builder.cdataNode("approvedBy", instance.getApprovedBy());
return builder.build();
}
Aggregations