Search in sources :

Example 56 with DependencyMaterialConfig

use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.

the class ValueStreamMapServiceTest method shouldPopulateRevisionsForUpstreamPipelines.

@Test
public void shouldPopulateRevisionsForUpstreamPipelines() {
    /*
        * git---> p1 ---> p3
        * |      v      ^
        * +---> p2 -----+
        * **/
    GitMaterial git = new GitMaterial("git");
    MaterialConfig gitConfig = git.config();
    BuildCause p3buildCause = createBuildCause(asList("p1", "p2"), new ArrayList<>());
    BuildCause p2buildCause = createBuildCauseForRevisions(asList(dependencyMaterial("p1", 2)), asList(git), ModificationsMother.multipleModificationList(0));
    BuildCause p1buildCause = createBuildCause(new ArrayList<>(), asList(git));
    Modifications modifications = p1buildCause.getMaterialRevisions().getMaterialRevision(0).getModifications();
    when(pipelineService.buildCauseFor("p3", 1)).thenReturn(p3buildCause);
    when(pipelineService.buildCauseFor("p2", 1)).thenReturn(p2buildCause);
    when(pipelineService.buildCauseFor("p1", 1)).thenReturn(p1buildCause);
    when(pipelineService.buildCauseFor("p1", 2)).thenReturn(p1buildCause);
    PipelineConfig p1Config = PipelineConfigMother.pipelineConfig("p1", new MaterialConfigs(gitConfig));
    PipelineConfig p2Config = PipelineConfigMother.pipelineConfig("p2", new MaterialConfigs(gitConfig));
    PipelineConfig p3Config = PipelineConfigMother.pipelineConfig("p3", new MaterialConfigs(new DependencyMaterialConfig(p1Config.name(), p1Config.getFirstStageConfig().name()), new DependencyMaterialConfig(p2Config.name(), p2Config.getFirstStageConfig().name())));
    CruiseConfig cruiseConfig = new BasicCruiseConfig(new BasicPipelineConfigs(p1Config, p2Config, p3Config));
    when(pipelineService.findPipelineByCounterOrLabel("p3", "1")).thenReturn(new Pipeline("p3", "LABEL-P3", p3buildCause));
    when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
    ValueStreamMapPresentationModel graph = valueStreamMapService.getValueStreamMap("p3", 1, user, result);
    VSMTestHelper.assertNodeHasRevisions(graph, "p1", new PipelineRevision("p1", 1, "LABEL-p1-1"), new PipelineRevision("p1", 2, "LABEL-p1-2"));
    VSMTestHelper.assertNodeHasRevisions(graph, "p2", new PipelineRevision("p2", 1, "LABEL-p2-1"));
    VSMTestHelper.assertNodeHasRevisions(graph, "p3", new PipelineRevision("p3", 1, "LABEL-P3"));
    VSMTestHelper.assertSCMNodeHasMaterialRevisions(graph, git.getFingerprint(), new MaterialRevision(git, false, modifications));
    verify(runStagesPopulator).apply(any(ValueStreamMap.class));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Modifications(com.thoughtworks.go.domain.materials.Modifications) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) ValueStreamMapPresentationModel(com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Example 57 with DependencyMaterialConfig

use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.

the class ValueStreamMapServiceTest method shouldPushAllAncestorsLeftByOneWhenMovingImmediateParentToLeftOfANode.

@Test
public void shouldPushAllAncestorsLeftByOneWhenMovingImmediateParentToLeftOfANode() {
    /*
        * g1 -> P1--->X------>P2
        *        \             ^
        *          \           |
        *            V         |
        *       g2-->P3-------+
        *
        */
    String p1 = "p1";
    String p2 = "p2";
    String p3 = "p3";
    GitMaterial g1 = new GitMaterial("g1");
    GitMaterial g2 = new GitMaterial("g2");
    BuildCause p1buildCause = createBuildCause(new ArrayList<>(), asList(g1));
    BuildCause p3buildCause = createBuildCause(asList(p1), asList(g2));
    BuildCause p2buildCause = createBuildCause(asList(p1, p3), Arrays.<GitMaterial>asList());
    when(pipelineService.buildCauseFor(p1, 1)).thenReturn(p1buildCause);
    when(pipelineService.buildCauseFor(p2, 1)).thenReturn(p2buildCause);
    when(pipelineService.buildCauseFor(p3, 1)).thenReturn(p3buildCause);
    PipelineConfig p1Config = PipelineConfigMother.pipelineConfig(p1, new MaterialConfigs(g1.config()));
    PipelineConfig p3Config = PipelineConfigMother.pipelineConfig(p3, new MaterialConfigs(g2.config(), new DependencyMaterialConfig(p1Config.name(), p1Config.getFirstStageConfig().name())));
    PipelineConfig p2Config = PipelineConfigMother.pipelineConfig(p2, new MaterialConfigs(new DependencyMaterialConfig(p1Config.name(), p1Config.getFirstStageConfig().name()), new DependencyMaterialConfig(p3Config.name(), p3Config.getFirstStageConfig().name())));
    CruiseConfig cruiseConfig = new BasicCruiseConfig(new BasicPipelineConfigs(p1Config, p2Config, p3Config));
    when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
    when(pipelineService.findPipelineByCounterOrLabel(p2, "1")).thenReturn(new Pipeline(p2, "p2-label", p2buildCause));
    ValueStreamMapPresentationModel graph = valueStreamMapService.getValueStreamMap(p2, 1, user, result);
    List<List<Node>> nodesAtEachLevel = graph.getNodesAtEachLevel();
    assertThat(nodesAtEachLevel.size(), is(4));
    VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(0), 0, g1.getFingerprint());
    VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(1), 0, p1, g2.getFingerprint());
    VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(2), 1, p3);
    VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(3), 0, p2);
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Arrays.asList(java.util.Arrays.asList) ValueStreamMapPresentationModel(com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Example 58 with DependencyMaterialConfig

use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.

the class ValueStreamMapServiceTest method currentPipelineShouldNotHaveWarningsIfBuiltFromMultipleRevisionsWithSameLatestRevision.

@Test
public void currentPipelineShouldNotHaveWarningsIfBuiltFromMultipleRevisionsWithSameLatestRevision() {
    /*
                            /-> P1 -- \
                        git            -> p3
                            \-> P2 -- /
         */
    GitMaterial git = new GitMaterial("git");
    MaterialConfig gitConfig = git.config();
    Modification rev1 = ModificationsMother.oneModifiedFile("rev1");
    Modification rev2 = ModificationsMother.oneModifiedFile("rev2");
    Modification rev3 = ModificationsMother.oneModifiedFile("rev3");
    BuildCause p1buildCause = createBuildCauseForRevisions(new ArrayList<>(), asList(git), Arrays.asList(rev3, rev2, rev1));
    BuildCause p2buildCause = createBuildCauseForRevisions(new ArrayList<>(), asList(git), Arrays.asList(rev3));
    BuildCause p3buildCause = createBuildCauseForRevisions(asList(dependencyMaterial("p1", 1), dependencyMaterial("p2", 1)), new ArrayList<>(), new ArrayList<>());
    when(pipelineService.buildCauseFor("p3", 1)).thenReturn(p3buildCause);
    when(pipelineService.buildCauseFor("p1", 1)).thenReturn(p1buildCause);
    when(pipelineService.buildCauseFor("p2", 1)).thenReturn(p2buildCause);
    PipelineConfig p1Config = PipelineConfigMother.pipelineConfig("p1", new MaterialConfigs(gitConfig));
    PipelineConfig p2Config = PipelineConfigMother.pipelineConfig("p2", new MaterialConfigs(gitConfig));
    PipelineConfig p3Config = PipelineConfigMother.pipelineConfig("p3", new MaterialConfigs(new DependencyMaterialConfig(p1Config.name(), p1Config.getFirstStageConfig().name()), new DependencyMaterialConfig(p2Config.name(), p2Config.getFirstStageConfig().name())));
    CruiseConfig cruiseConfig = new BasicCruiseConfig(new BasicPipelineConfigs(p1Config, p2Config, p3Config));
    when(pipelineService.findPipelineByCounterOrLabel("p3", "1")).thenReturn(new Pipeline("p3", "LABEL-P3", p3buildCause));
    when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
    ValueStreamMapPresentationModel graph = valueStreamMapService.getValueStreamMap("p3", 1, user, result);
    assertNull(graph.getCurrentPipeline().getViewType());
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) ValueStreamMapPresentationModel(com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Example 59 with DependencyMaterialConfig

use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.

the class ValueStreamMapServiceTest method shouldMoveNodeAndIntroduceDummyNodesWhenCurrentLevelIsDeeperThanExistingNodeLevel.

@Test
public void shouldMoveNodeAndIntroduceDummyNodesWhenCurrentLevelIsDeeperThanExistingNodeLevel() throws Exception {
    /*
        * +-------------+
        * |             v
        * g---->p1---->p2 ---> p3
        *        |             ^
        *        -------------+
        *
        * */
    GitMaterial git = new GitMaterial("git");
    MaterialConfig gitConfig = git.config();
    String p1 = "p1";
    String p2 = "p2";
    String p3 = "p3";
    BuildCause p3buildCause = createBuildCause(asList(p1, p2), new ArrayList<>());
    BuildCause p2buildCause = createBuildCause(asList(p1), asList(git));
    BuildCause p1buildCause = createBuildCause(new ArrayList<>(), asList(git));
    when(pipelineService.buildCauseFor(p3, 1)).thenReturn(p3buildCause);
    when(pipelineService.buildCauseFor(p2, 1)).thenReturn(p2buildCause);
    when(pipelineService.buildCauseFor(p1, 1)).thenReturn(p1buildCause);
    PipelineConfig p1Config = PipelineConfigMother.pipelineConfig(p1, new MaterialConfigs(gitConfig));
    PipelineConfig p2Config = PipelineConfigMother.pipelineConfig(p2, new MaterialConfigs(gitConfig, new DependencyMaterialConfig(p1Config.name(), p1Config.getFirstStageConfig().name())));
    PipelineConfig p3Config = PipelineConfigMother.pipelineConfig(p3, new MaterialConfigs(new DependencyMaterialConfig(p1Config.name(), p1Config.getFirstStageConfig().name()), new DependencyMaterialConfig(p2Config.name(), p2Config.getFirstStageConfig().name())));
    CruiseConfig cruiseConfig = new BasicCruiseConfig(new BasicPipelineConfigs(p1Config, p2Config, p3Config));
    when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
    when(pipelineService.findPipelineByCounterOrLabel("p3", "1")).thenReturn(new Pipeline("p3", "p3-label", p3buildCause));
    ValueStreamMapPresentationModel graph = valueStreamMapService.getValueStreamMap(p3, 1, user, result);
    List<List<Node>> nodesAtEachLevel = graph.getNodesAtEachLevel();
    assertThat(graph.getCurrentPipeline().getName(), is(p3));
    assertThat(nodesAtEachLevel.size(), is(4));
    List<Node> firstLevel = nodesAtEachLevel.get(0);
    assertThat(firstLevel.size(), is(1));
    assertLayerHasNode(firstLevel, git.getDisplayName(), git.getFingerprint(), p1);
    List<Node> secondLevel = nodesAtEachLevel.get(1);
    assertThat(secondLevel.size(), is(2));
    assertLayerHasNode(secondLevel, p1, p1, p2);
    assertLayerHasDummyNodeWithDependents(secondLevel, p2);
    List<Node> thirdLevel = nodesAtEachLevel.get(2);
    assertThat(thirdLevel.size(), is(2));
    assertLayerHasNode(thirdLevel, p2, p2, p3);
    assertLayerHasDummyNodeWithDependents(thirdLevel, p3);
    List<Node> fourthLevel = nodesAtEachLevel.get(3);
    assertThat(fourthLevel.size(), is(1));
    assertLayerHasNode(fourthLevel, p3, p3);
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Arrays.asList(java.util.Arrays.asList) ValueStreamMapPresentationModel(com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Example 60 with DependencyMaterialConfig

use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.

the class PipelineSqlMapDaoIntegrationTest method pipelineConfigFor.

private PipelineConfig pipelineConfigFor(final String pipelineName, final String dependentOnPipeline, final String dependentOnStage) {
    PipelineConfig config = PipelineMother.twoBuildPlansWithResourcesAndMaterials(pipelineName, "cruiseStage");
    config.materialConfigs().clear();
    config.addMaterialConfig(new DependencyMaterialConfig(new CaseInsensitiveString(dependentOnPipeline), new CaseInsensitiveString(dependentOnStage)));
    return config;
}
Also used : DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)

Aggregations

DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)135 Test (org.junit.Test)106 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)22 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)22 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)21 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)15 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)14 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)11 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)10 Date (java.util.Date)10 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)9 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)8 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)8 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)8 Pipeline (com.thoughtworks.go.domain.Pipeline)8 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)8 ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)7 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)7 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)7 ModificationsMother.changedDependencyMaterialRevision (com.thoughtworks.go.helper.ModificationsMother.changedDependencyMaterialRevision)7