Search in sources :

Example 31 with MaterialRevision

use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.

the class SpecificMaterialRevisionFactoryTest method shouldCreateDependencyMaterialForAPipeline.

@Test
public void shouldCreateDependencyMaterialForAPipeline() throws Exception {
    DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("upstream"), new CaseInsensitiveString("blah-stage"));
    MaterialConfig dependencyMaterialConfig = dependencyMaterial.config();
    MaterialRevision expected = new MaterialRevision(dependencyMaterial, new Modification(new Date(), "upstream/4/blah-stage/2", "MOCK_LABEL-12", null));
    String upstreamFingerprint = "234fa4";
    when(mockGoConfigService.findMaterial(new CaseInsensitiveString("blahPipeline"), upstreamFingerprint)).thenReturn(dependencyMaterialConfig);
    when(materialConfigConverter.toMaterial(dependencyMaterialConfig)).thenReturn(dependencyMaterial);
    when(mockMaterialChecker.findSpecificRevision(dependencyMaterial, "upstream/4/blah-stage/2")).thenReturn(expected);
    MaterialRevisions materialRevisions = specificMaterialRevisionFactory.create("blahPipeline", Collections.singletonMap(upstreamFingerprint, "upstream/4/blah-stage/2"));
    assertThat(materialRevisions, is(new MaterialRevisions(expected)));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Date(java.util.Date) Test(org.junit.Test)

Example 32 with MaterialRevision

use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.

the class ManualBuildTest method setUp.

@Before
public void setUp() {
    manualBuild = new ManualBuild(new Username(new CaseInsensitiveString("cruise-user")));
    SvnMaterial material = new SvnMaterial("http://foo.bar/baz", "user", "pass", false);
    materialRevisions = new MaterialRevisions(new MaterialRevision(material, new Modification(new Date(), "1234", "MOCK_LABEL-12", null)));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) Username(com.thoughtworks.go.server.domain.Username) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Date(java.util.Date) Before(org.junit.Before)

Example 33 with MaterialRevision

use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.

the class MaterialRevisionsJsonBuilderTest method shouldNotProcessPackageMaterialComment.

@Test
public void shouldNotProcessPackageMaterialComment() throws Exception {
    HashMap<String, String> map = new HashMap<>();
    map.put("TYPE", "PACKAGE_MATERIAL");
    map.put("TRACKBACK_URL", "google.com");
    map.put("COMMENT", "comment");
    String packageMaterialComment = JsonHelper.toJsonString(map);
    Modification modification = new Modification("user", packageMaterialComment, "some@com", new Date(), "1234");
    materialRevisions = new MaterialRevisions(new MaterialRevision(MaterialsMother.packageMaterial(), modification));
    JSONArray jsonArray = buildJson();
    JSONObject modificationJson = (JSONObject) ((JSONArray) ((JSONObject) jsonArray.get(0)).get("modifications")).get(0);
    assertThat(modificationJson.get("comment").render(false), is(JsonHelper.toJsonString(packageMaterialComment)));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) JSONObject(com.sdicons.json.model.JSONObject) HashMap(java.util.HashMap) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) JSONArray(com.sdicons.json.model.JSONArray) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Date(java.util.Date) Test(org.junit.Test)

Example 34 with MaterialRevision

use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.

the class DownstreamInstancePopulatorIntegrationTest method shouldPopulateInstancesBuiltFromCurrentPipeline.

