use of com.thoughtworks.go.domain.buildcause.BuildCause 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());
}
use of com.thoughtworks.go.domain.buildcause.BuildCause 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));
}
use of com.thoughtworks.go.domain.buildcause.BuildCause 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);
}
use of com.thoughtworks.go.domain.buildcause.BuildCause in project gocd by gocd.
the class ValueStreamMapServiceTest method shouldGetPipelineDependencyGraphForAPipelineWithNoCrossLevelDependencies.
@Test
public void shouldGetPipelineDependencyGraphForAPipelineWithNoCrossLevelDependencies() {
/*
* svn => P1
* */
String pipeline = "P1";
int counter = 1;
BuildCause buildCause = PipelineMother.pipeline(pipeline, new Stage()).getBuildCause();
MaterialConfig material = buildCause.getMaterialRevisions().getMaterialRevision(0).getMaterial().config();
when(pipelineService.buildCauseFor(pipeline, counter)).thenReturn(buildCause);
PipelineConfig p1Config = PipelineConfigMother.pipelineConfig(pipeline, new MaterialConfigs(material));
when(goConfigService.currentCruiseConfig()).thenReturn(new BasicCruiseConfig(new BasicPipelineConfigs(p1Config)));
when(pipelineService.findPipelineByCounterOrLabel(pipeline, "1")).thenReturn(new Pipeline(pipeline, "p1-label", buildCause));
ValueStreamMapPresentationModel graph = valueStreamMapService.getValueStreamMap(pipeline, counter, user, result);
List<List<Node>> nodesAtEachLevel = graph.getNodesAtEachLevel();
assertThat(graph.getCurrentPipeline().getName(), is(pipeline));
assertThat(nodesAtEachLevel.size(), is(2));
List<Node> firstLevel = nodesAtEachLevel.get(0);
assertThat(firstLevel.size(), is(1));
assertNode(-1, firstLevel.get(0), material.getDisplayName(), material.getFingerprint(), 0, pipeline);
List<Node> secondLevel = nodesAtEachLevel.get(1);
assertThat(secondLevel.size(), is(1));
assertNode(0, secondLevel.get(0), pipeline, pipeline, 0);
}
use of com.thoughtworks.go.domain.buildcause.BuildCause 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);
}
Aggregations