use of com.thoughtworks.go.presentation.pipelinehistory.PipelineModel in project gocd by gocd.
the class PipelineHistoryMother method pipelineWithLatestRevisionAndMaterialRevision.
public static PipelineModel pipelineWithLatestRevisionAndMaterialRevision(MaterialRevisions latest, MaterialRevisions revision) {
PipelineModel pipelineModel = pipelineWithLatestRevision(latest);
pipelineModel.getLatestPipelineInstance().setMaterialRevisionsOnBuildCause(revision);
return pipelineModel;
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineModel in project gocd by gocd.
the class PipelineHistoryServiceIntegrationTest method shouldGetLatestPipelineInstanceWithPreviousStateFromAllPipelineGroups.
@Test
public void shouldGetLatestPipelineInstanceWithPreviousStateFromAllPipelineGroups() throws Exception {
configHelper.setViewPermissionForGroup("group1", "jez");
dbHelper.updateNaturalOrder(pipelineOne.createdPipelineWithAllStagesPassed().getId(), 1.0);
dbHelper.updateNaturalOrder(pipelineTwo.createdPipelineWithAllStagesPassed().getId(), 1.0);
dbHelper.updateNaturalOrder(pipelineTwo.createPipelineWithFirstStagePassedAndSecondStageRunning().getId(), 2.0);
Pipeline toRerun = pipelineTwo.createPipelineWithFirstStagePassedAndSecondStageHasNotStarted();
pipelineTwo.createPipelineWithFirstStagePassedAndSecondStageHasNotStarted();
dbHelper.updateNaturalOrder(toRerun.getId(), 3);
dbHelper.scheduleStage(toRerun, pipelineTwo.devStage());
pipelineRepository.updatePipelineTimeline(pipelineTimeline, new ArrayList<>());
List<PipelineGroupModel> groupModels = pipelineHistoryService.allActivePipelineInstances(new Username(new CaseInsensitiveString("jez")), PipelineSelections.ALL);
assertThat(groupModels.size(), is(2));
List<PipelineModel> pipelineOneModels = groupModels.get(1).getPipelineModels();
assertThat(pipelineOneModels.size(), is(1));
PipelineInstanceModels pipelineOneInstances = pipelineOneModels.get(0).getActivePipelineInstances();
assertThat(pipelineOneInstances.size(), is(1));
PipelineInstanceModel pipelineOne = pipelineOneInstances.get(0);
assertThat(pipelineOne.getCounter(), is(1));
List<PipelineModel> pipelineTwoModels = groupModels.get(0).getPipelineModels();
assertThat(pipelineTwoModels.size(), is(1));
PipelineInstanceModels pipelineTwoInstances = pipelineTwoModels.get(0).getActivePipelineInstances();
assertThat(pipelineTwoInstances.size(), is(3));
PipelineInstanceModel pipelineTwoJustScheduled = pipelineTwoInstances.get(0);
assertThat(pipelineTwoJustScheduled.getCounter(), is(4));
assertThat(pipelineTwoJustScheduled.getStageHistory().size(), is(2));
StageInstanceModel activeStage = pipelineTwoJustScheduled.activeStage();
assertThat(activeStage, is(nullValue()));
PipelineInstanceModel pipelineTwoPostFirstStage = pipelineTwoInstances.get(1);
assertThat(pipelineTwoPostFirstStage.getCounter(), is(3));
assertThat(pipelineTwoPostFirstStage.getStageHistory().size(), is(2));
activeStage = pipelineTwoPostFirstStage.activeStage();
assertThat(activeStage.getName(), is("dev"));
assertThat(activeStage.hasPreviousStage(), is(true));
assertThat(activeStage.getPreviousStage().getResult(), is(StageResult.Passed));
PipelineInstanceModel pipelineTwoWithSecondStageRunning = pipelineTwoInstances.get(2);
assertThat(pipelineTwoWithSecondStageRunning.getCounter(), is(2));
assertThat(pipelineTwoWithSecondStageRunning.getStageHistory().size(), is(2));
activeStage = pipelineTwoWithSecondStageRunning.activeStage();
assertThat(activeStage.getName(), is("ft"));
assertThat(activeStage.hasPreviousStage(), is(true));
assertThat(activeStage.getPreviousStage().getResult(), is(StageResult.Passed));
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineModel in project gocd by gocd.
the class PipelineHistoryServiceIntegrationTest method shouldReturnActiveInstanceOfAPipeline.
@Test
public void shouldReturnActiveInstanceOfAPipeline() throws Exception {
pipelineOne.createdPipelineWithAllStagesPassed();
configHelper.setViewPermissionForGroup("group1", "jez");
String pipelineName = pipelineOne.pipelineName;
List<PipelineGroupModel> groupModels = pipelineHistoryService.getActivePipelineInstance(new Username(new CaseInsensitiveString("jez")), pipelineName.toUpperCase());
assertThat(groupModels.size(), is(1));
List<PipelineModel> pipelineOneModels = groupModels.get(0).getPipelineModels();
assertThat(pipelineOneModels.size(), is(1));
assertThat(pipelineOneModels.get(0).getActivePipelineInstances().get(0).getName(), is(pipelineName));
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineModel in project gocd by gocd.
the class PipelineHistoryServiceIntegrationTest method shouldRememberOldStagesWhenConfigFileChanges.
@Test
public void shouldRememberOldStagesWhenConfigFileChanges() throws Exception {
configHelper.removePipeline(pipelineTwo.pipelineName);
Pipeline toRerun = pipelineOne.createdPipelineWithAllStagesPassed();
configHelper.addStageToPipeline(pipelineOne.pipelineName, "brand_new_stage", 1, "unit");
pipelineOne.createdPipelineWithAllStagesPassed();
dbHelper.scheduleStage(toRerun, pipelineOne.devStage());
configHelper.setViewPermissionForGroup("group1", "jez");
List<PipelineGroupModel> groupModels = pipelineHistoryService.allActivePipelineInstances(new Username(new CaseInsensitiveString("jez")), PipelineSelections.ALL);
assertThat(groupModels.size(), is(1));
List<PipelineModel> pipelineOneModels = groupModels.get(0).getPipelineModels();
assertThat(pipelineOneModels.size(), is(1));
PipelineInstanceModels pipelineTwoInstances = pipelineOneModels.get(0).getActivePipelineInstances();
assertThat(pipelineTwoInstances.size(), is(2));
assertThat(pipelineTwoInstances.get(0).getCounter(), is(2));
assertThat(pipelineTwoInstances.get(0).getStageHistory().size(), is(4));
assertThat(pipelineTwoInstances.get(1).getCounter(), is(1));
assertThat(pipelineTwoInstances.get(1).getStageHistory().size(), is(3));
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineModel 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())));
}
Aggregations