use of com.thoughtworks.go.domain.materials.Material in project gocd by gocd.
the class PipelineScheduleServiceTest method shouldScheduleStageAfterModifications.
@Test
public void shouldScheduleStageAfterModifications() throws Exception {
scheduleAndCompleteInitialPipelines();
Material stubMaterial = new TestingMaterial();
mingleConfig.setMaterialConfigs(new MaterialConfigs(stubMaterial.config()));
MaterialRevisions revisions = new MaterialRevisions();
revisions.addRevision(stubMaterial, ((TestingMaterial) stubMaterial).modificationsSince(null, null, subprocessExecutionContext));
BuildCause buildCause = BuildCause.createWithModifications(revisions, "");
dbHelper.saveMaterials(buildCause.getMaterialRevisions());
Pipeline pipeline = instanceFactory.createPipelineInstance(mingleConfig, buildCause, new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
pipelineService.save(pipeline);
verifyMingleScheduledWithModifications();
}
use of com.thoughtworks.go.domain.materials.Material in project gocd by gocd.
the class PipelineServiceIntegrationTest method shouldReturnModificationsInCorrectOrder.
@Test
public void shouldReturnModificationsInCorrectOrder() throws Exception {
File file1 = new File("file1");
File file2 = new File("file2");
File file3 = new File("file3");
File file4 = new File("file4");
Material hg1 = new HgMaterial("url1", "Dest1");
String[] hgRevs = new String[] { "hg1_2" };
Date latestModification = new Date();
Date older = DateUtils.addDays(latestModification, -1);
u.checkinFiles(hg1, "hg1_1", a(file1, file2, file3, file4), ModifiedAction.added, older);
u.checkinFiles(hg1, "hg1_2", a(file1, file2, file3, file4), ModifiedAction.modified, latestModification);
ScheduleTestUtil.AddedPipeline pair01 = u.saveConfigWith("pair01", "stageName", u.m(hg1));
u.runAndPass(pair01, hgRevs);
ReflectionUtil.invoke(pipelineSqlMapDao, "initDao");
Pipeline pipeline = pipelineService.mostRecentFullPipelineByName("pair01");
MaterialRevisions materialRevisions = pipeline.getBuildCause().getMaterialRevisions();
assertThat(materialRevisions.getMaterials().size(), is(1));
assertThat(materialRevisions.getDateOfLatestModification().getTime(), is(latestModification.getTime()));
}
use of com.thoughtworks.go.domain.materials.Material in project gocd by gocd.
the class PipelineServiceIntegrationTest method shouldReturnPMRsInCorrectOrder.
@Test
public void shouldReturnPMRsInCorrectOrder() throws Exception {
File file1 = new File("file1");
File file2 = new File("file2");
File file3 = new File("file3");
File file4 = new File("file4");
Material hg1 = new HgMaterial("url1", "Dest1");
Material hg2 = new HgMaterial("url2", "Dest2");
String[] hgRevs = new String[] { "h1", "h2" };
Date latestModification = new Date();
u.checkinFiles(hg2, "h2", a(file1, file2, file3, file4), ModifiedAction.added, org.apache.commons.lang.time.DateUtils.addDays(latestModification, -1));
u.checkinFiles(hg1, "h1", a(file1, file2, file3, file4), ModifiedAction.added, latestModification);
ScheduleTestUtil.AddedPipeline pair01 = u.saveConfigWith("pair01", "stageName", u.m(hg1), u.m(hg2));
u.runAndPass(pair01, hgRevs);
ReflectionUtil.invoke(pipelineSqlMapDao, "initDao");
Pipeline pipeline = pipelineService.mostRecentFullPipelineByName("pair01");
MaterialRevisions materialRevisions = pipeline.getBuildCause().getMaterialRevisions();
Materials materials = materialRevisions.getMaterials();
assertThat(materials.size(), is(2));
assertThat(materials.get(0), is(hg1));
assertThat(materials.get(1), is(hg2));
}
use of com.thoughtworks.go.domain.materials.Material in project gocd by gocd.
the class PipelineServiceTriangleDependencyTest method shouldCopyMissingRevisionsForSameMaterialThatsUsedMoreThanOnce.
@Test
public void shouldCopyMissingRevisionsForSameMaterialThatsUsedMoreThanOnce() throws Exception {
PipelineConfig pipelineConfig = PipelineConfigMother.pipelineConfig("last");
pipelineConfig.materialConfigs().clear();
HgMaterialConfig onDirOne = MaterialConfigsMother.hgMaterialConfig("google.com", "dirOne");
HgMaterialConfig onDirTwo = MaterialConfigsMother.hgMaterialConfig("google.com", "dirTwo");
pipelineConfig.addMaterialConfig(onDirOne);
pipelineConfig.addMaterialConfig(onDirTwo);
HashMap<Material, String> materialToCommit = new HashMap<>();
materialToCommit.put(new MaterialConfigConverter().toMaterial(onDirOne), "abc");
materialToCommit.put(new MaterialConfigConverter().toMaterial(onDirTwo), "abc");
MaterialRevisions revs = ModificationsMother.getMaterialRevisions(materialToCommit);
MaterialRevisions finalRevisions = service.getRevisionsBasedOnDependencies(new PipelineConfigDependencyGraph(pipelineConfig), revs);
assertThat(finalRevisions.getRevisions(), is(revs.getRevisions()));
}
use of com.thoughtworks.go.domain.materials.Material in project gocd by gocd.
the class BuildAssignmentServiceIntegrationTest method shouldCancelAScheduledJobInCaseThePipelineIsRemovedFromTheConfig_SpecificallyAPipelineRenameToADifferentCaseAndStageNameToADifferentName.
@Test
public void shouldCancelAScheduledJobInCaseThePipelineIsRemovedFromTheConfig_SpecificallyAPipelineRenameToADifferentCaseAndStageNameToADifferentName() throws Exception {
Material hgMaterial = new HgMaterial("url", "folder");
String[] hgRevs = new String[] { "h1" };
u.checkinInOrder(hgMaterial, hgRevs);
ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("PIPELINE_WHICH_WILL_EVENTUALLY_CHANGE_CASE", u.m(hgMaterial));
u.scheduleWith(p1, hgRevs);
ScheduleTestUtil.AddedPipeline renamedPipeline = u.renamePipelineAndFirstStage(p1, "pipeline_which_will_eventually_change_case", "NEW_RANDOM_STAGE_NAME" + UUID.randomUUID());
Pipeline p1_2 = u.scheduleWith(renamedPipeline, hgRevs);
CruiseConfig cruiseConfig = configHelper.load();
// To Reload Job Plans
buildAssignmentService.onTimer();
buildAssignmentService.onConfigChange(cruiseConfig);
Stages allStages = stageDao.findAllStagesFor(p1_2.getName(), p1_2.getCounter());
assertThat(allStages.byName(CaseInsensitiveString.str(p1.config.first().name())).getState(), is(StageState.Cancelled));
}
Aggregations