Search in sources :

Example 11 with PackageMaterial

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()));
}
Also used : Modifications(com.thoughtworks.go.domain.materials.Modifications) Modification(com.thoughtworks.go.domain.materials.Modification) TransactionCallback(org.springframework.transaction.support.TransactionCallback) PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) TransactionStatus(org.springframework.transaction.TransactionStatus) MaterialInstance(com.thoughtworks.go.domain.MaterialInstance) File(java.io.File) Test(org.junit.Test)

Example 12 with PackageMaterial

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));
}
Also used : PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 13 with PackageMaterial

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;
}
Also used : PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 14 with 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()));
}
Also used : PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) Test(org.junit.Test)

Example 15 with PackageMaterial

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)));
}
Also used : PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) MaterialInstance(com.thoughtworks.go.domain.MaterialInstance) Test(org.junit.Test)

Aggregations

PackageMaterial (com.thoughtworks.go.config.materials.PackageMaterial)23 Test (org.junit.Test)18 PackageDefinition (com.thoughtworks.go.domain.packagerepository.PackageDefinition)6 RepositoryConfiguration (com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration)5 File (java.io.File)5 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)4 MaterialInstance (com.thoughtworks.go.domain.MaterialInstance)4 Configuration (com.thoughtworks.go.domain.config.Configuration)4 Modification (com.thoughtworks.go.domain.materials.Modification)4 PackageRevision (com.thoughtworks.go.plugin.api.material.packagerepository.PackageRevision)4 PluggableSCMMaterial (com.thoughtworks.go.config.materials.PluggableSCMMaterial)3 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)3 Modifications (com.thoughtworks.go.domain.materials.Modifications)3 Date (java.util.Date)3 Materials (com.thoughtworks.go.config.materials.Materials)2 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)2 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)2 PackageMaterialRevision (com.thoughtworks.go.domain.materials.packagematerial.PackageMaterialRevision)2 PackageRepository (com.thoughtworks.go.domain.packagerepository.PackageRepository)2 SCM (com.thoughtworks.go.domain.scm.SCM)2