Search in sources :

Example 6 with PluggableSCMMaterial

use of com.thoughtworks.go.config.materials.PluggableSCMMaterial 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 7 with PluggableSCMMaterial

use of com.thoughtworks.go.config.materials.PluggableSCMMaterial in project gocd by gocd.

the class PluggableSCMMaterialTest method shouldNotCalculateFingerprintWhenAvailable.

@Test
public void shouldNotCalculateFingerprintWhenAvailable() {
    String fingerprint = "fingerprint";
    SCM scmConfig = mock(SCM.class);
    PluggableSCMMaterial pluggableSCMMaterial = new PluggableSCMMaterial();
    pluggableSCMMaterial.setSCMConfig(scmConfig);
    pluggableSCMMaterial.setFingerprint(fingerprint);
    assertThat(pluggableSCMMaterial.getFingerprint(), is(fingerprint));
    verify(scmConfig, never()).getFingerprint();
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) SCM(com.thoughtworks.go.domain.scm.SCM) Test(org.junit.Test)

Example 8 with PluggableSCMMaterial

use of com.thoughtworks.go.config.materials.PluggableSCMMaterial in project gocd by gocd.

the class PluggableSCMMaterialTest method shouldGetAttributesWithoutSecureFields.

@Test
public void shouldGetAttributesWithoutSecureFields() {
    PluggableSCMMaterial material = createPluggableSCMMaterialWithSecureConfiguration();
    Map<String, Object> attributes = material.getAttributes(false);
    assertThat(attributes.get("type"), is("scm"));
    assertThat(attributes.get("plugin-id"), is("pluginid"));
    Map<String, Object> configuration = (Map<String, Object>) attributes.get("scm-configuration");
    assertThat(configuration.get("k1"), is("v1"));
    assertThat(configuration.get("k2"), is(nullValue()));
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Test(org.junit.Test)

Example 9 with PluggableSCMMaterial

use of com.thoughtworks.go.config.materials.PluggableSCMMaterial in project gocd by gocd.

the class PluggableSCMMaterialTest method shouldGetDescription.

@Test
public void shouldGetDescription() {
    ConfigurationProperty k1 = ConfigurationPropertyMother.create("k1", false, "v1");
    SCM scmConfig = SCMMother.create("scm-id", "scm-name", "pluginid", "version", new Configuration(k1));
    PluggableSCMMaterial material = new PluggableSCMMaterial();
    material.setSCMConfig(scmConfig);
    assertThat(material.getDescription(), is("scm-name"));
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) SCM(com.thoughtworks.go.domain.scm.SCM) Test(org.junit.Test)

Example 10 with PluggableSCMMaterial

use of com.thoughtworks.go.config.materials.PluggableSCMMaterial in project gocd by gocd.

the class PluggableSCMMaterialTest method shouldReturnTrueForPluggableScmMaterial_supportsDestinationFolder.

@Test
public void shouldReturnTrueForPluggableScmMaterial_supportsDestinationFolder() throws Exception {
    PluggableSCMMaterial material = new PluggableSCMMaterial();
    assertThat(material.supportsDestinationFolder(), is(true));
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) Test(org.junit.Test)

Aggregations

PluggableSCMMaterial (com.thoughtworks.go.config.materials.PluggableSCMMaterial)63 Test (org.junit.Test)55 SCM (com.thoughtworks.go.domain.scm.SCM)24 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)18 File (java.io.File)13 Modification (com.thoughtworks.go.domain.materials.Modification)11 Modifications (com.thoughtworks.go.domain.materials.Modifications)10 Date (java.util.Date)10 MaterialInstance (com.thoughtworks.go.domain.MaterialInstance)9 HashMap (java.util.HashMap)8 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)7 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)7 PluggableSCMMaterialRevision (com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialRevision)7 SCMRevision (com.thoughtworks.go.plugin.access.scm.revision.SCMRevision)6 Map (java.util.Map)6 PackageMaterial (com.thoughtworks.go.config.materials.PackageMaterial)5 Material (com.thoughtworks.go.domain.materials.Material)5 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)5 LinkedHashMap (java.util.LinkedHashMap)5 SCMPropertyConfiguration (com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration)4