@Test
public void shouldPopulateInstancesBuiltFromCurrentPipeline() {
    /*
            g1 -> P -> P2  -->  P4
                        \      /
                         + P3 +
        */
    ValueStreamMap valueStreamMap = new ValueStreamMap("p", new PipelineRevision("p", 1, "13.1.1"));
    Node nodep2 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p2", "p2"), "p");
    Node nodep3 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p3", "p3"), "p2");
    Node nodep4 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p4", "p4"), "p3");
    valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p4", "p4"), "p2");
    valueStreamMap.addUpstreamMaterialNode(new SCMDependencyNode("g1", "g1", "git"), new CaseInsensitiveString("git"), "p", new MaterialRevision(null));
    GitMaterial g1 = u.wf(new GitMaterial("g1"), "folder3");
    u.checkinInOrder(g1, "g_1");
    ScheduleTestUtil.AddedPipeline p = u.saveConfigWith("p", u.m(g1));
    ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("p2", u.m(p));
    ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("p3", u.m(p2));
    ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("p4", u.m(p2), u.m(p3));
    String p_1 = u.runAndPass(p, "g_1");
    String p2_1 = u.runAndPass(p2, p_1);
    String p3_1 = u.runAndPass(p3, p2_1);
    String p4_1 = u.runAndPass(p4, p2_1, p3_1);
    downstreamInstancePopulator.apply(valueStreamMap);
    assertInstances(nodep2, "p2", 1);
    assertInstances(nodep3, "p3", 1);
    assertInstances(nodep4, "p4", 1);
}
Also used : ValueStreamMap(com.thoughtworks.go.domain.valuestreammap.ValueStreamMap) PipelineDependencyNode(com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode) SCMDependencyNode(com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) PipelineRevision(com.thoughtworks.go.domain.valuestreammap.PipelineRevision) PipelineDependencyNode(com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode) SCMDependencyNode(com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode) Node(com.thoughtworks.go.domain.valuestreammap.Node) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) ScheduleTestUtil(com.thoughtworks.go.server.service.ScheduleTestUtil) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 35 with MaterialRevision

use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.

the class DownstreamInstancePopulatorIntegrationTest method shouldPopulateMultipleInstancesBuiltFromDifferentUpstreamPipelines.

@Test
public void shouldPopulateMultipleInstancesBuiltFromDifferentUpstreamPipelines() {
    /*
            g1 -> P -> P2 -> P4 --> P5
                     \    /
                       P3
        */
    ValueStreamMap valueStreamMap = new ValueStreamMap("p", new PipelineRevision("p", 1, "13.1.1"));
    Node nodep2 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p2", "p2"), "p");
    Node nodep3 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p3", "p3"), "p");
    Node nodep4 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p4", "p4"), "p2");
    valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p4", "p4"), "p3");
    Node nodep5 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p5", "p5"), "p4");
    valueStreamMap.addUpstreamMaterialNode(new SCMDependencyNode("g1", "g1", "git"), new CaseInsensitiveString("git"), "p", new MaterialRevision(null));
    GitMaterial g1 = u.wf(new GitMaterial("g1"), "folder3");
    u.checkinInOrder(g1, "g_1");
    u.checkinInOrder(g1, "g_2");
    ScheduleTestUtil.AddedPipeline p = u.saveConfigWith("p", u.m(g1));
    ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("p2", u.m(p));
    ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("p3", u.m(p));
    ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("p4", u.m(p2), u.m(p3));
    ScheduleTestUtil.AddedPipeline p5 = u.saveConfigWith("p5", u.m(p4));
    String p_1 = u.runAndPass(p, "g_1");
    String p_2 = u.runAndPass(p, "g_2");
    String p2_1 = u.runAndPass(p2, p_1);
    String p2_2 = u.runAndPass(p2, p_1);
    String p2_3 = u.runAndPass(p2, p_2);
    String p3_1 = u.runAndPass(p3, p_1);
    String p3_2 = u.runAndPass(p3, p_1);
    String p4_1 = u.runAndPass(p4, p2_1, p3_1);
    String p4_2 = u.runAndPass(p4, p2_2, p3_1);
    String p4_3 = u.runAndPass(p4, p2_3, p3_2);
    String p5_1 = u.runAndPass(p5, p4_1);
    String p5_2 = u.runAndPass(p5, p4_2);
    String p5_3 = u.runAndPass(p5, p4_3);
    downstreamInstancePopulator.apply(valueStreamMap);
    assertInstances(nodep2, "p2", 1, 2);
    assertInstances(nodep3, "p3", 1, 2);
    assertInstances(nodep4, "p4", 1, 2, 3);
    assertInstances(nodep5, "p5", 1, 2, 3);
}
Also used : ValueStreamMap(com.thoughtworks.go.domain.valuestreammap.ValueStreamMap) PipelineDependencyNode(com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode) SCMDependencyNode(com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) PipelineRevision(com.thoughtworks.go.domain.valuestreammap.PipelineRevision) PipelineDependencyNode(com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode) SCMDependencyNode(com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode) Node(com.thoughtworks.go.domain.valuestreammap.Node) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) ScheduleTestUtil(com.thoughtworks.go.server.service.ScheduleTestUtil) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) 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