Search in sources :

Example 46 with PluggableSCMMaterial

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

the class PluggableSCMMaterialTest method shouldGetUriForDisplayNameIfNameIsNull.

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

Example 47 with PluggableSCMMaterial

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

the class PluggableSCMMaterialTest method shouldGetJsonRepresentationForPluggableSCMMaterial.

@Test
public void shouldGetJsonRepresentationForPluggableSCMMaterial() {
    ConfigurationProperty k1 = create("k1", false, "v1");
    SCM scmConfig = SCMMother.create("scm-id", "scm-name", "pluginid", "version", new Configuration(k1));
    PluggableSCMMaterial material = new PluggableSCMMaterial();
    material.setSCMConfig(scmConfig);
    material.setFolder("folder");
    Map<String, String> jsonMap = new LinkedHashMap<>();
    material.toJson(jsonMap, new PluggableSCMMaterialRevision("rev123", new Date()));
    assertThat(jsonMap.get("scmType"), is("SCM"));
    assertThat(jsonMap.get("materialName"), is("scm-name"));
    assertThat(jsonMap.get("location"), is(material.getUriForDisplay()));
    assertThat(jsonMap.get("folder"), is("folder"));
    assertThat(jsonMap.get("action"), is("Modified"));
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) PluggableSCMMaterialRevision(com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialRevision) SCM(com.thoughtworks.go.domain.scm.SCM) Date(java.util.Date) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 48 with PluggableSCMMaterial

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

the class PluggableSCMMaterialTest method shouldGetEmailContentForPluggableSCMMaterial.

@Test
public void shouldGetEmailContentForPluggableSCMMaterial() {
    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);
    StringBuilder content = new StringBuilder();
    Date date = new Date(1367472329111L);
    material.emailContent(content, new Modification(null, "comment", null, date, "rev123"));
    assertThat(content.toString(), is(String.format("SCM : scm-name\nrevision: rev123, completed on %s\ncomment", date.toString())));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) SCM(com.thoughtworks.go.domain.scm.SCM) Date(java.util.Date) Test(org.junit.Test)

Example 49 with PluggableSCMMaterial

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

the class PluggableSCMMaterialTest method createPluggableSCMMaterialWithSecureConfiguration.

private PluggableSCMMaterial createPluggableSCMMaterialWithSecureConfiguration() {
    PluggableSCMMaterial material = MaterialsMother.pluggableSCMMaterial();
    material.getScmConfig().getConfiguration().get(1).handleSecureValueConfiguration(true);
    return material;
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial)

Example 50 with PluggableSCMMaterial

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

the class PluggableSCMMaterialTest method shouldReturnSomethingMoreSaneForToString.

@Test
public void shouldReturnSomethingMoreSaneForToString() throws Exception {
    PluggableSCMMaterial material = MaterialsMother.pluggableSCMMaterial();
    SCMMetadataStore.getInstance().addMetadataFor(material.getPluginId(), new SCMConfigurations(), null);
    assertThat(material.toString(), is("'PluggableSCMMaterial{[k1=v1, k2=v2]}'"));
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) SCMConfigurations(com.thoughtworks.go.plugin.access.scm.SCMConfigurations) Test(org.junit.Test)

Aggregations

PluggableSCMMaterial (com.thoughtworks.go.config.materials.PluggableSCMMaterial)64 Test (org.junit.Test)55 SCM (com.thoughtworks.go.domain.scm.SCM)25 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 PackageMaterial (com.thoughtworks.go.config.materials.PackageMaterial)6 SCMRevision (com.thoughtworks.go.plugin.access.scm.revision.SCMRevision)6 Map (java.util.Map)6 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