use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.
the class ValueStreamMapTest method currentPipelineShouldNotHaveWarningsIfBuiltFromMultipleMaterialRevisionsWithSameLatestRevision.
@Test
public void currentPipelineShouldNotHaveWarningsIfBuiltFromMultipleMaterialRevisionsWithSameLatestRevision() {
String current = "current";
ValueStreamMap valueStreamMap = new ValueStreamMap(current, null);
SCMDependencyNode scmDependencyNode = new SCMDependencyNode("id", "git_node", "git");
MaterialRevision rev1 = new MaterialRevision(MaterialsMother.gitMaterial("git/repo/url"), ModificationsMother.oneModifiedFile("rev1"));
MaterialRevision rev2 = new MaterialRevision(MaterialsMother.gitMaterial("git/repo/url"), ModificationsMother.oneModifiedFile("rev1"), ModificationsMother.oneModifiedFile("rev2"));
valueStreamMap.addUpstreamMaterialNode(scmDependencyNode, new CaseInsensitiveString("git"), valueStreamMap.getCurrentPipeline().getId(), rev1);
valueStreamMap.addUpstreamMaterialNode(scmDependencyNode, new CaseInsensitiveString("git"), valueStreamMap.getCurrentPipeline().getId(), rev2);
valueStreamMap.addWarningIfBuiltFromInCompatibleRevisions();
assertNull(valueStreamMap.getCurrentPipeline().getViewType());
}
use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.
the class ValueStreamMapTest method shouldNotConsiderTriangleDependencyAsCyclic.
@Test
public void shouldNotConsiderTriangleDependencyAsCyclic() {
/*
* g --> A -> D --------> B ----> C
* |________________________^
*/
String a = "A";
String b = "B";
String c = "C";
String d = "D";
ValueStreamMap valueStreamMap = new ValueStreamMap(c, null);
valueStreamMap.addUpstreamNode(new PipelineDependencyNode(a, a), null, c);
valueStreamMap.addUpstreamNode(new PipelineDependencyNode(b, b), null, c);
valueStreamMap.addUpstreamNode(new PipelineDependencyNode(d, d), null, b);
valueStreamMap.addUpstreamNode(new PipelineDependencyNode(a, a), null, d);
valueStreamMap.addUpstreamMaterialNode(new SCMDependencyNode("g", "g", "git"), null, a, new MaterialRevision(null));
assertThat(valueStreamMap.hasCycle(), is(false));
}
use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.
the class ValueStreamMapTest method shouldPopulateSCMDependencyNodeWithMaterialRevisions.
@Test
public void shouldPopulateSCMDependencyNodeWithMaterialRevisions() {
/*
git_fingerprint -> P1 ---- \
\ -> p3
-> P2 ---- /
*/
String P1 = "P1";
String P2 = "P2";
String currentPipeline = "P3";
ValueStreamMap graph = new ValueStreamMap(currentPipeline, null);
MaterialRevision revision1 = new MaterialRevision(MaterialsMother.gitMaterial("test/repo1"), oneModifiedFile("revision1"));
MaterialRevision revision2 = new MaterialRevision(MaterialsMother.gitMaterial("test/repo2"), oneModifiedFile("revision2"));
graph.addUpstreamNode(new PipelineDependencyNode(P1, P1), null, currentPipeline);
graph.addUpstreamNode(new PipelineDependencyNode(P2, P2), null, currentPipeline);
graph.addUpstreamMaterialNode(new SCMDependencyNode("git_fingerprint", "git", "git"), new CaseInsensitiveString("git1"), P1, revision1);
graph.addUpstreamMaterialNode(new SCMDependencyNode("git_fingerprint", "git", "git"), new CaseInsensitiveString("git1"), P2, revision2);
SCMDependencyNode node = (SCMDependencyNode) graph.findNode("git_fingerprint");
assertThat(node.getMaterialRevisions().size(), is(2));
assertTrue(node.getMaterialRevisions().contains(revision1));
assertTrue(node.getMaterialRevisions().contains(revision2));
}
use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.
the class ValueStreamMapTest method shouldOptimizeVisualizationOfThePipelineDependencyGraph.
@Test
public void shouldOptimizeVisualizationOfThePipelineDependencyGraph() {
/*
git-trunk git-plugins-->plugins ---->acceptance---->deploy-go03---> publish --->deploy-go01
\ / ^ ^ \ ^
\ / | | \ /
\ / | | \ /
hg-trunk--->cruise +--------------------+ | +-->deploy-go02---------------+
+ |
+---------------------------------------+
*/
String acceptance = "acceptance";
String plugins = "plugins";
String gitPlugins = "git-plugins";
String cruise = "cruise";
String gitTrunk = "git-trunk";
String hgTrunk = "hg-trunk";
String deployGo03 = "deploy-go03";
String deployGo02 = "deploy-go02";
String deployGo01 = "deploy-go01";
String publish = "publish";
ValueStreamMap graph = new ValueStreamMap(acceptance, null);
graph.addUpstreamNode(new PipelineDependencyNode(plugins, plugins), null, acceptance);
graph.addUpstreamNode(new PipelineDependencyNode(gitPlugins, gitPlugins), null, plugins);
graph.addUpstreamNode(new PipelineDependencyNode(cruise, cruise), null, plugins);
graph.addUpstreamMaterialNode(new SCMDependencyNode(gitTrunk, gitTrunk, "git"), null, cruise, new MaterialRevision(null));
graph.addUpstreamMaterialNode(new SCMDependencyNode(hgTrunk, hgTrunk, "hg"), null, cruise, new MaterialRevision(null));
graph.addUpstreamNode(new PipelineDependencyNode(cruise, cruise), null, acceptance);
graph.addUpstreamMaterialNode(new SCMDependencyNode(hgTrunk, hgTrunk, "hg"), null, acceptance, new MaterialRevision(null));
graph.addDownstreamNode(new PipelineDependencyNode(deployGo03, deployGo03), acceptance);
graph.addDownstreamNode(new PipelineDependencyNode(publish, publish), deployGo03);
graph.addDownstreamNode(new PipelineDependencyNode(deployGo01, deployGo01), publish);
graph.addDownstreamNode(new PipelineDependencyNode(deployGo02, deployGo02), acceptance);
graph.addDownstreamNode(new PipelineDependencyNode(deployGo01, deployGo01), deployGo02);
List<List<Node>> nodesAtEachLevel = graph.presentationModel().getNodesAtEachLevel();
assertThat(nodesAtEachLevel.size(), is(7));
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(0), 0, gitTrunk, hgTrunk);
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(1), 1, gitPlugins, cruise);
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(2), 2, plugins);
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(3), 0, acceptance);
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(4), 0, deployGo03, deployGo02);
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(5), 1, publish);
VSMTestHelper.assertThatLevelHasNodes(nodesAtEachLevel.get(6), 0, deployGo01);
MatcherAssert.assertThat(graph.findNode(gitTrunk).getDepth(), is(2));
MatcherAssert.assertThat(graph.findNode(hgTrunk).getDepth(), is(3));
MatcherAssert.assertThat(graph.findNode(gitPlugins).getDepth(), is(1));
MatcherAssert.assertThat(graph.findNode(cruise).getDepth(), is(2));
MatcherAssert.assertThat(graph.findNode(deployGo03).getDepth(), is(1));
MatcherAssert.assertThat(graph.findNode(deployGo02).getDepth(), is(2));
MatcherAssert.assertThat(graph.findNode(publish).getDepth(), is(1));
MatcherAssert.assertThat(graph.findNode(deployGo01).getDepth(), is(1));
}
use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.
the class ValueStreamMapTest method shouldThrowCyclicDependencyExceptionIfACycleIsDetected_CycleDetectedInUpstreamNodes.
@Test
public void shouldThrowCyclicDependencyExceptionIfACycleIsDetected_CycleDetectedInUpstreamNodes() {
/*
* git -> A1 -> B1
* all run once
* config changes to:
* git -> B1 -> A2 -> C1
*
*/
String a = "A";
String b = "B";
String c = "C";
ValueStreamMap graph = new ValueStreamMap(b, null);
graph.addUpstreamNode(new PipelineDependencyNode(a, a), null, b);
graph.addUpstreamMaterialNode(new SCMDependencyNode("g", "g", "git"), null, a, new MaterialRevision(null));
graph.addDownstreamNode(new PipelineDependencyNode(a, a), b);
graph.addDownstreamNode(new PipelineDependencyNode(c, c), a);
assertThat(graph.hasCycle(), is(true));
}
Aggregations