use of com.thoughtworks.go.config.materials.dependency.DependencyMaterial in project gocd by gocd.
the class BuildCauseProducerServiceTest method shouldBeAbleToPassInSpecificRevisionForMaterialsAndScheduleABuild.
@Test
public void shouldBeAbleToPassInSpecificRevisionForMaterialsAndScheduleABuild() throws Exception {
DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("upstream-pipeline"), new CaseInsensitiveString("stage"));
SvnMaterial svnMaterial = new SvnMaterial("url", null, null, false);
pipelineConfig.addMaterialConfig(dependencyMaterial.config());
pipelineConfig.addMaterialConfig(svnMaterial.config());
List<Modification> svnModifications = ModificationsMother.multipleModificationList();
MaterialConfigs knownMaterialConfigs = new MaterialConfigs(pipelineConfig.materialConfigs());
MaterialRevision specificMaterialRevision = new MaterialRevision(dependencyMaterial, new Modification(new Date(), "upstream-pipeline/2/stage/1", "MOCK_LABEL-12", null));
when(specificMaterialRevisionFactory.create(eq("pipeline"), eq(Collections.singletonMap(dependencyMaterial.getPipelineUniqueFingerprint(), "upstream-pipeline/2/stage/1")))).thenReturn(new MaterialRevisions(specificMaterialRevision));
when(pipelineScheduleQueue.mostRecentScheduled("pipeline")).thenReturn(BuildCause.createNeverRun());
when(materialRepository.findLatestModification(svnMaterial)).thenReturn(new MaterialRevisions(new MaterialRevision(svnMaterial, svnModifications)));
when(materialConfigConverter.toMaterials(pipelineConfig.materialConfigs())).thenReturn(new Materials(dependencyMaterial, svnMaterial));
when(materialExpansionService.expandMaterialConfigsForScheduling(pipelineConfig.materialConfigs())).thenReturn(knownMaterialConfigs);
when(materialConfigConverter.toMaterials(knownMaterialConfigs)).thenReturn(new Materials(dependencyMaterial, svnMaterial));
ManualBuild buildType = new ManualBuild(Username.ANONYMOUS);
final HashMap<String, String> stringStringHashMap = new HashMap<>();
buildCauseProducerService.newProduceBuildCause(pipelineConfig, buildType, new ScheduleOptions(Collections.singletonMap(dependencyMaterial.getPipelineUniqueFingerprint(), "upstream-pipeline/2/stage/1"), stringStringHashMap, new HashMap<>()), new ServerHealthStateOperationResult(), 12345);
verify(pipelineScheduleQueue).schedule(eq("pipeline"), argThat(containsRevisions(new MaterialRevision(svnMaterial, svnModifications), specificMaterialRevision)));
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterial in project gocd by gocd.
the class EnvironmentVariableContextTest method materialRevision.
private MaterialRevision materialRevision(String materialName, String pipelineName, Integer pipelineCounter, String pipelineLabel, String stageName, int stageCounter) {
DependencyMaterial material = new DependencyMaterial(new CaseInsensitiveString(pipelineName), new CaseInsensitiveString(stageName));
if (!StringUtils.isEmpty(materialName)) {
material.setName(new CaseInsensitiveString(materialName));
}
DependencyMaterialRevision revision = DependencyMaterialRevision.create(pipelineName, pipelineCounter, pipelineLabel, stageName, stageCounter);
MaterialRevision materialRevision = revision.convert(material, new Date());
return materialRevision;
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterial in project gocd by gocd.
the class DependencyMaterialRevisionTest method shouldConvertToTheCounterBasedRevision.
@Test
public void shouldConvertToTheCounterBasedRevision() {
DependencyMaterialRevision materialRevision = DependencyMaterialRevision.create("pipeline", 10, "1.2.3", "stage", 4);
MaterialRevision withRevision = materialRevision.convert(new DependencyMaterial(new CaseInsensitiveString("pipeline"), new CaseInsensitiveString("stage")), new Date());
DependencyMaterialRevision revision = (DependencyMaterialRevision) withRevision.getRevision();
assertThat(revision.getRevision(), is("pipeline/10/stage/4"));
assertThat(revision.getPipelineLabel(), is("1.2.3"));
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterial in project gocd by gocd.
the class PipelineMaterialRevisionTest method shouldSetFROMRevisionSameAsTORevisionWhenDependencyMaterial.
@Test
public void shouldSetFROMRevisionSameAsTORevisionWhenDependencyMaterial() {
DependencyMaterial material = new DependencyMaterial(new CaseInsensitiveString("pipeline_name"), new CaseInsensitiveString("stage_name"));
Modification latestModification = modification(new Date(), "pipeline_name/4/stage_name/1", "4", null);
MaterialRevision revision = new MaterialRevision(material, latestModification, new Modification(new Date(), "pipeline_name/2/stage_name/1", "2", null));
PipelineMaterialRevision pmr = new PipelineMaterialRevision(9, revision, null);
assertThat(pmr.getToModification(), is(latestModification));
assertThat(pmr.getFromModification(), is(latestModification));
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterial in project gocd by gocd.
the class PipelineMaterialRevisionTest method shouldUpdateFROMRevisionSameAsTORevisionWhenDependencyMaterial.
@Test
public void shouldUpdateFROMRevisionSameAsTORevisionWhenDependencyMaterial() {
DependencyMaterial material = new DependencyMaterial(new CaseInsensitiveString("pipeline_name"), new CaseInsensitiveString("stage_name"));
Modification latestModification = modification(new Date(), "pipeline_name/4/stage_name/1", "4", null);
MaterialRevision revision = new MaterialRevision(material, latestModification, modification(new Date(), "pipeline_name/2/stage_name/1", "2", null));
PipelineMaterialRevision pmr = new PipelineMaterialRevision(9, revision, null);
Modification differentFrom = modification(new Date(), "pipeline_name/3/stage_name/1", "3", null);
pmr.useMaterialRevision(new MaterialRevision(material, latestModification, differentFrom));
assertThat(pmr.getToModification(), is(latestModification));
assertThat(pmr.getFromModification(), is(latestModification));
Modification laterThanTheLatest = modification(new Date(), "pipeline_name/5/stage_name/1", "5", null);
pmr.useMaterialRevision(new MaterialRevision(material, laterThanTheLatest, differentFrom));
assertThat(pmr.getToModification(), is(laterThanTheLatest));
assertThat(pmr.getFromModification(), is(laterThanTheLatest));
pmr.useMaterialRevision(new MaterialRevision(material, laterThanTheLatest, modification(new Date(), "pipeline_name/3/stage_name/2", "3", null)));
assertThat(pmr.getToModification(), is(laterThanTheLatest));
assertThat(pmr.getFromModification(), is(laterThanTheLatest));
}
Aggregations