Search in sources :

Example 51 with PluggableSCMMaterial

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

the class PluggableSCMMaterialTest method shouldPassEqualsCheckIfFingerprintIsSame.

@Test
public void shouldPassEqualsCheckIfFingerprintIsSame() {
    PluggableSCMMaterial material1 = MaterialsMother.pluggableSCMMaterial();
    material1.setName(new CaseInsensitiveString("name1"));
    PluggableSCMMaterial material2 = MaterialsMother.pluggableSCMMaterial();
    material2.setName(new CaseInsensitiveString("name2"));
    assertThat(material1.equals(material2), is(true));
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 52 with PluggableSCMMaterial

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

the class PluggableSCMMaterialTest method shouldReturnWorkingDirectoryCorrectly.

@Test
public void shouldReturnWorkingDirectoryCorrectly() {
    PluggableSCMMaterial material = new PluggableSCMMaterial();
    material.setFolder("dest");
    String baseFolder = new File(System.getProperty("java.io.tmpdir")).getAbsolutePath();
    String workingFolder = new File(baseFolder, "dest").getAbsolutePath();
    assertThat(material.workingDirectory(new File(baseFolder)).getAbsolutePath(), is(workingFolder));
    material.setFolder(null);
    assertThat(material.workingDirectory(new File(baseFolder)).getAbsolutePath(), is(baseFolder));
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) File(java.io.File) Test(org.junit.Test)

Example 53 with PluggableSCMMaterial

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

the class PluggableSCMMaterialTest method shouldGetAttributesForXml.

@Test
public void shouldGetAttributesForXml() {
    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);
    Map<String, Object> attributesForXml = material.getAttributesForXml();
    assertThat(attributesForXml.get("type").toString(), is(PluggableSCMMaterial.class.getSimpleName()));
    assertThat(attributesForXml.get("scmName").toString(), is("scm-name"));
}
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 54 with PluggableSCMMaterial

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

the class PluggableSCMMaterialTest method shouldFailEqualsCheckIfFingerprintDiffers.

@Test
public void shouldFailEqualsCheckIfFingerprintDiffers() {
    PluggableSCMMaterial material1 = MaterialsMother.pluggableSCMMaterial();
    material1.getScmConfig().getConfiguration().first().setConfigurationValue(new ConfigurationValue("new-url"));
    PluggableSCMMaterial material2 = MaterialsMother.pluggableSCMMaterial();
    assertThat(material1.equals(material2), is(false));
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) Test(org.junit.Test)

Example 55 with PluggableSCMMaterial

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

the class MaterialAgentFactoryTest method shouldGetPluggableSCMMaterialAgent.

@Test
public void shouldGetPluggableSCMMaterialAgent() {
    File workingDirectory = new File("/tmp/workingDirectory");
    MaterialRevision revision = new MaterialRevision(new PluggableSCMMaterial(), new Modifications());
    MaterialAgentFactory factory = new MaterialAgentFactory(null, workingDirectory, null, packageRepositoryExtension, scmExtension);
    MaterialAgent agent = factory.createAgent(revision);
    assertThat(agent instanceof PluggableSCMMaterialAgent, is(true));
    assertThat(ReflectionUtil.getField(agent, "scmExtension"), is(scmExtension));
    assertThat(ReflectionUtil.getField(agent, "revision"), is(revision));
    assertThat(ReflectionUtil.getField(agent, "workingDirectory"), is(workingDirectory));
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) PluggableSCMMaterialAgent(com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialAgent) 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)

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