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()));
}
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;
}
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));
}
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);
}
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);
}
Aggregations