use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels in project gocd by gocd.
the class PipelineHistoryGroupingUtilTest method shouldCreateTwoGroupsWithOneGroupHasMultiplePipelineHistoryItems.
@Test
public void shouldCreateTwoGroupsWithOneGroupHasMultiplePipelineHistoryItems() throws Exception {
PipelineInstanceModel pipelineHistoryItem1 = PipelineHistoryItemMother.custom("stage1", "stage2");
PipelineInstanceModel pipelineHistoryItem2 = PipelineHistoryItemMother.custom("stage1", "stage2");
PipelineInstanceModel pipelineHistoryItem3 = PipelineHistoryItemMother.custom("stage2", "stage1");
PipelineInstanceModel pipelineHistoryItem4 = PipelineHistoryItemMother.custom("stage1", "stage3");
PipelineInstanceModels history = PipelineInstanceModels.createPipelineInstanceModels(pipelineHistoryItem1, pipelineHistoryItem2, pipelineHistoryItem3, pipelineHistoryItem4);
PipelineHistoryGroups historyGroups = groupingUtil.createGroups(history);
assertThat(historyGroups.size(), is(3));
assertThat(historyGroups.first().hasSameStagesAs(pipelineHistoryItem1), is(true));
assertThat(historyGroups.get(1).hasSameStagesAs(pipelineHistoryItem3), is(true));
assertThat(historyGroups.get(2).hasSameStagesAs(pipelineHistoryItem4), is(true));
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels in project gocd by gocd.
the class PipelineSqlMapDaoTest method shouldGetAnListOfPIMsForPipelineWhenActivePipelinesListHasPIMsForRequestedPipeline.
@Test
public void shouldGetAnListOfPIMsForPipelineWhenActivePipelinesListHasPIMsForRequestedPipeline() throws Exception {
String p1 = "pipeline-with-active-instances";
String p2 = "pipeline-with-no-active-instances";
PipelineInstanceModel pimForP1_1 = pimFor(p1, 1);
PipelineInstanceModel pimForP1_2 = pimFor(p1, 2);
when(configFileDao.load()).thenReturn(GoConfigMother.configWithPipelines(p1, p2));
when(sqlMapClientTemplate.queryForList("allActivePipelines")).thenReturn(asList(pimForP1_1, pimForP1_2, pimFor(p2, 1), pimFor(p2, 2)));
when(sqlMapClientTemplate.queryForObject("getPipelineHistoryById", m("id", pimForP1_1.getId()))).thenReturn(pimForP1_1);
when(sqlMapClientTemplate.queryForObject("getPipelineHistoryById", m("id", pimForP1_2.getId()))).thenReturn(pimForP1_2);
PipelineInstanceModels models = pipelineSqlMapDao.loadActivePipelineInstancesFor(p1);
assertThat(models.size(), is(2));
assertThat(pimForP1_1.getName(), is(p1));
assertThat(pimForP1_1.getCounter(), is(1));
assertThat(pimForP1_2.getName(), is(p1));
assertThat(pimForP1_2.getCounter(), is(2));
verify(sqlMapClientTemplate).queryForList("allActivePipelines");
verify(sqlMapClientTemplate).queryForObject("getPipelineHistoryById", m("id", pimForP1_1.getId()));
verify(sqlMapClientTemplate).queryForObject("getPipelineHistoryById", m("id", pimForP1_2.getId()));
verifyNoMoreInteractions(sqlMapClientTemplate);
/* Should not have loaded history for the other pipeline. */
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels in project gocd by gocd.
the class PipelineDependencyGraphOldTest method shouldFilterPIMS.
@Test
public void shouldFilterPIMS() throws Exception {
PipelineDependencyGraphOld graph = new PipelineDependencyGraphOld(pim("upstream"), PipelineInstanceModels.createPipelineInstanceModels(pim("pavan"), pim("raghu")));
PipelineDependencyGraphOld.Filterer filterer = mock(PipelineDependencyGraphOld.Filterer.class);
when(filterer.filterPipeline("raghu")).thenReturn(false);
when(filterer.filterPipeline("pavan")).thenReturn(true);
graph.filterDependencies(filterer);
PipelineInstanceModels models = graph.dependencies();
assertThat(models.size(), is(1));
assertThat(models.get(0).getName(), is("pavan"));
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels in project gocd by gocd.
the class PipelineHistoryMother method pipelineHistory.
public static PipelineInstanceModels pipelineHistory(PipelineConfig pipelineConfig, Date scheduleDate, Date modificationDate, String revision, String committer, String commitMessage, String commiterEmail, String commitedFileName, String dirModified, String label) {
PipelineInstanceModels history = PipelineInstanceModels.createPipelineInstanceModels();
Modification modification = new Modification(committer, commitMessage, commiterEmail, modificationDate, revision);
modification.createModifiedFile(commitedFileName, dirModified, ModifiedAction.added);
MaterialRevisions revisions = new MaterialRevisions();
Material material = new MaterialConfigConverter().toMaterial(pipelineConfig.materialConfigs().first());
material.setId(10);
revisions.addRevision(material, modification);
BuildCause buildCause = BuildCause.createManualForced(revisions, Username.ANONYMOUS);
PipelineInstanceModel item = PipelineInstanceModel.createPipeline(CaseInsensitiveString.str(pipelineConfig.name()), -1, label, buildCause, stageHistory(pipelineConfig, scheduleDate));
item.setCounter(1);
item.setId(1);
item.setComment("build comment");
history.add(item);
return history;
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels in project gocd by gocd.
the class GoDashboardCurrentStateLoader method findPIMsWithFallbacks.
private PipelineInstanceModels findPIMsWithFallbacks(PipelineConfig pipelineConfig, PipelineInstanceModels historyForDashboard) {
String pipelineName = str(pipelineConfig.name());
PipelineInstanceModels pipelinesToShow = historyForDashboard.findAll(pipelineName);
if (!pipelinesToShow.isEmpty()) {
return pipelinesToShow;
}
if (triggerMonitor.isAlreadyTriggered(pipelineName)) {
return createPipelineInstanceModels(createPreparingToSchedule(pipelineName, new StageInstanceModels()));
}
return createPipelineInstanceModels(createEmptyPipelineInstanceModel(pipelineName, createWithEmptyModifications(), new StageInstanceModels()));
}
Aggregations