use of com.thoughtworks.go.config.materials.PluggableSCMMaterial in project gocd by gocd.
the class PluggableSCMMaterialUpdaterTest method shouldNotUpdateMaterialInstanceWhenConfigHas_NOT_Changed.
@Test
public void shouldNotUpdateMaterialInstanceWhenConfigHas_NOT_Changed() throws Exception {
PluggableSCMMaterial material = MaterialsMother.pluggableSCMMaterial();
MaterialInstance materialInstance = material.createMaterialInstance();
File file = new File("random");
Modifications modifications = new Modifications();
materialUpdater.insertLatestOrNewModifications(material, materialInstance, file, modifications);
verify(materialRepository, never()).saveOrUpdate(Matchers.<MaterialInstance>any());
verify(scmMaterialUpdater).insertLatestOrNewModifications(material, materialInstance, file, modifications);
}
use of com.thoughtworks.go.config.materials.PluggableSCMMaterial in project gocd by gocd.
the class PluggableSCMPostCommitHookImplementerTest method shouldReturnListOfMaterialMatchingTheSCMNameWithCaseInsensitivity.
@Test
public void shouldReturnListOfMaterialMatchingTheSCMNameWithCaseInsensitivity() throws Exception {
PluggableSCMMaterial material1 = new PluggableSCMMaterial(MaterialConfigsMother.pluggableSCMMaterialConfig("material-1", null, null));
PluggableSCMMaterial material2 = new PluggableSCMMaterial(MaterialConfigsMother.pluggableSCMMaterialConfig("material-2", null, null));
PluggableSCMMaterial material3 = new PluggableSCMMaterial(MaterialConfigsMother.pluggableSCMMaterialConfig("material-3", null, null));
PluggableSCMMaterial material4 = new PluggableSCMMaterial(MaterialConfigsMother.pluggableSCMMaterialConfig("material-4", null, null));
Set<Material> materials = new HashSet<>(Arrays.asList(material1, material2, material3, material4));
Map params = new HashMap();
params.put(PluggableSCMPostCommitHookImplementer.SCM_NAME, "SCM-MATERIAL-1");
Set<Material> actual = implementer.prune(materials, params);
assertThat(actual.size(), is(1));
assertThat(actual, hasItem(material1));
}
use of com.thoughtworks.go.config.materials.PluggableSCMMaterial in project gocd by gocd.
the class MaterialRepositoryIntegrationTest method shouldSavePluggableSCMMaterialInstance.
@Test
public void shouldSavePluggableSCMMaterialInstance() {
PluggableSCMMaterial material = new PluggableSCMMaterial();
ConfigurationProperty k1 = ConfigurationPropertyMother.create("k1", false, "v1");
ConfigurationProperty k2 = ConfigurationPropertyMother.create("k2", true, "v2");
material.setSCMConfig(SCMMother.create("scm-id", "scm-name", "plugin-id", "1.0", new Configuration(k1, k2)));
PluggableSCMMaterialInstance savedMaterialInstance = (PluggableSCMMaterialInstance) repo.findOrCreateFrom(material);
assertThat(savedMaterialInstance.getId() > 0, is(true));
assertThat(savedMaterialInstance.getFingerprint(), is(material.getFingerprint()));
assertThat(JsonHelper.fromJson(savedMaterialInstance.getConfiguration(), PluggableSCMMaterial.class).getScmConfig().getConfiguration(), is(material.getScmConfig().getConfiguration()));
assertThat(JsonHelper.fromJson(savedMaterialInstance.getConfiguration(), PluggableSCMMaterial.class).getScmConfig().getPluginConfiguration().getId(), is(material.getScmConfig().getPluginConfiguration().getId()));
}
use of com.thoughtworks.go.config.materials.PluggableSCMMaterial in project gocd by gocd.
the class PluggableSCMMaterialInstanceTest method shouldTestEqualsBasedOnConfiguration.
@Test
public void shouldTestEqualsBasedOnConfiguration() {
PluggableSCMMaterial material = MaterialsMother.pluggableSCMMaterial("scm-id", "scm-name", ConfigurationPropertyMother.create("key1", false, "value1"));
MaterialInstance materialInstance = material.createMaterialInstance();
MaterialInstance materialInstanceCopy = material.createMaterialInstance();
material.getScmConfig().getConfiguration().add(ConfigurationPropertyMother.create("key2", false, "value2"));
MaterialInstance newMaterialInstance = material.createMaterialInstance();
assertThat(materialInstance, is(materialInstanceCopy));
assertThat(materialInstance, is(not(newMaterialInstance)));
}
use of com.thoughtworks.go.config.materials.PluggableSCMMaterial in project gocd by gocd.
the class PluggableSCMMaterialInstanceTest method shouldCorrectlyCheckIfUpgradeIsNecessary.
@Test
public void shouldCorrectlyCheckIfUpgradeIsNecessary() {
PluggableSCMMaterial material = MaterialsMother.pluggableSCMMaterial("scm-id", "scm-name", ConfigurationPropertyMother.create("key1", false, "value1"));
PluggableSCMMaterialInstance materialInstance = (PluggableSCMMaterialInstance) material.createMaterialInstance();
materialInstance.setId(10L);
PluggableSCMMaterialInstance materialInstanceCopy = (PluggableSCMMaterialInstance) material.createMaterialInstance();
material.getScmConfig().getConfiguration().add(ConfigurationPropertyMother.create("key2", false, "value2"));
PluggableSCMMaterialInstance newMaterialInstance = (PluggableSCMMaterialInstance) material.createMaterialInstance();
assertThat(materialInstance.shouldUpgradeTo(materialInstanceCopy), is(false));
assertThat(materialInstance.shouldUpgradeTo(newMaterialInstance), is(true));
}
Aggregations