Search in sources :

Example 26 with BasicCruiseConfig

use of com.thoughtworks.go.config.BasicCruiseConfig in project gocd by gocd.

the class ConfigRepoPartialPreprocessorTest method shouldMergePartialsSetOnConfig.

@Test
public void shouldMergePartialsSetOnConfig() {
    final PartialConfig partialConfig = PartialConfigMother.withPipeline("partial");
    partialConfig.setOrigin(new RepoConfigOrigin(configRepoConfig, "sha-1"));
    ConfigRepoPartialPreprocessor preprocessor = new ConfigRepoPartialPreprocessor();
    PipelineConfig pipelineInMain = PipelineConfigMother.createPipelineConfig("main_pipeline", "stage", "job");
    BasicCruiseConfig cruiseConfig = new BasicCruiseConfig(new BasicPipelineConfigs(pipelineInMain));
    cruiseConfig.setConfigRepos(reposConfig);
    cruiseConfig.setPartials(asList(partialConfig));
    preprocessor.process(cruiseConfig);
    assertThat(cruiseConfig.getAllPipelineNames().contains(pipelineInMain.name()), is(true));
    assertThat(cruiseConfig.getAllPipelineNames().contains(partialConfig.getGroups().first().get(0).name()), is(true));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) BasicPipelineConfigs(com.thoughtworks.go.config.BasicPipelineConfigs) Test(org.junit.Test)

Example 27 with BasicCruiseConfig

use of com.thoughtworks.go.config.BasicCruiseConfig in project gocd by gocd.

the class ArtifactDirValidatorTest method shouldThrowExceptionWhenUserProvidesDot.

@Test
public void shouldThrowExceptionWhenUserProvidesDot() throws Exception {
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    cruiseConfig.setServerConfig(new ServerConfig(".", null));
    ArtifactDirValidator dirValidator = new ArtifactDirValidator();
    try {
        dirValidator.validate(cruiseConfig);
        fail("should throw exception, see dot will make server check out the repository in the wrong place.");
    } catch (Exception e) {
    }
}
Also used : ServerConfig(com.thoughtworks.go.config.ServerConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) Test(org.junit.Test)

Example 28 with BasicCruiseConfig

use of com.thoughtworks.go.config.BasicCruiseConfig in project gocd by gocd.

the class SCMTest method shouldValidateIfNameIsMissing.

@Test
public void shouldValidateIfNameIsMissing() {
    SCM scm = new SCM();
    scm.validate(new ConfigSaveValidationContext(new BasicCruiseConfig(), null));
    assertThat(scm.errors().getAllOn(SCM.NAME), is(asList("Please provide name")));
}
Also used : ConfigSaveValidationContext(com.thoughtworks.go.config.ConfigSaveValidationContext) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) Test(org.junit.Test)

Example 29 with BasicCruiseConfig

use of com.thoughtworks.go.config.BasicCruiseConfig in project gocd by gocd.

the class FanInGraphTest method shouldConstructAFaninGraph.

@Test
public void shouldConstructAFaninGraph() throws Exception {
    GitMaterialConfig git = new GitMaterialConfig("giturl", "dest");
    HgMaterialConfig hg = new HgMaterialConfig("hgurl", "dest");
    PipelineConfig p1 = PipelineConfigMother.pipelineConfig("p1", new MaterialConfigs(git));
    DependencyMaterialConfig p1Dep = new DependencyMaterialConfig(p1.name(), p1.get(0).name());
    PipelineConfig p2 = PipelineConfigMother.pipelineConfig("p2", new MaterialConfigs(p1Dep));
    PipelineConfig p3 = PipelineConfigMother.pipelineConfig("p3", new MaterialConfigs(p1Dep, hg));
    DependencyMaterialConfig p2Dep = new DependencyMaterialConfig(p2.name(), p2.get(0).name());
    DependencyMaterialConfig p3Dep = new DependencyMaterialConfig(p3.name(), p3.get(0).name());
    PipelineConfig p4 = PipelineConfigMother.pipelineConfig("p4", new MaterialConfigs(p2Dep, p3Dep));
    CruiseConfig cruiseConfig = new BasicCruiseConfig(new BasicPipelineConfigs(p1, p2, p3, p4));
    FanInGraph faninGraph = new FanInGraph(cruiseConfig, p4.name(), null, null, null, null);
    List<ScmMaterialConfig> scmMaterialNodes = faninGraph.getScmMaterials();
    List<String> scmMaterialUrls = new ArrayList<>();
    for (ScmMaterialConfig scmMaterialNode : scmMaterialNodes) {
        scmMaterialUrls.add(scmMaterialNode.getUrl().toString());
    }
    assertThat(scmMaterialUrls.contains("giturl"), is(true));
    assertThat(scmMaterialUrls.contains("hgurl"), is(true));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) ArrayList(java.util.ArrayList) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) BasicPipelineConfigs(com.thoughtworks.go.config.BasicPipelineConfigs) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) Test(org.junit.Test)

Example 30 with BasicCruiseConfig

use of com.thoughtworks.go.config.BasicCruiseConfig in project gocd by gocd.

the class UnrunStagesPopulatorTest method shouldPopulateConfiguredStagesWhenThereAreNoRevisionsForDownstream.

@Test
public void shouldPopulateConfiguredStagesWhenThereAreNoRevisionsForDownstream() throws Exception {
    /*
            p --> p1 --> p2
             \
              +-> p3
         */
    ValueStreamMap graph = new ValueStreamMap("p", revision("p", 1));
    Node p1_node = graph.addDownstreamNode(new PipelineDependencyNode("p1", "p1"), "p");
    Node p2_node = graph.addDownstreamNode(new PipelineDependencyNode("p2", "p2"), "p1");
    Node p3_node = graph.addDownstreamNode(new PipelineDependencyNode("p3", "p3"), "p");
    addRevisions(p1_node);
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    String group = "first";
    cruiseConfig.addPipeline(group, pipelineConfig("p"));
    cruiseConfig.addPipeline(group, pipelineConfig("p1"));
    cruiseConfig.addPipeline(group, pipelineConfig("p2"));
    cruiseConfig.addPipeline(group, pipelineConfig("p3"));
    when(goConfigService.getCurrentConfig()).thenReturn(cruiseConfig);
    unrunStagesPopulator.apply(graph);
    assertUnrunPipeline(p2_node, "p2");
    assertUnrunPipeline(p3_node, "p3");
}
Also used : BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) Test(org.junit.Test)

Aggregations

BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)31 Test (org.junit.Test)28 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)18 ServerConfig (com.thoughtworks.go.config.ServerConfig)10 BasicPipelineConfigs (com.thoughtworks.go.config.BasicPipelineConfigs)4 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)4 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)4 ServerSiteUrlConfig (com.thoughtworks.go.domain.ServerSiteUrlConfig)4 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)4 ConfigSaveValidationContext (com.thoughtworks.go.config.ConfigSaveValidationContext)3 SecurityConfig (com.thoughtworks.go.config.SecurityConfig)3 ValidationError (com.thoughtworks.go.plugin.api.response.validation.ValidationError)3 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)3 GoConfigService (com.thoughtworks.go.server.service.GoConfigService)3 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)3 PluginRoleConfig (com.thoughtworks.go.config.PluginRoleConfig)2 SecurityAuthConfig (com.thoughtworks.go.config.SecurityAuthConfig)2 ElasticProfile (com.thoughtworks.go.config.elastic.ElasticProfile)2 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)2 ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)2