Search in sources :

Example 6 with MaterialRevision

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

the class PluggableSCMMaterialTest method shouldPopulateEnvironmentContext.

@Test
public void shouldPopulateEnvironmentContext() {
    ConfigurationProperty k1 = ConfigurationPropertyMother.create("k1", false, "v1");
    ConfigurationProperty k2 = ConfigurationPropertyMother.create("scm-secure", true, "value");
    SCM scmConfig = SCMMother.create("scm-id", "tw-dev", "pluginid", "version", new Configuration(k1, k2));
    PluggableSCMMaterial material = new PluggableSCMMaterial();
    material.setSCMConfig(scmConfig);
    material.setName(new CaseInsensitiveString("tw-dev:go-agent"));
    Modifications modifications = new Modifications(new Modification(null, null, null, new Date(), "revision-123"));
    EnvironmentVariableContext environmentVariableContext = new EnvironmentVariableContext();
    material.populateEnvironmentContext(environmentVariableContext, new MaterialRevision(material, modifications), null);
    assertThat(environmentVariableContext.getProperty("GO_SCM_TW_DEV_GO_AGENT_K1"), is("v1"));
    assertThat(environmentVariableContext.getProperty("GO_SCM_TW_DEV_GO_AGENT_SCM_SECURE"), is("value"));
    assertThat(environmentVariableContext.getPropertyForDisplay("GO_SCM_TW_DEV_GO_AGENT_SCM_SECURE"), is(EnvironmentVariableContext.EnvironmentVariable.MASK_VALUE));
    assertThat(environmentVariableContext.getProperty("GO_SCM_TW_DEV_GO_AGENT_LABEL"), is("revision-123"));
}
Also used : Modifications(com.thoughtworks.go.domain.materials.Modifications) Modification(com.thoughtworks.go.domain.materials.Modification) PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) SCM(com.thoughtworks.go.domain.scm.SCM) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) PluggableSCMMaterialRevision(com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialRevision) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Date(java.util.Date) Test(org.junit.Test)

Example 7 with MaterialRevision

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

the class PluggableSCMMaterialTest method shouldPopulateEnvironmentContextWithEnvironmentVariablesCreatedOutOfAdditionalDataFromModification.

@Test
public void shouldPopulateEnvironmentContextWithEnvironmentVariablesCreatedOutOfAdditionalDataFromModification() {
    ConfigurationProperty k1 = ConfigurationPropertyMother.create("k1", false, "v1");
    SCM scmConfig = SCMMother.create("scm-id", "tw-dev", "pluginid", "version", new Configuration(k1));
    PluggableSCMMaterial material = new PluggableSCMMaterial();
    material.setSCMConfig(scmConfig);
    material.setName(new CaseInsensitiveString("tw-dev:go-agent"));
    HashMap<String, String> map = new HashMap<>();
    map.put("MY_NEW_KEY", "my_value");
    Modification modification = new Modification("loser", "comment", "email", new Date(), "revision-123", JsonHelper.toJsonString(map));
    Modifications modifications = new Modifications(modification);
    EnvironmentVariableContext environmentVariableContext = new EnvironmentVariableContext();
    material.populateEnvironmentContext(environmentVariableContext, new MaterialRevision(material, modifications), null);
    assertThat(environmentVariableContext.getProperty("GO_SCM_TW_DEV_GO_AGENT_LABEL"), is("revision-123"));
    assertThat(environmentVariableContext.getProperty("GO_SCM_TW_DEV_GO_AGENT_K1"), is("v1"));
    assertThat(environmentVariableContext.getProperty("GO_SCM_TW_DEV_GO_AGENT_MY_NEW_KEY"), is("my_value"));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Date(java.util.Date) Modifications(com.thoughtworks.go.domain.materials.Modifications) SCM(com.thoughtworks.go.domain.scm.SCM) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) PluggableSCMMaterialRevision(com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialRevision) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Test(org.junit.Test)

Example 8 with MaterialRevision

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

the class SvnMultipleMaterialsTest method shouldDetectLatestModifications.

@Test
public void shouldDetectLatestModifications() throws Exception {
    SvnMaterial svnMaterial1 = repo.createMaterial("multiple-materials/trunk/part1", "part1");
    SvnMaterial svnMaterial2 = repo.createMaterial("multiple-materials/trunk/part2", "part2");
    Materials materials = new Materials(svnMaterial1, svnMaterial2);
    MaterialRevisions materialRevisions = materials.latestModification(pipelineDir, new TestSubprocessExecutionContext());
    MaterialRevision revision1 = materialRevisions.getMaterialRevision(0);
    assertThat(revision1.getRevision(), is(latestRevision(svnMaterial1, pipelineDir, new TestSubprocessExecutionContext())));
    MaterialRevision revision2 = materialRevisions.getMaterialRevision(1);
    assertThat(revision2.getRevision(), is(latestRevision(svnMaterial2, pipelineDir, new TestSubprocessExecutionContext())));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Materials(com.thoughtworks.go.config.materials.Materials) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Test(org.junit.Test)

Example 9 with MaterialRevision

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

the class FetchTaskTest method buildCauseWithDependencyMaterial.

private BuildCause buildCauseWithDependencyMaterial(String upstreamPipelineName, int upstreamPipelineCounter, String upstreamPipelineLabel, String upstreamStageName, int upstreamStageCounter) {
    BuildCause buildCause = BuildCause.createWithEmptyModifications();
    MaterialRevisions materialRevisions = new MaterialRevisions();
    DependencyMaterialRevision materialRevision = DependencyMaterialRevision.create(upstreamPipelineName, upstreamPipelineCounter, upstreamPipelineLabel, upstreamStageName, upstreamStageCounter);
    MaterialRevision withRevision = materialRevision.convert(new DependencyMaterial(new CaseInsensitiveString(upstreamPipelineName), new CaseInsensitiveString(upstreamStageName)), new Date());
    materialRevisions.addRevision(withRevision);
    buildCause.setMaterialRevisions(materialRevisions);
    return buildCause;
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Date(java.util.Date) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause)

Example 10 with MaterialRevision

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

the class HgMultipleMaterialsTest method shouldCloneMaterialToItsDestFolder.

@Test
public void shouldCloneMaterialToItsDestFolder() throws Exception {
    HgMaterial material1 = repo.createMaterial("dest1");
    MaterialRevision materialRevision = new MaterialRevision(material1, material1.latestModification(pipelineDir, new TestSubprocessExecutionContext()));
    materialRevision.updateTo(pipelineDir, ProcessOutputStreamConsumer.inMemoryConsumer(), new TestSubprocessExecutionContext());
    assertThat(new File(pipelineDir, "dest1").exists(), is(true));
    assertThat(new File(pipelineDir, "dest1/.hg").exists(), is(true));
}
Also used : TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) File(java.io.File) 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