use of com.thoughtworks.go.config.materials.dependency.DependencyMaterial in project gocd by gocd.
the class MaterialRepositoryIntegrationTest method hasPipelineEverRunWithMultipleMaterialsAndMultipleRuns.
@Test
public void hasPipelineEverRunWithMultipleMaterialsAndMultipleRuns() {
HgMaterial hgMaterial1 = MaterialsMother.hgMaterial("hgUrl", "dest");
MaterialRevision hgMaterialRevision1 = saveOneScmModification(hgMaterial1, "user", "file");
DependencyMaterial depMaterial1 = new DependencyMaterial(new CaseInsensitiveString("blahPipeline"), new CaseInsensitiveString("blahStage"));
MaterialRevision depMaterialRevision1 = saveOneDependencyModification(depMaterial1, "blahPipeline/1/blahStage/1");
PipelineConfig pipelineConfig = PipelineMother.createPipelineConfig("mingle", new MaterialConfigs(hgMaterial1.config(), depMaterial1.config()), "dev");
MaterialRevisions materialRevisions1 = new MaterialRevisions(hgMaterialRevision1, depMaterialRevision1);
pipelineSqlMapDao.save(instanceFactory.createPipelineInstance(pipelineConfig, BuildCause.createManualForced(materialRevisions1, Username.ANONYMOUS), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider()));
HgMaterial hgMaterial2 = MaterialsMother.hgMaterial("hgUrl", "dest");
MaterialRevision hgMaterialRevision2 = saveOneScmModification(hgMaterial2, "user", "file");
DependencyMaterial depMaterial2 = new DependencyMaterial(new CaseInsensitiveString("blahPipeline"), new CaseInsensitiveString("blahStage"));
MaterialRevision depMaterialRevision2 = saveOneDependencyModification(depMaterial2, "blahPipeline/2/blahStage/1");
PipelineConfig pipelineConfig2 = PipelineMother.createPipelineConfig("mingle", new MaterialConfigs(hgMaterial2.config(), depMaterial2.config()), "dev");
MaterialRevisions materialRevisions2 = new MaterialRevisions(hgMaterialRevision2, depMaterialRevision2);
savePipeline(instanceFactory.createPipelineInstance(pipelineConfig2, BuildCause.createManualForced(materialRevisions2, Username.ANONYMOUS), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider()));
MaterialRevisions revisions = new MaterialRevisions(new MaterialRevision(depMaterial1, depMaterialRevision1.getLatestModification()), new MaterialRevision(hgMaterial2, hgMaterialRevision2.getLatestModification()));
assertThat(repo.hasPipelineEverRunWith("mingle", revisions), is(true));
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterial in project gocd by gocd.
the class MaterialRepositoryIntegrationTest method savePipelineAndCreate_DMRs.
private DependencyMaterial savePipelineAndCreate_DMRs(Date d, MaterialRevisions hgMaterialRevisions, PipelineConfig config, int... dmrStageCounters) {
Pipeline pipeline = savePipeline(instanceFactory.createPipelineInstance(config, BuildCause.createWithModifications(hgMaterialRevisions, "Loser"), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider()));
CaseInsensitiveString stageName = config.get(0).name();
DependencyMaterial material = new DependencyMaterial(config.name(), stageName);
String label = pipeline.getLabel();
ArrayList<Modification> mods = new ArrayList<>();
for (int i = 0; i < dmrStageCounters.length; i++) {
int dmrStageCounter = dmrStageCounters[i];
StageIdentifier stageIdentifier = new StageIdentifier(pipeline.getIdentifier(), CaseInsensitiveString.str(stageName), String.valueOf(dmrStageCounter));
mods.add(new Modification(d, stageIdentifier.getStageLocator(), label, pipeline.getId()));
}
final MaterialRevision materialRevision = new MaterialRevision(material, mods);
transactionTemplate.execute(new TransactionCallback() {
public Object doInTransaction(TransactionStatus status) {
repo.saveMaterialRevision(materialRevision);
return null;
}
});
return material;
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterial in project gocd by gocd.
the class MaterialRepositoryIntegrationTest method shouldPersistActualFromRevisionUsingTheRealFromForDependencyMaterial.
@Test
public void shouldPersistActualFromRevisionUsingTheRealFromForDependencyMaterial() throws Exception {
Material material = new DependencyMaterial(new CaseInsensitiveString("pipeline_name"), new CaseInsensitiveString("stage_name"));
Modification actualFrom = modification("pipeline_name/8/stage_name/2");
Modification from = modification("pipeline_name/10/stage_name/1");
MaterialRevision firstRevision = new MaterialRevision(material, new Modifications(from, modification("pipeline_name/9/stage_name/2"), actualFrom));
saveMaterialRev(firstRevision);
Pipeline firstPipeline = createPipeline();
savePMR(firstRevision, firstPipeline);
List<PipelineMaterialRevision> pmrs = repo.findPipelineMaterialRevisions(firstPipeline.getId());
assertThat(pmrs.get(0).getActualFromRevisionId(), is(actualFrom.getId()));
assertEquals(from, pmrs.get(0).getFromModification());
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterial in project gocd by gocd.
the class MaterialRepositoryIntegrationTest method shouldBeAbleToPersistADependencyMaterial.
@Test
public void shouldBeAbleToPersistADependencyMaterial() {
MaterialInstance materialInstance = new DependencyMaterial(new CaseInsensitiveString("name"), new CaseInsensitiveString("pipeline"), new CaseInsensitiveString("stage"), "serverAlias").createMaterialInstance();
repo.saveOrUpdate(materialInstance);
MaterialInstance loaded = repo.find(materialInstance.getId());
assertThat(loaded, is(materialInstance));
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterial in project gocd by gocd.
the class ChangesetServiceIntegrationTest method shouldReturnModsOfItsOwnAndAnUpstreamPipelineForTheGivenPipelineCounters.
@Test
public void shouldReturnModsOfItsOwnAndAnUpstreamPipelineForTheGivenPipelineCounters() {
PipelineConfig upstreamPipeline = configHelper.addPipeline("upstream", "stage", git.config(), "job");
DependencyMaterial dependencyMaterial = MaterialsMother.dependencyMaterial("upstream", "stage");
pipelineConfigWithTwoMaterials.addMaterialConfig(dependencyMaterial.config());
pipelineConfigWithTwoMaterials.removeMaterialConfig(git.config());
Username username = new Username(new CaseInsensitiveString("user1"));
// Schedule upstream
List<MaterialRevision> revisionsForUpstream1 = new ArrayList<>();
addRevisionWith2Mods(revisionsForUpstream1, git);
Pipeline upstreamOne = dbHelper.checkinRevisionsToBuild(new ManualBuild(username), upstreamPipeline, revisionsForUpstream1);
// Schedule downstream
List<MaterialRevision> revisionsForPipeline1 = new ArrayList<>();
addRevisionWith2Mods(revisionsForPipeline1, hg);
dbHelper.addDependencyRevisionModification(revisionsForPipeline1, dependencyMaterial, upstreamOne);
Pipeline pipelineOne = dbHelper.checkinRevisionsToBuild(new ManualBuild(username), pipelineConfigWithTwoMaterials, revisionsForPipeline1);
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
List<MaterialRevision> actual = changesetService.revisionsBetween(CaseInsensitiveString.str(pipelineConfigWithTwoMaterials.name()), pipelineOne.getCounter(), pipelineOne.getCounter(), username, result, true, false);
List<MaterialRevision> expectedRevisions = groupByMaterial(revisionsForUpstream1, revisionsForPipeline1);
assertMaterialRevisions(expectedRevisions, actual);
assertThat(result.isSuccessful(), is(true));
}
Aggregations