use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.
the class PipelineSqlMapDaoIntegrationTest method shouldLoadStageIdentifier.
@Test
public void shouldLoadStageIdentifier() throws SQLException {
Stage stage = new Stage("dev", new JobInstances(new JobInstance("unit")), "anonymous", "manual", new TimeProvider());
stage.building();
Pipeline pipeline = new Pipeline("Test", BuildCause.createManualForced(), stage);
savePipeline(pipeline);
PipelineInstanceModel loaded = pipelineDao.loadHistory("Test").get(0);
StageInstanceModel historicalStage = loaded.getStageHistory().get(0);
assertThat(historicalStage.getIdentifier(), is(new StageIdentifier("Test", loaded.getCounter(), loaded.getLabel(), "dev", historicalStage.getCounter())));
PipelineInstanceModel loadedById = pipelineDao.loadHistory(pipeline.getId());
StageInstanceModel historicalStageModelById = loadedById.getStageHistory().get(0);
assertThat(historicalStageModelById.getIdentifier(), is(new StageIdentifier("Test", loadedById.getCounter(), loadedById.getLabel(), "dev", historicalStage.getCounter())));
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.
the class PipelineSqlMapDaoIntegrationTest method shouldLoadStageResult.
@Test
public void shouldLoadStageResult() throws SQLException {
Stage stage = new Stage("dev", new JobInstances(new JobInstance("unit")), "anonymous", "manual", new TimeProvider());
stage.building();
Pipeline pipeline = new Pipeline("Test", BuildCause.createManualForced(), stage);
savePipeline(pipeline);
PipelineInstanceModel loaded = pipelineDao.loadHistory("Test").get(0);
assertThat(loaded.getStageHistory().get(0).getResult(), is(StageResult.Unknown));
PipelineInstanceModel loadedById = pipelineDao.loadHistory(pipeline.getId());
assertThat(loadedById.getStageHistory().get(0).getResult(), is(StageResult.Unknown));
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel 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.PipelineInstanceModel in project gocd by gocd.
the class ViewCacheKeyTest method shouldGenerateKeyForBuildCause.
@Test
public void shouldGenerateKeyForBuildCause() {
PipelineModel model = new PipelineModel("pipelineName", true, true, PipelinePauseInfo.notPaused());
PipelineInstanceModel pipelineInstance = PipelineInstanceModel.createPipeline("pipelineName", 10, "label-10", BuildCause.createExternal(), new StageInstanceModels());
pipelineInstance.setId(12);
TrackingTool trackingTool = new TrackingTool("link", "regex");
pipelineInstance.setTrackingTool(trackingTool);
model.addPipelineInstance(pipelineInstance);
PipelineInstanceModel pipelineInstance2 = PipelineInstanceModel.createPipeline("pipelineName", 7, "label-7", BuildCause.createExternal(), new StageInstanceModels());
pipelineInstance2.setId(14);
MingleConfig mingleConfig = new MingleConfig("mingle", "project", "mql");
pipelineInstance2.setMingleConfig(mingleConfig);
model.addPipelineInstance(pipelineInstance2);
assertThat(viewCacheKey.forPipelineModelBuildCauses(model), is(String.format("view_buildCausesForPipelineModel_pipelineName[12|%s|%s][14|%s|%s]", trackingTool.hashCode(), -1, -1, mingleConfig.hashCode())));
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel 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"));
}
Aggregations