Search in sources :

Example 31 with DependencyMaterialConfig

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)));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) GoCipher(com.thoughtworks.go.security.GoCipher) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) UrlArgument(com.thoughtworks.go.util.command.UrlArgument) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) TfsMaterialConfig(com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) TfsMaterialConfig(com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) Test(org.junit.Test)

Example 32 with DependencyMaterialConfig

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"));
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Example 33 with DependencyMaterialConfig

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."));
}
Also used : DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Example 34 with DependencyMaterialConfig

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"));
}
Also used : FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Example 35 with DependencyMaterialConfig

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;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Aggregations

DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)135 Test (org.junit.Test)106 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)22 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)22 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)21 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)15 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)14 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)11 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)10 Date (java.util.Date)10 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)9 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)8 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)8 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)8 Pipeline (com.thoughtworks.go.domain.Pipeline)8 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)8 ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)7 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)7 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)7 ModificationsMother.changedDependencyMaterialRevision (com.thoughtworks.go.helper.ModificationsMother.changedDependencyMaterialRevision)7