use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.
the class CcTrayBreakersCalculatorTest method shouldCaptureAuthorNamesOfUnchangedRevisionsIfThereAreNoChangedRevisions.
@Test
public void shouldCaptureAuthorNamesOfUnchangedRevisionsIfThereAreNoChangedRevisions() throws Exception {
Modification user1Commit = ModificationsMother.checkinWithComment("123", "comment 1", "user1", "user1@domain1.com", new Date(), "foo.c");
Modification user2Commit = ModificationsMother.checkinWithComment("124", "comment 2", "user2", "user2@domain2.com", new Date(), "bar.c");
MaterialRevision firstUnchangedRevision = new MaterialRevision(MaterialsMother.gitMaterial("foo.com"), user1Commit, user2Commit);
Modification user3Commit = ModificationsMother.checkinWithComment("125", "comment 1", "user3", "user3@domain2.com", new Date(), "bar.c");
MaterialRevision secondUnchangedRevision = new MaterialRevision(MaterialsMother.gitMaterial("bar.com"), user3Commit);
MaterialRevisions revisions = new MaterialRevisions(firstUnchangedRevision, secondUnchangedRevision);
when(materialRepo.findMaterialRevisionsForPipeline(12l)).thenReturn(revisions);
CcTrayBreakersCalculator status = new CcTrayBreakersCalculator(materialRepo);
Set<String> actualBreakers = status.calculateFor(failedStage());
assertThat(actualBreakers, is(s("user1", "user2", "user3")));
}
use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.
the class CcTrayBreakersCalculatorTest method shouldNotHaveAnyBreakersIfStageHasNotFailed.
@Test
public void shouldNotHaveAnyBreakersIfStageHasNotFailed() throws Exception {
Modification user1Commit = ModificationsMother.checkinWithComment("123", "comment 1", "user1", "user1@domain1.com", new Date(), "foo.c");
MaterialRevision revision = new MaterialRevision(MaterialsMother.gitMaterial("foo.com"), user1Commit);
revision.markAsChanged();
MaterialRevisions revisions = new MaterialRevisions(revision);
when(materialRepo.findMaterialRevisionsForPipeline(12l)).thenReturn(revisions);
CcTrayBreakersCalculator status = new CcTrayBreakersCalculator(materialRepo);
Set<String> actualBreakers = status.calculateFor(StageMother.createPassedStage("pipeline1", 1, "stage1", 1, "job1", new Date()));
assertThat(actualBreakers, is(Collections.<String>emptySet()));
}
use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.
the class ValueStreamMapTest method shouldKeepUpstreamNodeAtALevelLessThanDependent.
@Test
public void shouldKeepUpstreamNodeAtALevelLessThanDependent() {
/*
git_fingerprint -> P1
*/
String dependent = "P1";
ValueStreamMap graph = new ValueStreamMap(dependent, null);
graph.addUpstreamMaterialNode(new SCMDependencyNode("git_fingerprint", "git", "git"), null, dependent, new MaterialRevision(null));
List<List<Node>> nodesAtEachLevel = graph.presentationModel().getNodesAtEachLevel();
assertThat(nodesAtEachLevel.size(), is(2));
assertThat(nodesAtEachLevel.get(0).size(), is(1));
Node gitScmNode = nodesAtEachLevel.get(0).get(0);
assertThat(gitScmNode.getId(), is("git_fingerprint"));
assertThat(gitScmNode.getName(), is("git"));
VSMTestHelper.assertThatNodeHasChildren(graph, "git_fingerprint", 0, dependent);
}
use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.
the class ValueStreamMapTest method shouldNotPopulateAnyMaterialNamesForAMaterial_WhenNoNamesAreGiven.
@Test
public void shouldNotPopulateAnyMaterialNamesForAMaterial_WhenNoNamesAreGiven() {
/*
git_fingerprint -> P1 -> P2
|_________________________^
*/
String P1 = "P1";
String currentPipeline = "P2";
ValueStreamMap graph = new ValueStreamMap(currentPipeline, null);
graph.addUpstreamMaterialNode(new SCMDependencyNode("git_fingerprint", "http://git.com", "git"), null, currentPipeline, new MaterialRevision(null));
graph.addUpstreamNode(new PipelineDependencyNode(P1, P1), null, currentPipeline);
graph.addUpstreamMaterialNode(new SCMDependencyNode("git_fingerprint", "http://git.com", "git"), null, P1, new MaterialRevision(null));
SCMDependencyNode node = (SCMDependencyNode) graph.findNode("git_fingerprint");
assertTrue(node.getMaterialNames().isEmpty());
}
use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.
the class ValueStreamMapTest method shouldThrowCyclicDependencyExceptionIfACycleIsDetected_DownstreamOfCurrentWasUpstreamOfCurrentAtSomePoint.
@Test
public void shouldThrowCyclicDependencyExceptionIfACycleIsDetected_DownstreamOfCurrentWasUpstreamOfCurrentAtSomePoint() {
/*
* config version 1:
* grandParent -> parent -> current -> child
* all pipelines run once
* config version 2:
* parent -> current -> child -> grandParent
* */
String grandParent = "grandParent";
String parent = "parent";
String child = "child";
String currentPipeline = "current";
ValueStreamMap graph = new ValueStreamMap(currentPipeline, null);
graph.addDownstreamNode(new PipelineDependencyNode(child, child), currentPipeline);
graph.addDownstreamNode(new PipelineDependencyNode(grandParent, grandParent), child);
graph.addUpstreamNode(new PipelineDependencyNode(parent, parent), null, currentPipeline);
graph.addUpstreamNode(new PipelineDependencyNode(grandParent, grandParent), null, parent);
graph.addUpstreamMaterialNode(new SCMDependencyNode("g", "g", "git"), null, grandParent, new MaterialRevision(null));
graph.addUpstreamMaterialNode(new SCMDependencyNode("g", "g", "git"), null, parent, new MaterialRevision(null));
assertThat(graph.hasCycle(), is(true));
}
Aggregations