use of com.thoughtworks.go.domain.valuestreammap.ValueStreamMap in project gocd by gocd.
the class CrossingMinimizationTest method shouldReorderGraphsWithScmMaterialsOccurringInLevelsOtherThanTheFirst.
@Test
public void shouldReorderGraphsWithScmMaterialsOccurringInLevelsOtherThanTheFirst() {
/*
g1 g3 ---> P
\ ^
\ |
g2-->P1+-----+
*/
String g1 = "g1";
String g2 = "g2";
String g3 = "g3";
String p1 = "P1";
String p = "P";
ValueStreamMap graph = new ValueStreamMap(p, null);
graph.addUpstreamMaterialNode(new SCMDependencyNode(g3, g3, "git"), null, p, new MaterialRevision(null));
graph.addUpstreamNode(new PipelineDependencyNode(p1, p1), null, p);
graph.addUpstreamMaterialNode(new SCMDependencyNode(g1, g1, "git"), null, p1, new MaterialRevision(null));
graph.addUpstreamMaterialNode(new SCMDependencyNode(g2, g2, "git"), null, p1, new MaterialRevision(null));
NodeLevelMap levelToNodesMap = nodeLevelMap(graph);
crossingMinimization.apply(levelToNodesMap);
assertThat(levelToNodesMap.get(0), is(Arrays.asList(graph.findNode(p))));
assertThat(levelToNodesMap.get(-1), is(Arrays.asList(graph.findNode(g3), graph.findNode(p1))));
assertThat(levelToNodesMap.get(-2), is(Arrays.asList(graph.findNode(g1), graph.findNode(g2))));
assertThat(graph.findNode(g1).getDepth(), is(1));
assertThat(graph.findNode(g2).getDepth(), is(2));
assertThat(graph.findNode(g3).getDepth(), is(1));
assertThat(graph.findNode(p1).getDepth(), is(2));
assertThat(graph.findNode(p).getDepth(), is(1));
}
use of com.thoughtworks.go.domain.valuestreammap.ValueStreamMap in project gocd by gocd.
the class CrossingMinimizationTest method shouldNotReassignMinimumDepthIfOverallSlopeIncreases.
@Test
public void shouldNotReassignMinimumDepthIfOverallSlopeIncreases() {
/*
g1 g4----> p
\ / /
\ / /
g2--> p1 /
/
g3--> p2
*/
ValueStreamMap graph = new ValueStreamMap("P", null);
Node g4 = graph.addUpstreamMaterialNode(new SCMDependencyNode("g4", "g4", "git"), null, "P", new MaterialRevision(null));
Node p1 = graph.addUpstreamNode(new PipelineDependencyNode("P1", "P1"), null, "P");
Node g1 = graph.addUpstreamMaterialNode(new SCMDependencyNode("g1", "g1", "git"), null, "P1", new MaterialRevision(null));
Node g2 = graph.addUpstreamMaterialNode(new SCMDependencyNode("g2", "g2", "git"), null, "P1", new MaterialRevision(null));
Node p2 = graph.addUpstreamNode(new PipelineDependencyNode("P2", "P2"), null, "P");
Node g3 = graph.addUpstreamMaterialNode(new SCMDependencyNode("g3", "g3", "git"), null, "P2", new MaterialRevision(null));
NodeLevelMap levelToNodesMap = nodeLevelMap(graph);
crossingMinimization.apply(levelToNodesMap);
assertThat(levelToNodesMap.get(0), is(Arrays.asList(graph.getCurrentPipeline())));
assertThat(levelToNodesMap.get(-1), is(Arrays.asList(g4, p1, p2)));
assertThat(levelToNodesMap.get(-2), is(Arrays.asList(g1, g2, g3)));
assertThat(graph.toString(), g1.getDepth(), is(1));
assertThat(g2.getDepth(), is(2));
assertThat(g3.getDepth(), is(3));
assertThat(g4.getDepth(), is(1));
assertThat(p1.getDepth(), is(2));
assertThat(p2.getDepth(), is(3));
assertThat(graph.getCurrentPipeline().getDepth(), is(1));
}
use of com.thoughtworks.go.domain.valuestreammap.ValueStreamMap in project gocd by gocd.
the class CrossingMinimizationTest method shouldReorderBasedOnBarycenterForDownstreamGraph.
@Test
public void shouldReorderBasedOnBarycenterForDownstreamGraph() {
/*
g1 -->p ---->p1 -----> p4
\ \ /
\ \ /
\ +->p2 -(---> p5
\ /
\ /
>p3
*/
String g1 = "g1";
String p = "P";
String p1 = "P1";
String p2 = "P2";
String p3 = "P3";
String p4 = "P4";
String p5 = "P5";
ValueStreamMap graph = new ValueStreamMap(p, null);
graph.addUpstreamMaterialNode(new SCMDependencyNode(g1, g1, "git"), null, p, new MaterialRevision(null));
graph.addDownstreamNode(new PipelineDependencyNode(p1, p1), p);
graph.addDownstreamNode(new PipelineDependencyNode(p4, p4), p1);
graph.addDownstreamNode(new PipelineDependencyNode(p2, p2), p);
graph.addDownstreamNode(new PipelineDependencyNode(p5, p5), p2);
graph.addDownstreamNode(new PipelineDependencyNode(p3, p3), p);
graph.addDownstreamNode(new PipelineDependencyNode(p4, p4), p3);
NodeLevelMap levelToNodesMap = nodeLevelMap(graph);
crossingMinimization.apply(levelToNodesMap);
assertThat(levelToNodesMap.get(0), is(Arrays.asList(graph.findNode(p))));
assertThat(levelToNodesMap.get(-1), is(Arrays.asList(graph.findNode(g1))));
assertThat(levelToNodesMap.get(1), is(Arrays.asList(graph.findNode(p1), graph.findNode(p3), graph.findNode(p2))));
assertThat(levelToNodesMap.get(2), is(Arrays.asList(graph.findNode(p4), graph.findNode(p5))));
assertThat(graph.findNode(g1).getDepth(), is(1));
assertThat(graph.findNode(p).getDepth(), is(1));
assertThat(graph.findNode(p1).getDepth(), is(1));
assertThat(graph.findNode(p2).getDepth(), is(3));
assertThat(graph.findNode(p3).getDepth(), is(2));
assertThat(graph.findNode(p4).getDepth(), is(1));
assertThat(graph.findNode(p5).getDepth(), is(3));
}
use of com.thoughtworks.go.domain.valuestreammap.ValueStreamMap in project gocd by gocd.
the class CrossingMinimizationTest method shouldInitializeNodeDepthsInDfSOrder.
@Test
public void shouldInitializeNodeDepthsInDfSOrder() {
/*
g2 p1 --> P --> p3 p6
\ / / \/
/\ / / \
g1 p2 p4 p5
*/
String g1 = "g1";
String g2 = "g2";
String p1 = "p1";
String p2 = "p2";
String p = "p";
String p3 = "p3";
String p4 = "p4";
String p5 = "p5";
String p6 = "p6";
ValueStreamMap graph = new ValueStreamMap(p, null);
graph.addUpstreamNode(new PipelineDependencyNode(p1, p1), null, p);
graph.addUpstreamNode(new PipelineDependencyNode(p2, p2), null, p);
graph.addUpstreamMaterialNode(new SCMDependencyNode(g2, g2, "git"), null, p2, new MaterialRevision(null));
graph.addUpstreamMaterialNode(new SCMDependencyNode(g1, g1, "git"), null, p1, new MaterialRevision(null));
graph.addDownstreamNode(new PipelineDependencyNode(p3, p3), p);
graph.addDownstreamNode(new PipelineDependencyNode(p4, p4), p);
graph.addDownstreamNode(new PipelineDependencyNode(p6, p6), p4);
graph.addDownstreamNode(new PipelineDependencyNode(p5, p5), p3);
crossingMinimization.initializeNodeDepths(nodeLevelMap(graph));
assertThat(graph.findNode(g1).getDepth(), is(1));
assertThat(graph.findNode(g2).getDepth(), is(2));
assertThat(graph.findNode(p1).getDepth(), is(1));
assertThat(graph.findNode(p2).getDepth(), is(2));
assertThat(graph.findNode(p).getDepth(), is(1));
assertThat(graph.findNode(p3).getDepth(), is(1));
assertThat(graph.findNode(p4).getDepth(), is(2));
assertThat(graph.findNode(p5).getDepth(), is(1));
assertThat(graph.findNode(p6).getDepth(), is(2));
}
use of com.thoughtworks.go.domain.valuestreammap.ValueStreamMap in project gocd by gocd.
the class DummyNodeCreationTest method shouldMoveNodeAndIntroduceDummyNodesToCorrectLayer.
@Test
public void shouldMoveNodeAndIntroduceDummyNodesToCorrectLayer() {
/*
d2 -- X -----+
| V
==> d4 --> d1
| ^
d3 -- X -----+
*/
String currentPipeline = "d1";
ValueStreamMap graph = new ValueStreamMap(currentPipeline, null);
graph.addUpstreamNode(new PipelineDependencyNode("d2", "d2"), null, currentPipeline);
graph.addUpstreamNode(new PipelineDependencyNode("d3", "d3"), null, currentPipeline);
graph.addUpstreamNode(new PipelineDependencyNode("d4", "d4"), null, currentPipeline);
graph.addUpstreamNode(new PipelineDependencyNode("d2", "d2"), null, "d4");
graph.addUpstreamNode(new PipelineDependencyNode("d3", "d3"), null, "d4");
NodeLevelMap nodeLevelMap = new LevelAssignment().apply(graph);
dummyNodeCreation.apply(graph, nodeLevelMap);
VSMTestHelper.assertNumberOfLevelsInGraph(nodeLevelMap, 3);
assertThat(nodeLevelMap.get(0).size(), is(1));
assertThat(nodeLevelMap.get(-1).size(), is(3));
assertThat(nodeLevelMap.get(-2).size(), is(2));
}
Aggregations