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()));
}
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()));
}
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]"));
}
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"));
}
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));
}
Aggregations