Search in sources :

Example 1 with MergePipelineConfigs

use of com.thoughtworks.go.config.merge.MergePipelineConfigs in project gocd by gocd.

the class PipelineGroupsTest method shouldGetLocalPartsWhenOriginIsMixed.

@Test
public void shouldGetLocalPartsWhenOriginIsMixed() {
    PipelineConfigs localGroup = createGroup("defaultGroup", createPipelineConfig("pipeline1", "stage1"));
    localGroup.setOrigins(new FileConfigOrigin());
    PipelineConfigs remoteGroup = createGroup("defaultGroup", createPipelineConfig("pipeline2", "stage1"));
    remoteGroup.setOrigins(new RepoConfigOrigin());
    MergePipelineConfigs mergePipelineConfigs = new MergePipelineConfigs(localGroup, remoteGroup);
    PipelineGroups groups = new PipelineGroups(mergePipelineConfigs);
    assertThat(groups.getLocal().size(), is(1));
    assertThat(groups.getLocal(), hasItem(localGroup));
}
Also used : MergePipelineConfigs(com.thoughtworks.go.config.merge.MergePipelineConfigs) FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) MergePipelineConfigs(com.thoughtworks.go.config.merge.MergePipelineConfigs) Test(org.junit.jupiter.api.Test)

Example 2 with MergePipelineConfigs

use of com.thoughtworks.go.config.merge.MergePipelineConfigs in project gocd by gocd.

the class ParamResolverTest method shouldResolveInMergePipelineConfigs.

@Test
public void shouldResolveInMergePipelineConfigs() throws NoSuchFieldException {
    PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfig("cruise", "dev", "ant");
    pipelineConfig.setLabelTemplate("2.1-${COUNT}-#{foo}-bar-#{bar}");
    HgMaterialConfig materialConfig = MaterialConfigsMother.hgMaterialConfig("http://#{foo}.com/#{bar}");
    pipelineConfig.addMaterialConfig(materialConfig);
    MergePipelineConfigs merge = new MergePipelineConfigs(new BasicPipelineConfigs(), new BasicPipelineConfigs(pipelineConfig));
    new ParamResolver(new ParamSubstitutionHandlerFactory(params(param("foo", "pavan"), param("bar", "jj"))), fieldCache).resolve(merge);
    assertThat(pipelineConfig.getLabelTemplate(), is("2.1-${COUNT}-pavan-bar-jj"));
    assertThat(pipelineConfig.materialConfigs().get(1).getUriForDisplay(), is("http://pavan.com/jj"));
}
Also used : MergePipelineConfigs(com.thoughtworks.go.config.merge.MergePipelineConfigs) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) Test(org.junit.jupiter.api.Test)

Example 3 with MergePipelineConfigs

use of com.thoughtworks.go.config.merge.MergePipelineConfigs in project gocd by gocd.

the class CruiseConfigTestBase method shouldAddAuthorizationToPipelinesConfigForEditsWithUIOrigin_WhenFileHasNoPipelineGroupYet_AndForEdit.

@Test
public void shouldAddAuthorizationToPipelinesConfigForEditsWithUIOrigin_WhenFileHasNoPipelineGroupYet_AndForEdit() {
    BasicCruiseConfig mainCruiseConfig = new BasicCruiseConfig();
    // only remotely defined group
    PartialConfig partialConfig = PartialConfigMother.withPipelineInGroup("pipe1", "group1");
    partialConfig.setOrigins(new RepoConfigOrigin());
    cruiseConfig = new BasicCruiseConfig(mainCruiseConfig, true, partialConfig);
    assertThat(cruiseConfig.getGroups().size(), is(1));
    assertThat(cruiseConfig.getGroups().get(0) instanceof MergePipelineConfigs, is(true));
    assertThat(cruiseConfig.getGroups().get(0).getGroup(), is("group1"));
    MergePipelineConfigs mergedEnv = (MergePipelineConfigs) cruiseConfig.getGroups().get(0);
    assertThat(mergedEnv.getLocal().getOrigin(), is(new UIConfigOrigin()));
    Authorization authorization = new Authorization(new AdminsConfig(new AdminUser(new CaseInsensitiveString("firstTemplate-admin"))));
    cruiseConfig.getGroups().get(0).setAuthorization(authorization);
    assertThat(mergedEnv.getLocal().getAuthorization(), is(authorization));
}
Also used : MergePipelineConfigs(com.thoughtworks.go.config.merge.MergePipelineConfigs) Test(org.junit.jupiter.api.Test)

Example 4 with MergePipelineConfigs

use of com.thoughtworks.go.config.merge.MergePipelineConfigs in project gocd by gocd.

the class GoConfigGraphWalkerTest method shouldWalkPipelineConfigsInMergePipelineConfigs.

@Test
public void shouldWalkPipelineConfigsInMergePipelineConfigs() {
    PipelineConfig pipe = mockPipelineConfig();
    MergePipelineConfigs mergePipelines = new MergePipelineConfigs(new BasicPipelineConfigs(pipe));
    new GoConfigGraphWalker(mergePipelines).walk(new GoConfigGraphWalker.Handler() {

        @Override
        public void handle(Validatable validatable, ValidationContext ctx) {
            validatable.validate(ctx);
        }
    });
    verify(pipe, atLeastOnce()).validate(any(ValidationContext.class));
}
Also used : MergePipelineConfigs(com.thoughtworks.go.config.merge.MergePipelineConfigs) Test(org.junit.jupiter.api.Test)

Aggregations

MergePipelineConfigs (com.thoughtworks.go.config.merge.MergePipelineConfigs)4 Test (org.junit.jupiter.api.Test)4 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)1 FileConfigOrigin (com.thoughtworks.go.config.remote.FileConfigOrigin)1 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)1