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));
}
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"));
}
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));
}
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));
}
Aggregations