Search in sources :

Example 21 with MaterialRevision

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

the class LevelAssignmentTest method shouldAssignLevelsForUpstreamNodesOfCurrentPipeline.

@Test
public void shouldAssignLevelsForUpstreamNodesOfCurrentPipeline() throws Exception {
    /*
        ---> p1 ---
       /            \
       g -----------p3
       \            /
        ---> p2 ---
        */
    String current = "p3";
    Node p1 = new PipelineDependencyNode("p1", "p1");
    Node p2 = new PipelineDependencyNode("p2", "p2");
    Node gitNode = new SCMDependencyNode("git", "g", "git");
    ValueStreamMap valueStreamMap = new ValueStreamMap(current, new PipelineRevision(current, 1, "1"));
    valueStreamMap.addUpstreamNode(p1, new PipelineRevision("p1", 1, "1"), current);
    valueStreamMap.addUpstreamNode(p2, new PipelineRevision("p2", 1, "1"), current);
    valueStreamMap.addUpstreamMaterialNode(gitNode, new CaseInsensitiveString("trunk"), "p1", new MaterialRevision(null));
    valueStreamMap.addUpstreamMaterialNode(gitNode, new CaseInsensitiveString("main-branch"), "p3", new MaterialRevision(null));
    valueStreamMap.addUpstreamMaterialNode(gitNode, new CaseInsensitiveString("main-branch"), "p2", new MaterialRevision(null));
    NodeLevelMap levelToNodeMap = new LevelAssignment().apply(valueStreamMap);
    assertThat(valueStreamMap.getCurrentPipeline().getLevel(), is(0));
    assertThat(p1.getLevel(), is(-1));
    assertThat(p2.getLevel(), is(-1));
    assertThat(gitNode.getLevel(), is(-2));
    assertThat(levelToNodeMap.get(0), contains(valueStreamMap.getCurrentPipeline()));
    assertThat(levelToNodeMap.get(-1), containsInAnyOrder(p1, p2));
    assertThat(levelToNodeMap.get(-2), contains(gitNode));
}
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) SCMDependencyNode(com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode) Node(com.thoughtworks.go.domain.valuestreammap.Node) PipelineRevision(com.thoughtworks.go.domain.valuestreammap.PipelineRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) NodeLevelMap(com.thoughtworks.go.domain.valuestreammap.NodeLevelMap) Test(org.junit.Test)

Example 22 with MaterialRevision

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

the class EnvironmentVariableContextTest method shouldPopulateEnvironmentForMaterialUsingDest.

@Test
public void shouldPopulateEnvironmentForMaterialUsingDest() {
    SvnMaterial svn = MaterialsMother.svnMaterial();
    svn.setFolder("svn-dir");
    MaterialRevision revision = new MaterialRevision(svn, ModificationsMother.oneModifiedFile("revision1"));
    MaterialRevisions materialRevisions = new MaterialRevisions(revision);
    EnvironmentVariableContext context = new EnvironmentVariableContext();
    context.setProperty("GO_SERVER_URL", SystemEnvironment.getProperty("serviceUrl"), false);
    jobIdentifier().populateEnvironmentVariables(context);
    materialRevisions.populateEnvironmentVariables(context, WORKING_DIR);
    assertThat(context.getProperty("GO_REVISION_SVN_DIR"), is("revision1"));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) Test(org.junit.Test)

Example 23 with MaterialRevision

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

the class SvnExternalTest method shouldGetLatestRevision.

@Test
public void shouldGetLatestRevision() {
    SvnMaterial svn = svnMaterial(svnRepo.projectRepositoryUrl(), null);
    SvnMaterial svnExt = svnMaterial(svnRepo.externalRepositoryUrl(), "end2end");
    final Materials materials = new Materials(svn, svnExt);
    final MaterialRevisions materialRevisions = materials.latestModification(svnRepo.workingFolder(), new TestSubprocessExecutionContext());
    assertThat(materialRevisions.numberOfRevisions(), is(2));
    MaterialRevision main = materialRevisions.getRevisions().get(0);
    assertThat(main.getMaterial(), is(svn));
    assertThat(main.getModifications().size(), is(1));
    assertThat(main.getRevision().getRevision(), is("5"));
    MaterialRevision external = materialRevisions.getRevisions().get(1);
    assertThat(external.getMaterial(), is(svnExt));
    assertThat(external.getRevision().getRevision(), is("4"));
    assertThat(external.getModifications().size(), is(1));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Materials(com.thoughtworks.go.config.materials.Materials) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Test(org.junit.Test)

Example 24 with MaterialRevision

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

the class SvnExternalTest method shouldGetLatestRevisionFromExpandedSvnExternalRepository.

@Test
public void shouldGetLatestRevisionFromExpandedSvnExternalRepository() {
    MaterialRevisions materialRevisions = new MaterialRevisions();
    Material svnExt = svnMaterial(svnRepo.externalRepositoryUrl(), "end2end");
    List<Modification> modifications = ((SvnMaterial) svnExt).latestModification(svnRepo.workingFolder(), new TestSubprocessExecutionContext());
    materialRevisions.addRevision(svnExt, modifications);
    assertThat(materialRevisions.numberOfRevisions(), is(1));
    MaterialRevision materialRevision = materialRevisions.getRevisions().get(0);
    assertThat(materialRevision.getMaterial(), is(svnExt));
    assertThat(materialRevision.getRevision().getRevision(), is("4"));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Material(com.thoughtworks.go.domain.materials.Material) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) MaterialsMother.svnMaterial(com.thoughtworks.go.helper.MaterialsMother.svnMaterial) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Test(org.junit.Test)

Example 25 with MaterialRevision

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

the class StageConverter method createBuildCause.

private ArrayList<StageNotificationDTO.MaterialRevisionDTO> createBuildCause(BuildCause buildCause) {
    ArrayList<StageNotificationDTO.MaterialRevisionDTO> revisions = new ArrayList<>();
    for (MaterialRevision currentRevision : buildCause.getMaterialRevisions()) {
        Map<String, Object> attributes = currentRevision.getMaterial().getAttributes(false);
        ArrayList<StageNotificationDTO.ModificationDTO> modifications = new ArrayList<>();
        for (Modification modification : currentRevision.getModifications()) {
            modifications.add(new StageNotificationDTO.ModificationDTO(modification.getRevision(), modification.getModifiedTime(), modification.getAdditionalDataMap()));
        }
        revisions.add(new StageNotificationDTO.MaterialRevisionDTO(attributes, currentRevision.isChanged(), modifications));
    }
    return revisions;
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) ArrayList(java.util.ArrayList) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision)

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