Search in sources :

Example 31 with PluggableSCMMaterial

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

the class PluggableSCMMaterialInstanceTest method shouldConvertMaterialInstanceToMaterial.

@Test
public void shouldConvertMaterialInstanceToMaterial() {
    PluggableSCMMaterial material = MaterialsMother.pluggableSCMMaterial();
    SCM scmConfig = material.getScmConfig();
    PluggableSCMMaterialInstance materialInstance = new PluggableSCMMaterialInstance(JsonHelper.toJsonString(material), "flyweight");
    materialInstance.setId(1L);
    PluggableSCMMaterial constructedMaterial = (PluggableSCMMaterial) materialInstance.toOldMaterial(null, null, null);
    assertThat(constructedMaterial.getId(), is(1L));
    assertThat(constructedMaterial.getScmConfig().getPluginConfiguration().getId(), is(scmConfig.getPluginConfiguration().getId()));
    assertThat(constructedMaterial.getScmConfig().getConfiguration(), is(scmConfig.getConfiguration()));
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) SCM(com.thoughtworks.go.domain.scm.SCM) Test(org.junit.Test)

Example 32 with PluggableSCMMaterial

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

the class PluggableSCMMaterialInstanceTest method shouldCorrectlyCopyConfigurationValue.

@Test
public void shouldCorrectlyCopyConfigurationValue() {
    PluggableSCMMaterialInstance materialInstance = (PluggableSCMMaterialInstance) MaterialsMother.pluggableSCMMaterial().createMaterialInstance();
    materialInstance.setId(10L);
    PluggableSCMMaterial latestMaterial = MaterialsMother.pluggableSCMMaterial("scm-id", "scm-name", ConfigurationPropertyMother.create("key1", false, "value1"));
    PluggableSCMMaterialInstance newPluggableSCMMaterialInstance = (PluggableSCMMaterialInstance) latestMaterial.createMaterialInstance();
    materialInstance.upgradeTo(newPluggableSCMMaterialInstance);
    assertThat(materialInstance.getId(), is(10L));
    assertThat(materialInstance.getConfiguration(), is(newPluggableSCMMaterialInstance.getConfiguration()));
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) Test(org.junit.Test)

Example 33 with PluggableSCMMaterial

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

the class PluggableSCMMaterialTest method shouldGetUriForDisplay.

@Test
public void shouldGetUriForDisplay() {
    SCMMetadataStore.getInstance().addMetadataFor("some-plugin", new SCMConfigurations(), null);
    ConfigurationProperty k1 = ConfigurationPropertyMother.create("k1", false, "scm-v1");
    ConfigurationProperty k2 = ConfigurationPropertyMother.create("k2", false, "scm-v2");
    Configuration configuration = new Configuration(k1, k2);
    SCM scmConfig = SCMMother.create("scm-id", "scm-name", "some-plugin", "version", configuration);
    PluggableSCMMaterial material = new PluggableSCMMaterial();
    material.setSCMConfig(scmConfig);
    assertThat(material.getUriForDisplay(), is("[k1=scm-v1, k2=scm-v2]"));
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) SCMConfigurations(com.thoughtworks.go.plugin.access.scm.SCMConfigurations) SCM(com.thoughtworks.go.domain.scm.SCM) Test(org.junit.Test)

Example 34 with PluggableSCMMaterial

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

the class PluggableSCMMaterialTest method shouldGetDisplayName.

@Test
public void shouldGetDisplayName() {
    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.getDisplayName(), is("scm-name"));
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) SCM(com.thoughtworks.go.domain.scm.SCM) Test(org.junit.Test)

Example 35 with PluggableSCMMaterial

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

the class PluggableSCMMaterialTest method shouldTakeValueOfIsAutoUpdateFromSCMConfig.

@Test
public void shouldTakeValueOfIsAutoUpdateFromSCMConfig() throws Exception {
    PluggableSCMMaterial material = MaterialsMother.pluggableSCMMaterial();
    material.getScmConfig().setAutoUpdate(true);
    assertThat(material.isAutoUpdate(), is(true));
    material.getScmConfig().setAutoUpdate(false);
    assertThat(material.isAutoUpdate(), is(false));
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) 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