use of com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialInstance 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.domain.materials.scm.PluggableSCMMaterialInstance in project gocd by gocd.
the class PluggableSCMMaterialUpdater method insertLatestOrNewModifications.
@Override
public void insertLatestOrNewModifications(final Material material, MaterialInstance materialInstance, File folder, Modifications list) {
final PluggableSCMMaterialInstance currentMaterialInstance = (PluggableSCMMaterialInstance) materialInstance;
final PluggableSCMMaterialInstance latestMaterialInstance = (PluggableSCMMaterialInstance) material.createMaterialInstance();
if (currentMaterialInstance.shouldUpgradeTo(latestMaterialInstance)) {
transactionTemplate.execute((TransactionCallback) transactionStatus -> {
PluggableSCMMaterialInstance materialInstance1 = (PluggableSCMMaterialInstance) materialRepository.find(currentMaterialInstance.getId());
materialInstance1.upgradeTo(latestMaterialInstance);
materialRepository.saveOrUpdate(materialInstance1);
return materialInstance1;
});
}
scmMaterialUpdater.insertLatestOrNewModifications(material, currentMaterialInstance, folder, list);
}
use of com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialInstance in project gocd by gocd.
the class PluggableSCMMaterialTest method shouldCreatePluggableSCMMaterialInstance.
@Test
void shouldCreatePluggableSCMMaterialInstance() {
PluggableSCMMaterial material = MaterialsMother.pluggableSCMMaterial();
PluggableSCMMaterialInstance materialInstance = (PluggableSCMMaterialInstance) material.createMaterialInstance();
assertThat(materialInstance).isNotNull();
assertThat(materialInstance.getFlyweightName()).isNotNull();
assertThat(materialInstance.getConfiguration()).isEqualTo(JsonHelper.toJsonString(material));
}
Aggregations