use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class GoConfigServiceTest method shouldReturnListOfUpstreamPipelineConfigValidForFetchArtifact.
@Test
public void shouldReturnListOfUpstreamPipelineConfigValidForFetchArtifact() {
PipelineConfig unrelatedPipeline = PipelineConfigMother.pipelineConfig("some.random.pipeline");
PipelineConfig upstream = PipelineConfigMother.createPipelineConfig("upstream", "upstream.stage", "upstream.job");
upstream.add(StageConfigMother.stageConfig("upstream.stage.2"));
upstream.add(StageConfigMother.stageConfig("upstream.stage.3"));
PipelineConfig downstream = PipelineConfigMother.createPipelineConfig("pipeline", "stage.1", "jobs");
downstream.add(StageConfigMother.stageConfig("stage.2"));
downstream.add(StageConfigMother.stageConfig("current.stage"));
downstream.addMaterialConfig(new DependencyMaterialConfig(new CaseInsensitiveString("upstream"), new CaseInsensitiveString("upstream.stage.2")));
CruiseConfig cruiseConfig = configWith(upstream, downstream, unrelatedPipeline);
when(goConfigDao.load()).thenReturn(cruiseConfig);
List<PipelineConfig> fetchablePipelines = goConfigService.pipelinesForFetchArtifacts("pipeline");
assertThat(fetchablePipelines.size(), is(2));
assertThat(fetchablePipelines, hasItem(upstream));
assertThat(fetchablePipelines, hasItem(downstream));
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class GoConfigServiceTest method shouldBeAbleToListAllDependencyMaterialConfigs.
@Test
public void shouldBeAbleToListAllDependencyMaterialConfigs() {
BasicCruiseConfig config = mock(BasicCruiseConfig.class);
DependencyMaterialConfig dependencyMaterialConfig = MaterialConfigsMother.dependencyMaterialConfig();
SvnMaterialConfig svnMaterialConfig = MaterialConfigsMother.svnMaterialConfig();
PluggableSCMMaterialConfig pluggableSCMMaterialConfig = MaterialConfigsMother.pluggableSCMMaterialConfig();
HashSet<MaterialConfig> materialConfigs = new HashSet<>(Arrays.asList(dependencyMaterialConfig, svnMaterialConfig, pluggableSCMMaterialConfig));
when(goConfigService.getCurrentConfig()).thenReturn(config);
when(config.getAllUniqueMaterialsBelongingToAutoPipelinesAndConfigRepos()).thenReturn(materialConfigs);
Set<DependencyMaterialConfig> schedulableDependencyMaterials = goConfigService.getSchedulableDependencyMaterials();
assertThat(schedulableDependencyMaterials.size(), is(1));
assertTrue(schedulableDependencyMaterials.contains(dependencyMaterialConfig));
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class AutoBuildCauseTest method dependencyGraphOfDepthOne.
private PipelineConfigDependencyGraph dependencyGraphOfDepthOne(MaterialConfig sharedMaterial, MaterialConfig firstOrderMaterial) {
PipelineConfig current;
if (firstOrderMaterial != null) {
current = GoConfigMother.createPipelineConfigWithMaterialConfig("current", sharedMaterial, firstOrderMaterial, new DependencyMaterialConfig(new CaseInsensitiveString("up1"), new CaseInsensitiveString("first")));
} else {
current = GoConfigMother.createPipelineConfigWithMaterialConfig("current", sharedMaterial, new DependencyMaterialConfig(new CaseInsensitiveString("up1"), new CaseInsensitiveString("first")));
}
PipelineConfig upStream = GoConfigMother.createPipelineConfigWithMaterialConfig("up1", sharedMaterial);
return new PipelineConfigDependencyGraph(current, new PipelineConfigDependencyGraph(upStream));
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class PipelineConfigDependencyGraphTest method shouldReturnIfSharedRevisionsAreIgnoredByAllDaddys.
@Test
public void shouldReturnIfSharedRevisionsAreIgnoredByAllDaddys() throws Exception {
SvnMaterialConfig firstOrderSVNMaterial = MaterialConfigsMother.svnMaterialConfig();
GitMaterialConfig firstOrderGitMaterial = MaterialConfigsMother.gitMaterialConfig("url");
P4MaterialConfig firstOrderP4Material = MaterialConfigsMother.p4MaterialConfig();
firstOrderP4Material.setFilter(new Filter(new IgnoredFiles("foo")));
PipelineConfig current = GoConfigMother.createPipelineConfigWithMaterialConfig("current", MaterialConfigsMother.hgMaterialConfig(), new DependencyMaterialConfig(new CaseInsensitiveString("up1"), new CaseInsensitiveString("first")), new DependencyMaterialConfig(new CaseInsensitiveString("up2"), new CaseInsensitiveString("first")));
PipelineConfig up1 = GoConfigMother.createPipelineConfigWithMaterialConfig("up1", filteredHgMaterialConfig("phigar"), firstOrderGitMaterial, new DependencyMaterialConfig(new CaseInsensitiveString("uppest"), new CaseInsensitiveString("first")));
PipelineConfig up2 = GoConfigMother.createPipelineConfigWithMaterialConfig("up2", firstOrderSVNMaterial, firstOrderP4Material, filteredHgMaterialConfig("phigar"), new DependencyMaterialConfig(new CaseInsensitiveString("uppest"), new CaseInsensitiveString("first")));
PipelineConfig uppest = GoConfigMother.createPipelineConfigWithMaterialConfig("uppest", filteredHgMaterialConfig("phigar"), firstOrderP4Material);
PipelineConfigDependencyGraph uppestGraph = new PipelineConfigDependencyGraph(uppest);
PipelineConfigDependencyGraph up1Graph = new PipelineConfigDependencyGraph(up1, uppestGraph);
PipelineConfigDependencyGraph up2Graph = new PipelineConfigDependencyGraph(up2, uppestGraph);
PipelineConfigDependencyGraph dependencyGraph = new PipelineConfigDependencyGraph(current, up1Graph, up2Graph);
Modification modification = new Modification("user", "comment", "i@u.com", new Date(), "foo");
modification.createModifiedFile("phigar", "", ModifiedAction.added);
boolean ignored = dependencyGraph.isRevisionsOfSharedMaterialsIgnored(ModificationsMother.createHgMaterialWithMultipleRevisions(1, modification));
assertThat(ignored, is(true));
ignored = dependencyGraph.isRevisionsOfSharedMaterialsIgnored(ModificationsMother.createHgMaterialWithMultipleRevisions(1, ModificationsMother.oneModifiedFile("Silly")));
assertThat(ignored, is(false));
MaterialRevisions materialRevisions = ModificationsMother.createSvnMaterialRevisions(modification);
materialRevisions.addAll(ModificationsMother.createP4MaterialRevisions(modification));
materialRevisions.addAll(ModificationsMother.createHgMaterialWithMultipleRevisions(1, modification));
ignored = up2Graph.isRevisionsOfSharedMaterialsIgnored(materialRevisions);
assertThat(ignored, is(true));
ignored = up2Graph.isRevisionsOfSharedMaterialsIgnored(ModificationsMother.createHgMaterialWithMultipleRevisions(1, ModificationsMother.oneModifiedFile("Silly")));
assertThat(ignored, is(false));
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class PipelineConfigDependencyGraphTest method shouldReturnTheListOfFirstOrderMaterialsIgnoringDestFoldersForScmMaterials.
@Test
public void shouldReturnTheListOfFirstOrderMaterialsIgnoringDestFoldersForScmMaterials() throws Exception {
HgMaterialConfig common1 = MaterialConfigsMother.hgMaterialConfig("hg-url", "one-folder");
HgMaterialConfig common2 = MaterialConfigsMother.hgMaterialConfig("hg-url", "another-folder");
SvnMaterialConfig firstOrderSVNMaterial = MaterialConfigsMother.svnMaterialConfig();
GitMaterialConfig firstOrderGitMaterial = MaterialConfigsMother.gitMaterialConfig("url", "submodule", "branch", false);
P4MaterialConfig firstOrderP4Material = MaterialConfigsMother.p4MaterialConfig();
DependencyMaterialConfig up1DependencyMaterial = new DependencyMaterialConfig(new CaseInsensitiveString("up1"), new CaseInsensitiveString("first"));
DependencyMaterialConfig up2DependencyMaterial = new DependencyMaterialConfig(new CaseInsensitiveString("up2"), new CaseInsensitiveString("first"));
DependencyMaterialConfig uppestDependencyMaterial = new DependencyMaterialConfig(new CaseInsensitiveString("uppest"), new CaseInsensitiveString("first"));
PipelineConfig current = GoConfigMother.createPipelineConfigWithMaterialConfig("current", common1, up1DependencyMaterial, up2DependencyMaterial);
PipelineConfig up1 = GoConfigMother.createPipelineConfigWithMaterialConfig("up1", common2, firstOrderGitMaterial, uppestDependencyMaterial);
PipelineConfig up2 = GoConfigMother.createPipelineConfigWithMaterialConfig("up2", firstOrderSVNMaterial, common2, uppestDependencyMaterial);
PipelineConfig uppest = GoConfigMother.createPipelineConfigWithMaterialConfig("uppest", common1, firstOrderP4Material);
PipelineConfigDependencyGraph uppestGraph = new PipelineConfigDependencyGraph(uppest);
PipelineConfigDependencyGraph up1Graph = new PipelineConfigDependencyGraph(up1, uppestGraph);
PipelineConfigDependencyGraph up2Graph = new PipelineConfigDependencyGraph(up2, uppestGraph);
PipelineConfigDependencyGraph dependencyGraph = new PipelineConfigDependencyGraph(current, up1Graph, up2Graph);
assertThat(dependencyGraph.unsharedMaterialConfigs().size(), is(2));
assertThat(dependencyGraph.unsharedMaterialConfigs().get(0), is(up1DependencyMaterial));
assertThat(dependencyGraph.unsharedMaterialConfigs().get(1), is(up2DependencyMaterial));
assertThat(up1Graph.unsharedMaterialConfigs().size(), is(2));
assertThat(up1Graph.unsharedMaterialConfigs().get(0), is(firstOrderGitMaterial));
assertThat(up1Graph.unsharedMaterialConfigs().get(1), is(uppestDependencyMaterial));
assertThat(up2Graph.unsharedMaterialConfigs().size(), is(2));
assertThat(up2Graph.unsharedMaterialConfigs().get(0), is(firstOrderSVNMaterial));
assertThat(up2Graph.unsharedMaterialConfigs().get(1), is(uppestDependencyMaterial));
assertThat(uppestGraph.unsharedMaterialConfigs().size(), is(2));
assertThat(uppestGraph.unsharedMaterialConfigs().get(0), is(common1));
assertThat(uppestGraph.unsharedMaterialConfigs().get(1), is(firstOrderP4Material));
}
Aggregations