Search in sources :

Example 41 with PipelineInstanceModel

use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel 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 42 with PipelineInstanceModel

use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.

the class PipelineDependencyGraphOldTest method shouldGroupPiplineInstancesByName.

@Test
public void shouldGroupPiplineInstancesByName() throws Exception {
    PipelineInstanceModel raghu1 = pim("raghu");
    raghu1.setCounter(1);
    PipelineInstanceModel raghu2 = pim("raghu");
    raghu2.setCounter(2);
    PipelineInstanceModel phavan = pim("pavan");
    PipelineDependencyGraphOld graph = new PipelineDependencyGraphOld(pim("upstream"), PipelineInstanceModels.createPipelineInstanceModels(raghu2, phavan, raghu1));
    Map<String, TreeSet<PipelineInstanceModel>> map = graph.groupedDependencies();
    assertThat(map.size(), is(2));
    assertOrderIsMainted(map);
    assertThat(map.get("pavan").size(), is(1));
    assertThat(map.get("pavan"), hasItem(phavan));
    assertThat(map.get("raghu").size(), is(2));
    assertThat(map.get("raghu").first(), is(raghu2));
    assertThat(map.get("raghu").last(), is(raghu1));
}
Also used : PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) TreeSet(java.util.TreeSet) PipelineDependencyGraphOld(com.thoughtworks.go.domain.PipelineDependencyGraphOld) Test(org.junit.Test)

Example 43 with PipelineInstanceModel

use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.

the class ViewCacheKey method forPipelineModelBuildCauses.

public String forPipelineModelBuildCauses(PipelineModel model) {
    StringBuilder s = new StringBuilder();
    s.append("view_buildCausesForPipelineModel_");
    s.append(model.getName());
    for (PipelineInstanceModel pim : model.getActivePipelineInstances()) {
        TrackingTool trackingTool = pim.getTrackingTool();
        MingleConfig mingleConfig = pim.getMingleConfig();
        int trackingToolHash = trackingTool == null ? -1 : trackingTool.hashCode();
        int mingleToolHash = mingleConfig == null ? -1 : mingleConfig.hashCode();
        s.append("[").append(pim.getId()).append("|").append(trackingToolHash).append("|").append(mingleToolHash).append("]");
    }
    return s.toString();
}
Also used : PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) MingleConfig(com.thoughtworks.go.config.MingleConfig) TrackingTool(com.thoughtworks.go.config.TrackingTool)

Example 44 with PipelineInstanceModel

use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.

the class PipelineHistoryItemMother method custom.

public static PipelineInstanceModel custom(StageInstanceModel... stages) {
    PipelineInstanceModel pipelineInstanceModel = PipelineInstanceModel.createEmptyModel();
    pipelineInstanceModel.setStageHistory(new StageInstanceModels());
    for (StageInstanceModel stage : stages) {
        pipelineInstanceModel.getStageHistory().add(stage);
    }
    return pipelineInstanceModel;
}
Also used : PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) StageInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel)

Example 45 with PipelineInstanceModel

use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel 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)

Aggregations

PipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel)60 Test (org.junit.Test)31 StageInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels)15 PipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels)12 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)11 PipelineModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineModel)9 StageInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel)7 NullStageHistoryItem (com.thoughtworks.go.presentation.pipelinehistory.NullStageHistoryItem)6 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)5 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)5 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)4 PipelineDependencyGraphOld (com.thoughtworks.go.domain.PipelineDependencyGraphOld)4 Modification (com.thoughtworks.go.domain.materials.Modification)4 PipelineHistoryGroups (com.thoughtworks.go.server.presentation.models.PipelineHistoryGroups)4 Matchers.anyString (org.mockito.Matchers.anyString)4 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)3 EmptyPipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.EmptyPipelineInstanceModel)3 TimeProvider (com.thoughtworks.go.util.TimeProvider)3 MingleConfig (com.thoughtworks.go.config.MingleConfig)2 TrackingTool (com.thoughtworks.go.config.TrackingTool)2