Search in sources :

Example 46 with MaterialRevision

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")));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Date(java.util.Date) Test(org.junit.Test)

Example 47 with MaterialRevision

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()));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Date(java.util.Date) Test(org.junit.Test)

Example 48 with MaterialRevision

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);
}
Also used : List(java.util.List) LinkedList(java.util.LinkedList) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Test(org.junit.Test)

Example 49 with MaterialRevision

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());
}
Also used : CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Test(org.junit.Test)

Example 50 with MaterialRevision

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));
}
Also used : CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Test(org.junit.Test)

Aggregations

MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)185 Test (org.junit.Test)141 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)72 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)68 Modification (com.thoughtworks.go.domain.materials.Modification)65 Date (java.util.Date)50 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)31 Pipeline (com.thoughtworks.go.domain.Pipeline)29 Username (com.thoughtworks.go.server.domain.Username)27 PipelineMaterialRevision (com.thoughtworks.go.domain.PipelineMaterialRevision)23 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)21 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)21 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)20 PipelineDependencyNode (com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode)18 SCMDependencyNode (com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode)18 ValueStreamMap (com.thoughtworks.go.domain.valuestreammap.ValueStreamMap)18 File (java.io.File)17 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)16 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)16 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)16