use of com.thoughtworks.go.config.materials.PackageMaterial in project gocd by gocd.
the class PackageMaterialUpdaterIntegrationTest method shouldUpdateMaterialInstanceWhenPluginIsUpgraded.
@Test
public void shouldUpdateMaterialInstanceWhenPluginIsUpgraded() throws Exception {
final PackageMaterial material = MaterialsMother.packageMaterial();
final MaterialInstance materialInstance = material.createMaterialInstance();
materialRepository.saveOrUpdate(materialInstance);
addMetadata(material, "fieldX", false);
material.getPackageDefinition().getConfiguration().addNewConfiguration("fieldX", true);
final List<Modification> modifications = ModificationsMother.multipleModificationList();
doNothing().when(scmMaterialUpdater).insertLatestOrNewModifications(material, materialInstance, new File(""), new Modifications(modifications));
transactionTemplate.execute(new TransactionCallback() {
@Override
public Object doInTransaction(TransactionStatus transactionStatus) {
packageMaterialUpdater.insertLatestOrNewModifications(material, materialInstance, new File(""), new Modifications(modifications));
return null;
}
});
MaterialInstance actualInstance = materialRepository.findMaterialInstance(material);
assertThat(actualInstance.getConfiguration(), is(material.createMaterialInstance().getConfiguration()));
}
use of com.thoughtworks.go.config.materials.PackageMaterial in project gocd by gocd.
the class FaninDependencyResolutionTest method shouldResolveTriangleDependencyWithPackageMaterial.
@Test
public void shouldResolveTriangleDependencyWithPackageMaterial() {
/*
+---> P1 ---+
| v
pkg1-------> P2
*/
int i = 1;
PackageMaterial pkg1 = MaterialsMother.packageMaterial();
u.addPackageDefinition((PackageMaterialConfig) pkg1.config());
String[] pkg_revs1 = { "pkg1-1", "pkg1-2" };
u.checkinInOrder(pkg1, u.d(i++), pkg_revs1);
ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("p1", u.m(pkg1));
ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("p2", u.m(pkg1), u.m(p1));
String p1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "pkg1-1");
String p2_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "pkg1-1", p1_1);
MaterialRevisions given = u.mrs(u.mr(pkg1, true, "pkg1-2"), u.mr(p1, true, p1_1));
MaterialRevisions expected = u.mrs(u.mr(pkg1, true, "pkg1-1"), u.mr(p1, true, p1_1));
assertThat(getRevisionsBasedOnDependencies(p2, goConfigDao.load(), given), is(expected));
}
use of com.thoughtworks.go.config.materials.PackageMaterial in project gocd by gocd.
the class PackageMaterialInstance method toOldMaterial.
@Override
public Material toOldMaterial(String name, String folder, String password) {
PackageMaterial packageMaterial = JsonHelper.fromJson(configuration, PackageMaterial.class);
packageMaterial.setName(new CaseInsensitiveString(name));
packageMaterial.setId(id);
packageMaterial.setFingerprint(getFingerprint());
return packageMaterial;
}
use of com.thoughtworks.go.config.materials.PackageMaterial in project gocd by gocd.
the class PackageMaterialInstanceTest method shouldCorrectlyCopyConfigurationValue.
@Test
public void shouldCorrectlyCopyConfigurationValue() {
PackageMaterialInstance packageMaterialInstance = (PackageMaterialInstance) MaterialsMother.packageMaterial().createMaterialInstance();
packageMaterialInstance.setId(10L);
PackageMaterial latestMaterial = MaterialsMother.packageMaterial("repo-id", "name", "pkId", "name", ConfigurationPropertyMother.create("key1", false, "value1"));
PackageMaterialInstance newPackageMaterialInstance = (PackageMaterialInstance) latestMaterial.createMaterialInstance();
packageMaterialInstance.upgradeTo(newPackageMaterialInstance);
assertThat(packageMaterialInstance.getId(), is(10L));
assertThat(packageMaterialInstance.getConfiguration(), is(newPackageMaterialInstance.getConfiguration()));
}
use of com.thoughtworks.go.config.materials.PackageMaterial in project gocd by gocd.
the class PackageMaterialInstanceTest method shouldTestEqualsBasedOnConfiguration.
@Test
public void shouldTestEqualsBasedOnConfiguration() {
PackageMaterial material = MaterialsMother.packageMaterial("repo-id", "repo-name", "pkg-id", "pkg-name", ConfigurationPropertyMother.create("key1", false, "value1"));
MaterialInstance materialInstance = material.createMaterialInstance();
MaterialInstance materialInstanceCopy = material.createMaterialInstance();
material.getPackageDefinition().getConfiguration().add(ConfigurationPropertyMother.create("key2", false, "value2"));
MaterialInstance newMaterialInstance = material.createMaterialInstance();
assertThat(materialInstance, is(materialInstanceCopy));
assertThat(materialInstance, is(not(newMaterialInstance)));
}
Aggregations