Search in sources :

Example 76 with MaterialRevision

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

the class MaterialAgentFactoryTest method shouldCreateMaterialAgent_withAgentsUuidAsSubprocessExecutionContextNamespace.

@Test
public void shouldCreateMaterialAgent_withAgentsUuidAsSubprocessExecutionContextNamespace() throws IOException {
    String agentUuid = "uuid-01783738";
    File workingDirectory = temporaryFolder.newFolder();
    MaterialAgentFactory factory = new MaterialAgentFactory(new ProcessOutputStreamConsumer(new DevNull(), new DevNull()), workingDirectory, new AgentIdentifier("host", "1.1.1.1", agentUuid), packageRepositoryExtension, scmExtension);
    GitMaterial gitMaterial = new GitMaterial("http://foo", "master", "dest_folder");
    MaterialAgent agent = factory.createAgent(new MaterialRevision(gitMaterial));
    assertThat(agent, is(instanceOf(AbstractMaterialAgent.class)));
    SubprocessExecutionContext execCtx = (SubprocessExecutionContext) ReflectionUtil.getField(agent, "execCtx");
    assertThat(execCtx.getProcessNamespace("fingerprint"), is(CachedDigestUtils.sha256Hex(String.format("%s%s%s", "fingerprint", agentUuid, gitMaterial.workingdir(workingDirectory)))));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) DevNull(com.thoughtworks.go.util.command.DevNull) SubprocessExecutionContext(com.thoughtworks.go.config.materials.SubprocessExecutionContext) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) PluggableSCMMaterialAgent(com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialAgent) PackageMaterialAgent(com.thoughtworks.go.domain.materials.packagematerial.PackageMaterialAgent) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) File(java.io.File) ProcessOutputStreamConsumer(com.thoughtworks.go.util.command.ProcessOutputStreamConsumer) Test(org.junit.Test)

Example 77 with MaterialRevision

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

the class MaterialAgentFactoryTest method shouldGetPackageMaterialAgent.

@Test
public void shouldGetPackageMaterialAgent() {
    File workingDirectory = new File("/tmp/workingDirectory");
    MaterialRevision revision = new MaterialRevision(new PackageMaterial(), new Modifications());
    MaterialAgentFactory factory = new MaterialAgentFactory(null, workingDirectory, null, packageRepositoryExtension, scmExtension);
    MaterialAgent agent = factory.createAgent(revision);
    assertThat(agent instanceof PackageMaterialAgent, is(true));
    assertThat(ReflectionUtil.getField(agent, "packageRepositoryExtension"), is(packageRepositoryExtension));
    assertThat(ReflectionUtil.getField(agent, "revision"), is(revision));
    assertThat(ReflectionUtil.getField(agent, "workingDirectory"), is(workingDirectory));
}
Also used : PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) PackageMaterialAgent(com.thoughtworks.go.domain.materials.packagematerial.PackageMaterialAgent) PluggableSCMMaterialAgent(com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialAgent) PackageMaterialAgent(com.thoughtworks.go.domain.materials.packagematerial.PackageMaterialAgent) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) File(java.io.File) Test(org.junit.Test)

Example 78 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)

Example 79 with MaterialRevision

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

the class P4MultipleMaterialsTest method shouldUpdateToItsDestFolder.

@Test
public void shouldUpdateToItsDestFolder() {
    P4Material p4Material = p4Fixture.material(VIEW_SRC, "dest1");
    MaterialRevision revision = new MaterialRevision(p4Material, p4Material.latestModification(clientFolder, new TestSubprocessExecutionContext()));
    revision.updateTo(clientFolder, inMemoryConsumer(), new TestSubprocessExecutionContext());
    assertThat(new File(clientFolder, "dest1/net").exists(), is(true));
}
Also used : TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) MaterialRevisionsMatchers.containsModifiedFile(com.thoughtworks.go.config.MaterialRevisionsMatchers.containsModifiedFile) File(java.io.File) Test(org.junit.Test)

Example 80 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)

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