Search in sources :

Example 16 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 17 with MaterialRevision

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

the class ViewCacheKeyTest method shouldGenerateKeyForEnvironmentPipelineFragment.

@Test
public void shouldGenerateKeyForEnvironmentPipelineFragment() {
    MaterialRevisions materialRevisions = ModificationsMother.createHgMaterialRevisions();
    Modification latestModification = materialRevisions.getMaterialRevision(0).getModifications().remove(0);
    PipelineModel model = new PipelineModel("pipelineName", true, true, PipelinePauseInfo.notPaused()).updateAdministrability(true);
    StageInstanceModels stages = new StageInstanceModels();
    stages.add(stageInstance("stageName", 13, JobState.Building, JobResult.Unknown));
    stages.add(new NullStageHistoryItem("stage2", true));
    PipelineInstanceModel pipelineInstance = PipelineInstanceModel.createPipeline("pipelineName", 10, "label-10", BuildCause.createWithModifications(materialRevisions, "someone"), stages);
    pipelineInstance.setMaterialConfigs(materialRevisions.getMaterials().convertToConfigs());
    pipelineInstance.setLatestRevisions(new MaterialRevisions(new MaterialRevision(materialRevisions.getMaterialRevision(0).getMaterial(), latestModification)));
    pipelineInstance.setId(12);
    model.addPipelineInstance(pipelineInstance);
    assertThat(model.hasNewRevisions(), is(true));
    assertThat(viewCacheKey.forEnvironmentPipelineBox(model), is("view_environmentPipelineFragment_pipelineName{false|false|false}[12|stageName|13|Building|stage2|0|Unknown|]true|true|false|||true|true"));
    model.updateAdministrability(false);
    assertThat(viewCacheKey.forEnvironmentPipelineBox(model), is("view_environmentPipelineFragment_pipelineName{false|false|false}[12|stageName|13|Building|stage2|0|Unknown|]true|true|false|||false|true"));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) NullStageHistoryItem(com.thoughtworks.go.presentation.pipelinehistory.NullStageHistoryItem) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) PipelineModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineModel) Test(org.junit.Test)

Example 18 with MaterialRevision

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

the class CrossingMinimizationTest method shouldAssignNodesBasedOnMinimumDepthForDownstreamGraph.

@Test
public void shouldAssignNodesBasedOnMinimumDepthForDownstreamGraph() {
    /*
            g1 --> P ---> P1  P3
                     \      /
                      +-> P2
         */
    ValueStreamMap graph = new ValueStreamMap("P", null);
    Node g1 = graph.addUpstreamMaterialNode(new SCMDependencyNode("g1", "g1", "git"), null, "P", new MaterialRevision(null));
    Node p1 = graph.addDownstreamNode(new PipelineDependencyNode("p1", "p1"), "P");
    Node p2 = graph.addDownstreamNode(new PipelineDependencyNode("P2", "P2"), "P");
    Node p3 = graph.addDownstreamNode(new PipelineDependencyNode("P3", "P3"), "P2");
    NodeLevelMap levelToNodesMap = nodeLevelMap(graph);
    crossingMinimization.apply(levelToNodesMap);
    assertThat(levelToNodesMap.get(-1), is(Arrays.asList(g1)));
    assertThat(levelToNodesMap.get(0), is(Arrays.asList(graph.getCurrentPipeline())));
    assertThat(levelToNodesMap.get(1), is(Arrays.asList(p1, p2)));
    assertThat(levelToNodesMap.get(2), is(Arrays.asList(p3)));
    assertThat(p1.getDepth(), is(1));
    assertThat(p2.getDepth(), is(2));
    assertThat(p3.getDepth(), is(2));
}
Also used : ValueStreamMap(com.thoughtworks.go.domain.valuestreammap.ValueStreamMap) PipelineDependencyNode(com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode) SCMDependencyNode(com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode) PipelineDependencyNode(com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode) Node(com.thoughtworks.go.domain.valuestreammap.Node) SCMDependencyNode(com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) NodeLevelMap(com.thoughtworks.go.domain.valuestreammap.NodeLevelMap) Test(org.junit.Test)

Example 19 with MaterialRevision

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

the class DummyNodeCreationTest method shouldHandleDeepTriangle.

