@Test public void getStagesUsedAsMaterials() { HgMaterialConfig hg = MaterialConfigsMother.hgMaterialConfig(); StageConfig upStage = new StageConfig(new CaseInsensitiveString("stage1"), new JobConfigs()); PipelineConfig up1 = new PipelineConfig(new CaseInsensitiveString("up1"), new MaterialConfigs(hg), upStage); PipelineConfig up2 = new PipelineConfig( new CaseInsensitiveString("up2"), new MaterialConfigs(hg), new StageConfig(new CaseInsensitiveString("stage2"), new JobConfigs())); DependencyMaterialConfig dependency1 = MaterialConfigsMother.dependencyMaterialConfig("up1", "stage1"); DependencyMaterialConfig dependency2 = MaterialConfigsMother.dependencyMaterialConfig("up2", "stage2"); PipelineConfig down1 = new PipelineConfig( new CaseInsensitiveString("down1"), new MaterialConfigs(dependency1, dependency2, hg)); PipelineConfig down2 = new PipelineConfig( new CaseInsensitiveString("down2"), new MaterialConfigs(dependency1, dependency2, hg)); CruiseConfig config = new CruiseConfig(new PipelineConfigs(up1, up2, down1, down2)); Set<StageConfig> stages = config.getStagesUsedAsMaterials(up1); assertThat(stages.size(), is(1)); assertThat(stages.contains(upStage), is(true)); }
@Test public void shouldCreateDependencyNodeForScmMaterial() { MaterialConfig material = MaterialConfigsMother.dependencyMaterialConfig(); FanInNode node = FanInNodeFactory.create(material); assertThat(node instanceof DependencyFanInNode, is(true)); assertThat(node.materialConfig, is(material)); }
@Test public void shouldIncludeDependencyMaterialsFromManualPipelinesInSchedulableMaterials() { DependencyMaterialConfig dependencyMaterialConfig = MaterialConfigsMother.dependencyMaterialConfig(); PipelineConfig pipeline1 = new PipelineConfig( new CaseInsensitiveString("pipeline1"), new MaterialConfigs(dependencyMaterialConfig)); pipeline1.add( new StageConfig( new CaseInsensitiveString("manual-stage"), new JobConfigs(), new Approval())); CruiseConfig config = new CruiseConfig(new PipelineConfigs(pipeline1)); Set<MaterialConfig> materialConfigs = config.getAllUniqueMaterialsBelongingToAutoPipelines(); assertThat(materialConfigs.size(), is(1)); assertThat(materialConfigs.contains(dependencyMaterialConfig), is(true)); }