Search in sources :

Example 21 with PartialConfig

use of com.thoughtworks.go.config.remote.PartialConfig in project gocd by gocd.

the class PartialConfigMother method withPipelineMultipleMaterials.

public static PartialConfig withPipelineMultipleMaterials(String name, RepoConfigOrigin repoOrigin) {
    GitMaterialConfig gitMaterialConfig = MaterialConfigsMother.gitMaterialConfig();
    gitMaterialConfig.setFolder("git");
    SvnMaterialConfig svnMaterialConfig = MaterialConfigsMother.svnMaterialConfig();
    svnMaterialConfig.setFolder("svn");
    PipelineConfig pipe = PipelineConfigMother.pipelineConfig(name, new MaterialConfigs(gitMaterialConfig, svnMaterialConfig));
    BasicPipelineConfigs pipes = new BasicPipelineConfigs(pipe);
    pipes.setGroup("group");
    PartialConfig partialConfig = new PartialConfig(new PipelineGroups(pipes));
    partialConfig.setOrigins(repoOrigin);
    return partialConfig;
}
Also used : PipelineGroups(com.thoughtworks.go.domain.PipelineGroups) MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)

Example 22 with PartialConfig

use of com.thoughtworks.go.config.remote.PartialConfig in project gocd by gocd.

the class PartialConfigMother method withPipeline.

public static PartialConfig withPipeline(String name, RepoConfigOrigin repoOrigin) {
    PipelineConfig pipe = PipelineConfigMother.pipelineConfig(name);
    BasicPipelineConfigs pipes = new BasicPipelineConfigs(pipe);
    pipes.setGroup("group");
    PartialConfig partialConfig = new PartialConfig(new PipelineGroups(pipes));
    partialConfig.setOrigins(repoOrigin);
    return partialConfig;
}
Also used : PipelineGroups(com.thoughtworks.go.domain.PipelineGroups) PartialConfig(com.thoughtworks.go.config.remote.PartialConfig)

Example 23 with PartialConfig

use of com.thoughtworks.go.config.remote.PartialConfig in project gocd by gocd.

the class GoFileConfigDataSourceTest method shouldNotRetryConfigUpdateIfLastKnownAndValidPartialsAreSame_OnWriteFullConfigWithLock.

@Test(expected = RuntimeException.class)
public void shouldNotRetryConfigUpdateIfLastKnownAndValidPartialsAreSame_OnWriteFullConfigWithLock() throws Exception {
    PartialConfig partialConfig1 = PartialConfigMother.withPipeline("p1", new RepoConfigOrigin(new ConfigRepoConfig(MaterialConfigsMother.gitMaterialConfig(), "plugin"), "git_r1"));
    List<PartialConfig> known = asList(partialConfig1);
    List<PartialConfig> valid = asList(partialConfig1);
    BasicCruiseConfig configForEdit = new BasicCruiseConfig();
    MagicalGoConfigXmlLoader.setMd5(configForEdit, "md5");
    FullConfigUpdateCommand updatingCommand = new FullConfigUpdateCommand(new BasicCruiseConfig(), "md5");
    GoConfigHolder configHolder = new GoConfigHolder(new BasicCruiseConfig(), configForEdit);
    CachedGoPartials cachedGoPartials = mock(CachedGoPartials.class);
    GoFileConfigDataSource source = new GoFileConfigDataSource(null, null, systemEnvironment, null, null, null, null, null, cachedGoPartials, fullConfigSaveMergeFlow, fullConfigSaveNormalFlow);
    stub(cachedGoPartials.lastKnownPartials()).toReturn(known);
    stub(cachedGoPartials.lastValidPartials()).toReturn(valid);
    when(fullConfigSaveNormalFlow.execute(updatingCommand, known, "loser_boozer")).thenThrow(new GoConfigInvalidException(configForEdit, "error"));
    source.writeFullConfigWithLock(updatingCommand, configHolder);
}
Also used : FullConfigUpdateCommand(com.thoughtworks.go.config.update.FullConfigUpdateCommand) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) GoConfigInvalidException(com.thoughtworks.go.config.exceptions.GoConfigInvalidException) Test(org.junit.Test)

Example 24 with PartialConfig

use of com.thoughtworks.go.config.remote.PartialConfig in project gocd by gocd.

the class GoFileConfigDataSourceTest method shouldReturnFalseWhenValidPartialsListIsNotTheSameAsKnownPartialList.

@Test
public void shouldReturnFalseWhenValidPartialsListIsNotTheSameAsKnownPartialList() {
    PartialConfig partialConfig1 = PartialConfigMother.withPipeline("p1", new RepoConfigOrigin(new ConfigRepoConfig(MaterialConfigsMother.gitMaterialConfig(), "plugin"), "git_r1"));
    PartialConfig partialConfig2 = PartialConfigMother.withPipeline("p2", new RepoConfigOrigin(new ConfigRepoConfig(MaterialConfigsMother.svnMaterialConfig(), "plugin"), "svn_r1"));
    PartialConfig partialConfig3 = PartialConfigMother.withPipeline("p1", new RepoConfigOrigin(new ConfigRepoConfig(MaterialConfigsMother.gitMaterialConfig(), "plugin"), "git_r2"));
    PartialConfig partialConfig4 = PartialConfigMother.withPipeline("p2", new RepoConfigOrigin(new ConfigRepoConfig(MaterialConfigsMother.svnMaterialConfig(), "plugin"), "svn_r2"));
    List<PartialConfig> known = asList(partialConfig1, partialConfig2);
    List<PartialConfig> valid = asList(partialConfig3, partialConfig4);
    assertThat(dataSource.areKnownPartialsSameAsValidPartials(known, valid), is(false));
}
Also used : ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) Test(org.junit.Test)

Example 25 with PartialConfig

use of com.thoughtworks.go.config.remote.PartialConfig in project gocd by gocd.

the class GoPartialConfigTest method shouldNotifyListenersAfterUpdatingMapOfLatestValidConfig.

@Test
public void shouldNotifyListenersAfterUpdatingMapOfLatestValidConfig() {
    ScmMaterialConfig material = setOneConfigRepo();
    PartialConfig part = new PartialConfig();
    when(plugin.load(any(File.class), any(PartialConfigLoadContext.class))).thenReturn(part);
    PartialConfigUpdateCompletedListener listener = mock(PartialConfigUpdateCompletedListener.class);
    repoConfigDataSource.registerListener(listener);
    repoConfigDataSource.onCheckoutComplete(material, folder, "7a8f");
    verify(listener, times(1)).onSuccessPartialConfig(any(ConfigRepoConfig.class), any(PartialConfig.class));
}
Also used : ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) File(java.io.File) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) Test(org.junit.Test)

Aggregations

PartialConfig (com.thoughtworks.go.config.remote.PartialConfig)70 Test (org.junit.Test)39 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)29 File (java.io.File)15 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)12 StringContains.containsString (org.hamcrest.core.StringContains.containsString)12 FullConfigUpdateCommand (com.thoughtworks.go.config.update.FullConfigUpdateCommand)10 IOException (java.io.IOException)8 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)8 ExpectedException (org.junit.rules.ExpectedException)8 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)7 PipelineGroups (com.thoughtworks.go.domain.PipelineGroups)7 GoConfigMother (com.thoughtworks.go.helper.GoConfigMother)7 Cloner (com.rits.cloning.Cloner)6 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)6 ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)5 ConfigFileHasChangedException (com.thoughtworks.go.config.exceptions.ConfigFileHasChangedException)4 ConfigMergeException (com.thoughtworks.go.config.exceptions.ConfigMergeException)4 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)3 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)3