Search in sources :

Example 1 with PackageMaterial

use of com.thoughtworks.go.config.materials.PackageMaterial in project gocd by gocd.

the class MaterialRepositoryIntegrationTest method shouldSavePackageMaterialInstance.

@Test
public void shouldSavePackageMaterialInstance() {
    PackageMaterial material = new PackageMaterial();
    PackageRepository repository = PackageRepositoryMother.create("repo-id", "repo", "pluginid", "version", new Configuration(ConfigurationPropertyMother.create("k1", false, "v1")));
    material.setPackageDefinition(PackageDefinitionMother.create("p-id", "name", new Configuration(ConfigurationPropertyMother.create("k2", false, "v2")), repository));
    PackageMaterialInstance savedMaterialInstance = (PackageMaterialInstance) repo.findOrCreateFrom(material);
    assertThat(savedMaterialInstance.getId() > 0, is(true));
    assertThat(savedMaterialInstance.getFingerprint(), is(material.getFingerprint()));
    assertThat(JsonHelper.fromJson(savedMaterialInstance.getConfiguration(), PackageMaterial.class).getPackageDefinition().getConfiguration(), is(material.getPackageDefinition().getConfiguration()));
    assertThat(JsonHelper.fromJson(savedMaterialInstance.getConfiguration(), PackageMaterial.class).getPackageDefinition().getRepository().getPluginConfiguration().getId(), is(material.getPackageDefinition().getRepository().getPluginConfiguration().getId()));
    assertThat(JsonHelper.fromJson(savedMaterialInstance.getConfiguration(), PackageMaterial.class).getPackageDefinition().getRepository().getConfiguration(), is(material.getPackageDefinition().getRepository().getConfiguration()));
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) PackageMaterialInstance(com.thoughtworks.go.domain.materials.packagematerial.PackageMaterialInstance) Test(org.junit.Test)

Example 2 with PackageMaterial

use of com.thoughtworks.go.config.materials.PackageMaterial in project gocd by gocd.

the class JsonMessageHandler1_0_Test method createPipeline.

private Pipeline createPipeline() throws Exception {
    Pipeline pipeline = PipelineMother.pipelineWithAllTypesOfMaterials("pipeline-name", "stage-name", "job-name", "1");
    List<MaterialRevision> materialRevisions = pipeline.getMaterialRevisions().getRevisions();
    PackageDefinition packageDefinition = ((PackageMaterial) materialRevisions.get(6).getMaterial()).getPackageDefinition();
    packageDefinition.getRepository().getConfiguration().get(1).handleSecureValueConfiguration(true);
    packageDefinition.getConfiguration().addNewConfigurationWithValue("k4", "package-v2", false);
    packageDefinition.getConfiguration().get(1).handleSecureValueConfiguration(true);
    SCM scm = ((PluggableSCMMaterial) materialRevisions.get(7).getMaterial()).getScmConfig();
    scm.getConfiguration().get(1).handleSecureValueConfiguration(true);
    Stage stage = pipeline.getFirstStage();
    stage.setId(1L);
    stage.setPipelineId(1L);
    stage.setCreatedTime(new Timestamp(getFixedDate().getTime()));
    stage.setLastTransitionedTime(new Timestamp(getFixedDate().getTime()));
    JobInstance job = stage.getJobInstances().get(0);
    job.setScheduledDate(getFixedDate());
    job.getTransition(JobState.Completed).setStateChangeTime(getFixedDate());
    return pipeline;
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) SCM(com.thoughtworks.go.domain.scm.SCM) Timestamp(java.sql.Timestamp)

Example 3 with PackageMaterial

use of com.thoughtworks.go.config.materials.PackageMaterial in project gocd by gocd.

the class FaninDependencyResolutionTest method shouldResolveDiamondDependencyWithPackageMaterial.

@Test
public void shouldResolveDiamondDependencyWithPackageMaterial() {
    /*
            +---> P1 ---+
            |           v
           pkg1         P3
            |           ^
            +--> P2 ----+
        */
    int i = 1;
    PackageMaterial pkg1 = MaterialsMother.packageMaterial();
    u.addPackageDefinition((PackageMaterialConfig) pkg1.config());
    String[] pkg_revs = { "pkg1-1", "pkg1-2" };
    u.checkinInOrder(pkg1, u.d(i++), pkg_revs);
    ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("p1", u.m(pkg1));
    ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("p2", u.m(pkg1));
    ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("p3", u.m(p1), u.m(p2));
    String p1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "pkg1-1");
    String p2_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "pkg1-1");
    String p2_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "pkg1-2");
    MaterialRevisions given = u.mrs(u.mr(p1, true, p1_1), u.mr(p2, true, p2_2));
    MaterialRevisions expected = u.mrs(u.mr(p1, true, p1_1), u.mr(p2, true, p2_1));
    assertThat(getRevisionsBasedOnDependencies(p3, 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 4 with PackageMaterial

use of com.thoughtworks.go.config.materials.PackageMaterial in project gocd by gocd.

the class PackageMaterialUpdaterTest method shouldUpdateToNewMaterialInstanceWhenConfigHas_Changed.

@Test
public void shouldUpdateToNewMaterialInstanceWhenConfigHas_Changed() throws Exception {
    PackageMaterial material = MaterialsMother.packageMaterial();
    MaterialInstance materialInstance = material.createMaterialInstance();
    materialInstance.setId(1);
    material.getPackageDefinition().getConfiguration().add(ConfigurationPropertyMother.create("key2", false, "value2"));
    MaterialInstance newMaterialInstance = material.createMaterialInstance();
    newMaterialInstance.setId(1);
    File file = new File("random");
    Modifications modifications = new Modifications();
    when(materialRepository.find(anyLong())).thenReturn(materialInstance);
    materialUpdater.insertLatestOrNewModifications(material, materialInstance, file, modifications);
    verify(materialRepository).saveOrUpdate(newMaterialInstance);
    verify(scmMaterialUpdater).insertLatestOrNewModifications(material, materialInstance, file, modifications);
}
Also used : Modifications(com.thoughtworks.go.domain.materials.Modifications) PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) MaterialInstance(com.thoughtworks.go.domain.MaterialInstance) File(java.io.File) Test(org.junit.Test)

Example 5 with PackageMaterial

use of com.thoughtworks.go.config.materials.PackageMaterial in project gocd by gocd.

the class PackageMaterialUpdaterTest method shouldNotUpdateMaterialInstanceWhenConfigHas_NOT_Changed.

@Test
public void shouldNotUpdateMaterialInstanceWhenConfigHas_NOT_Changed() throws Exception {
    PackageMaterial material = MaterialsMother.packageMaterial();
    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);
}
Also used : Modifications(com.thoughtworks.go.domain.materials.Modifications) PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) MaterialInstance(com.thoughtworks.go.domain.MaterialInstance) File(java.io.File) 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