use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class CruiseConfigTestBase method shouldReturnAllUniqueSchedulableScmMaterials.
@Test
public void shouldReturnAllUniqueSchedulableScmMaterials() {
final MaterialConfig svnMaterialConfig = new SvnMaterialConfig("http://svn_url_1", "username", "password", false);
svnMaterialConfig.setAutoUpdate(false);
final MaterialConfig svnMaterialConfigWithAutoUpdate = new SvnMaterialConfig("http://svn_url_2", "username", "password", false);
svnMaterialConfigWithAutoUpdate.setAutoUpdate(true);
final MaterialConfig hgMaterialConfig = new HgMaterialConfig("http://hg_url", null);
hgMaterialConfig.setAutoUpdate(false);
final MaterialConfig gitMaterialConfig = new GitMaterialConfig("http://git_url");
gitMaterialConfig.setAutoUpdate(false);
final MaterialConfig tfsMaterialConfig = new TfsMaterialConfig(mock(GoCipher.class), new UrlArgument("http://tfs_url"), "username", "domain", "password", "project_path");
tfsMaterialConfig.setAutoUpdate(false);
final MaterialConfig p4MaterialConfig = new P4MaterialConfig("http://p4_url", "view", "username");
p4MaterialConfig.setAutoUpdate(false);
final MaterialConfig dependencyMaterialConfig = MaterialConfigsMother.dependencyMaterialConfig();
final PluggableSCMMaterialConfig pluggableSCMMaterialConfig = MaterialConfigsMother.pluggableSCMMaterialConfig("scm-id-1", null, null);
pluggableSCMMaterialConfig.getSCMConfig().setAutoUpdate(false);
final PipelineConfig p1 = PipelineConfigMother.pipelineConfig("pipeline1", new MaterialConfigs(svnMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
final PipelineConfig p2 = PipelineConfigMother.pipelineConfig("pipeline2", new MaterialConfigs(svnMaterialConfig, gitMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
final PipelineConfig p3 = PipelineConfigMother.pipelineConfig("pipeline3", new MaterialConfigs(hgMaterialConfig, dependencyMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
final PipelineConfig p4 = PipelineConfigMother.pipelineConfig("pipeline4", new MaterialConfigs(p4MaterialConfig, pluggableSCMMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
final PipelineConfig p5 = PipelineConfigMother.pipelineConfig("pipeline5", new MaterialConfigs(svnMaterialConfigWithAutoUpdate, tfsMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
cruiseConfig.getGroups().add(new BasicPipelineConfigs(p1, p2, p3, p4, p5));
final Set<MaterialConfig> materials = cruiseConfig.getAllUniquePostCommitSchedulableMaterials();
assertThat(materials.size(), is(6));
assertThat(materials, hasItems(svnMaterialConfig, hgMaterialConfig, gitMaterialConfig, tfsMaterialConfig, p4MaterialConfig, pluggableSCMMaterialConfig));
assertThat(materials, not(hasItem(svnMaterialConfigWithAutoUpdate)));
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class CruiseConfigTestBase method shouldCheckCyclicDependency.
@Test
public void shouldCheckCyclicDependency() throws Exception {
PipelineConfig p1 = createPipelineConfig("p1", "s1", "j1");
PipelineConfig p2 = createPipelineConfig("p2", "s2", "j1");
p2.addMaterialConfig(new DependencyMaterialConfig(new CaseInsensitiveString("p1"), new CaseInsensitiveString("s1")));
PipelineConfig p3 = createPipelineConfig("p3", "s3", "j1");
p3.addMaterialConfig(new DependencyMaterialConfig(new CaseInsensitiveString("p2"), new CaseInsensitiveString("s2")));
p1.addMaterialConfig(new DependencyMaterialConfig(new CaseInsensitiveString("p3"), new CaseInsensitiveString("s3")));
pipelines.addAll(Arrays.asList(p1, p2, p3));
BasicCruiseConfig mainCruiseConfig = new BasicCruiseConfig(pipelines);
ConfigReposConfig reposConfig = new ConfigReposConfig();
GitMaterialConfig configRepo = new GitMaterialConfig("http://git");
reposConfig.add(new ConfigRepoConfig(configRepo, "myplug"));
mainCruiseConfig.setConfigRepos(reposConfig);
PartialConfig partialConfig = PartialConfigMother.withPipeline("pipe2");
cruiseConfig = new BasicCruiseConfig(mainCruiseConfig, partialConfig);
cruiseConfig.validate(mock(ValidationContext.class));
List<ConfigErrors> allErrors = cruiseConfig.getAllErrors();
assertThat((allErrors.get(0).on("base")), is("Circular dependency: p1 <- p2 <- p3 <- p1"));
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class MaterialConfigsTest method shouldNotAllowMoreThanOneDependencyWithSameName.
@Test
public void shouldNotAllowMoreThanOneDependencyWithSameName() throws Exception {
CruiseConfig config = GoConfigMother.configWithPipelines("pipeline1", "pipeline2", "pipeline3", "go");
DependencyMaterialConfig one = new DependencyMaterialConfig(new CaseInsensitiveString("sameName"), new CaseInsensitiveString("pipeline2"), new CaseInsensitiveString("stage"));
DependencyMaterialConfig another = new DependencyMaterialConfig(new CaseInsensitiveString("sameName"), new CaseInsensitiveString("pipeline3"), new CaseInsensitiveString("stage"));
MaterialConfigs materialConfigs = new MaterialConfigs(one, another);
ValidationContext validationContext = ConfigSaveValidationContext.forChain(config);
materialConfigs.validate(validationContext);
assertThat(one.errors().isEmpty(), is(false));
assertThat(one.errors().on("materialName"), containsString("You have defined multiple materials called 'sameName'. Material names are case-insensitive and must be unique."));
assertThat(another.errors().isEmpty(), is(false));
assertThat(another.errors().on("materialName"), containsString("You have defined multiple materials called 'sameName'. Material names are case-insensitive and must be unique."));
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class MaterialConfigsTest method shouldNotAllowToDependOnPipelineDefinedInConfigRepository_WhenDownstreamInFile.
@Test
public void shouldNotAllowToDependOnPipelineDefinedInConfigRepository_WhenDownstreamInFile() throws Exception {
CruiseConfig cruiseConfig = new BasicCruiseConfig();
PipelineConfig pipeline1 = goConfigMother.addPipeline(cruiseConfig, "pipeline1", "stage", "build");
PipelineConfig pipeline2 = goConfigMother.addPipeline(cruiseConfig, "pipeline2", "stage", "build");
goConfigMother.setDependencyOn(cruiseConfig, pipeline2, "pipeline1", "stage");
pipeline1.setOrigin(new RepoConfigOrigin());
pipeline2.setOrigin(new FileConfigOrigin());
pipeline1.materialConfigs().validate(ConfigSaveValidationContext.forChain(cruiseConfig, new BasicPipelineConfigs(), pipeline1));
assertThat(pipeline1.materialConfigs().errors().isEmpty(), is(true));
pipeline2.materialConfigs().validate(ConfigSaveValidationContext.forChain(cruiseConfig, new BasicPipelineConfigs(), pipeline2));
DependencyMaterialConfig invalidDependency = pipeline2.materialConfigs().findDependencyMaterial(new CaseInsensitiveString("pipeline1"));
assertThat(invalidDependency.errors().isEmpty(), is(false));
assertThat(invalidDependency.errors().on(DependencyMaterialConfig.ORIGIN), startsWith("Dependency from pipeline defined in"));
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class ReportingFanInGraph method getPipelineScmDepMap.
public Map<DependencyMaterialConfig, Set<MaterialConfig>> getPipelineScmDepMap() {
Map<DependencyMaterialConfig, Set<MaterialConfig>> dependencyMaterialListMap = new HashMap<>();
for (Map.Entry<DependencyMaterialConfig, Set<String>> materialSetEntry : dependencyMaterialFingerprintMap.entrySet()) {
HashSet<MaterialConfig> scmMaterials = new HashSet<>();
for (String fingerprint : materialSetEntry.getValue()) {
scmMaterials.add(fingerprintScmMaterialMap.get(fingerprint));
}
dependencyMaterialListMap.put(materialSetEntry.getKey(), scmMaterials);
}
return dependencyMaterialListMap;
}
Aggregations