@Test
public void shouldHandleDeepTriangle() {
    /*
             +---> d1 ---> d2 ---> d3
             g                     ^
             +---- x ----- x ------+
         */
    String currentPipeline = "d3";
    ValueStreamMap graph = new ValueStreamMap(currentPipeline, null);
    graph.addUpstreamNode(new PipelineDependencyNode("d2", "d2"), null, currentPipeline);
    graph.addUpstreamNode(new PipelineDependencyNode("d1", "d1"), null, "d2");
    graph.addUpstreamMaterialNode(new SCMDependencyNode("g", "g", "git"), null, "d1", new MaterialRevision(null));
    graph.addUpstreamMaterialNode(new SCMDependencyNode("g", "g", "git"), null, currentPipeline, new MaterialRevision(null));
    NodeLevelMap nodeLevelMap = new LevelAssignment().apply(graph);
    dummyNodeCreation.apply(graph, nodeLevelMap);
    VSMTestHelper.assertNumberOfLevelsInGraph(nodeLevelMap, 4);
    VSMTestHelper.assertThatLevelHasNodes(nodeLevelMap.get(0), 0, "d3");
    VSMTestHelper.assertThatLevelHasNodes(nodeLevelMap.get(-1), 1, "d2");
    VSMTestHelper.assertThatLevelHasNodes(nodeLevelMap.get(-2), 1, "d1");
    VSMTestHelper.assertThatLevelHasNodes(nodeLevelMap.get(-3), 0, "g");
}
Also used : ValueStreamMap(com.thoughtworks.go.domain.valuestreammap.ValueStreamMap) PipelineDependencyNode(com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode) SCMDependencyNode(com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) NodeLevelMap(com.thoughtworks.go.domain.valuestreammap.NodeLevelMap) Test(org.junit.Test)

Example 20 with MaterialRevision

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

the class DummyNodeCreationTest method shouldCreateDummyNodesAtCorrectLevelsWhenNodesAreAddedUsingDFS.

@Test
public void shouldCreateDummyNodesAtCorrectLevelsWhenNodesAreAddedUsingDFS() {
    /*                +-------X------+
                          |              v
             +---> p1 --> p4 --> p5 ---> P6
            |             ^      ^
           git --> p2 ----+      |
            |                    |
            +---> X -----p3------+
         */
    String currentPipeline = "p6";
    ValueStreamMap graph = new ValueStreamMap(currentPipeline, null);
    graph.addUpstreamNode(new PipelineDependencyNode("p4", "p4"), null, currentPipeline);
    graph.addUpstreamNode(new PipelineDependencyNode("p1", "p1"), null, "p4");
    graph.addUpstreamMaterialNode(new SCMDependencyNode("git", "git", "git"), null, "p1", new MaterialRevision(null));
    graph.addUpstreamNode(new PipelineDependencyNode("p2", "p2"), null, "p4");
    graph.addUpstreamMaterialNode(new SCMDependencyNode("git", "git", "git"), null, "p2", new MaterialRevision(null));
    graph.addUpstreamNode(new PipelineDependencyNode("p5", "p5"), null, currentPipeline);
    graph.addUpstreamNode(new PipelineDependencyNode("p3", "p3"), null, "p5");
    graph.addUpstreamMaterialNode(new SCMDependencyNode("git", "git", "git"), null, "p3", new MaterialRevision(null));
    graph.addUpstreamNode(new PipelineDependencyNode("p4", "p4"), null, "p5");
    graph.addUpstreamNode(new PipelineDependencyNode("p1", "p1"), null, "p4");
    graph.addUpstreamMaterialNode(new SCMDependencyNode("git", "git", "git"), null, "p1", new MaterialRevision(null));
    graph.addUpstreamNode(new PipelineDependencyNode("p2", "p2"), null, "p4");
    graph.addUpstreamMaterialNode(new SCMDependencyNode("git", "git", "git"), null, "p2", new MaterialRevision(null));
    NodeLevelMap nodeLevelMap = new LevelAssignment().apply(graph);
    dummyNodeCreation.apply(graph, nodeLevelMap);
    VSMTestHelper.assertNumberOfLevelsInGraph(nodeLevelMap, 5);
    assertThat(nodeLevelMap.get(0).size(), is(1));
    assertThat(nodeLevelMap.get(-1).size(), is(2));
    assertThat(nodeLevelMap.get(-2).size(), is(2));
    assertThat(nodeLevelMap.get(-3).size(), is(3));
    assertThat(nodeLevelMap.get(-4).size(), is(1));
}
Also used : ValueStreamMap(com.thoughtworks.go.domain.valuestreammap.ValueStreamMap) PipelineDependencyNode(com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode) SCMDependencyNode(com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) NodeLevelMap(com.thoughtworks.go.domain.valuestreammap.NodeLevelMap) Test(org.junit.Test)

Aggregations

MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)192 Test (org.junit.Test)146 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)75 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)72 Modification (com.thoughtworks.go.domain.materials.Modification)68 Date (java.util.Date)52 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)32 Pipeline (com.thoughtworks.go.domain.Pipeline)30 Username (com.thoughtworks.go.server.domain.Username)28 PipelineMaterialRevision (com.thoughtworks.go.domain.PipelineMaterialRevision)23 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)22 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)21 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)20 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)19 PipelineDependencyNode (com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode)18 SCMDependencyNode (com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode)18 ValueStreamMap (com.thoughtworks.go.domain.valuestreammap.ValueStreamMap)18 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)17 File (java.io.File)17 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)16