Search in sources :

Example 36 with PipelineInstanceModels

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));
}
Also used : PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) PipelineHistoryGroups(com.thoughtworks.go.server.presentation.models.PipelineHistoryGroups) Test(org.junit.Test)

Example 37 with PipelineInstanceModels

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. */
}
Also used : PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 38 with PipelineInstanceModels

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"));
}
Also used : PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels) PipelineDependencyGraphOld(com.thoughtworks.go.domain.PipelineDependencyGraphOld) Test(org.junit.Test)

Example 39 with PipelineInstanceModels

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;
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) Material(com.thoughtworks.go.domain.materials.Material) MaterialConfigConverter(com.thoughtworks.go.server.service.MaterialConfigConverter) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause)

Example 40 with PipelineInstanceModels

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()));
}
Also used : PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels) PipelineInstanceModels.createPipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels.createPipelineInstanceModels) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels)

Aggregations

PipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels)45 Test (org.junit.Test)37 PipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel)12 StageInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels)8 PipelineInstanceModels.createPipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels.createPipelineInstanceModels)4 StageInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel)4 PipelineHistoryGroups (com.thoughtworks.go.server.presentation.models.PipelineHistoryGroups)4 EmptyPipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.EmptyPipelineInstanceModel)3 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)2 PipelineNotFoundException (com.thoughtworks.go.config.PipelineNotFoundException)2 Permissions (com.thoughtworks.go.config.security.Permissions)2 Modification (com.thoughtworks.go.domain.materials.Modification)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 Matchers.anyString (org.mockito.Matchers.anyString)2 SqlMapClientTemplate (org.springframework.orm.ibatis.SqlMapClientTemplate)2 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)1 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)1 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)1 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)1 PipelineDependencyGraphOld (com.thoughtworks.go.domain.PipelineDependencyGraphOld)1