Search in sources :

Example 6 with FileConfigOrigin

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

the class MergeEnvironmentConfigTest method shouldUpdateEnvironmentVariablesWhenSourceIsEditable.

@Test
public void shouldUpdateEnvironmentVariablesWhenSourceIsEditable() {
    BasicEnvironmentConfig uatLocalPart = new BasicEnvironmentConfig(new CaseInsensitiveString("UAT"));
    uatLocalPart.setOrigins(new FileConfigOrigin());
    BasicEnvironmentConfig uatRemotePart = new BasicEnvironmentConfig(new CaseInsensitiveString("UAT"));
    uatRemotePart.setOrigins(new RepoConfigOrigin());
    uatLocalPart.addEnvironmentVariable("hello", "world");
    environmentConfig = new MergeEnvironmentConfig(uatLocalPart, uatRemotePart);
    environmentConfig.setConfigAttributes(new SingletonMap(BasicEnvironmentConfig.VARIABLES_FIELD, Arrays.asList(envVar("foo", "bar"), envVar("baz", "quux"), envVar("hello", "you"))));
    assertThat(environmentConfig.getVariables(), hasItem(new EnvironmentVariableConfig("hello", "you")));
    assertThat(environmentConfig.getVariables(), hasItem(new EnvironmentVariableConfig("foo", "bar")));
    assertThat(environmentConfig.getVariables(), hasItem(new EnvironmentVariableConfig("baz", "quux")));
    assertThat(environmentConfig.getVariables().size(), is(3));
    assertThat("ChangesShouldBeInLocalConfig", uatLocalPart.getVariables(), hasItem(new EnvironmentVariableConfig("hello", "you")));
    assertThat("ChangesShouldBeInLocalConfig", uatLocalPart.getVariables(), hasItem(new EnvironmentVariableConfig("foo", "bar")));
    assertThat("ChangesShouldBeInLocalConfig", uatLocalPart.getVariables(), hasItem(new EnvironmentVariableConfig("baz", "quux")));
    assertThat("ChangesShouldBeInLocalConfig", uatLocalPart.getVariables().size(), is(3));
}
Also used : SingletonMap(org.apache.commons.collections.map.SingletonMap) FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) Test(org.junit.Test)

Example 7 with FileConfigOrigin

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

the class MergeEnvironmentConfigTest method shouldReturnFalseWhenPartIsRemote.

@Test
public void shouldReturnFalseWhenPartIsRemote() {
    BasicEnvironmentConfig uatLocalPart = new BasicEnvironmentConfig(new CaseInsensitiveString("UAT"));
    uatLocalPart.setOrigins(new FileConfigOrigin());
    BasicEnvironmentConfig uatRemotePart = new BasicEnvironmentConfig(new CaseInsensitiveString("UAT"));
    uatRemotePart.setOrigins(new RepoConfigOrigin());
    environmentConfig = new MergeEnvironmentConfig(uatLocalPart, uatRemotePart);
    assertThat(environmentConfig.isLocal(), is(false));
}
Also used : FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) Test(org.junit.Test)

Example 8 with FileConfigOrigin

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

the class MergeEnvironmentConfigTest method setUp.

@Before
public void setUp() throws Exception {
    localUatEnv1 = new BasicEnvironmentConfig(new CaseInsensitiveString("UAT"));
    localUatEnv1.setOrigins(new FileConfigOrigin());
    singleEnvironmentConfig = new MergeEnvironmentConfig(localUatEnv1);
    uatLocalPart2 = new BasicEnvironmentConfig(new CaseInsensitiveString("UAT"));
    uatLocalPart2.setOrigins(new FileConfigOrigin());
    uatRemotePart = new BasicEnvironmentConfig(new CaseInsensitiveString("UAT"));
    uatRemotePart.setOrigins(new RepoConfigOrigin());
    pairEnvironmentConfig = new MergeEnvironmentConfig(uatLocalPart2, uatRemotePart);
    super.environmentConfig = pairEnvironmentConfig;
}
Also used : FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) Before(org.junit.Before)

Example 9 with FileConfigOrigin

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

the class MergeEnvironmentConfigTest method shouldReturnCorrectOriginOfDefinedAgent.

@Test
public void shouldReturnCorrectOriginOfDefinedAgent() throws Exception {
    BasicEnvironmentConfig uatLocalPart = new BasicEnvironmentConfig(new CaseInsensitiveString("UAT"));
    uatLocalPart.setOrigins(new FileConfigOrigin());
    String localAgent = "local-agent";
    uatLocalPart.addAgent(localAgent);
    BasicEnvironmentConfig uatRemotePart = new BasicEnvironmentConfig(new CaseInsensitiveString("UAT"));
    uatRemotePart.setOrigins(new RepoConfigOrigin());
    String remoteAgent = "remote-agent";
    uatRemotePart.addAgent(remoteAgent);
    MergeEnvironmentConfig environmentConfig = new MergeEnvironmentConfig(uatLocalPart, uatRemotePart);
    assertThat(environmentConfig.getOriginForAgent(localAgent), is(new FileConfigOrigin()));
    assertThat(environmentConfig.getOriginForAgent(remoteAgent), is(new RepoConfigOrigin()));
}
Also used : FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) Test(org.junit.Test)

Example 10 with FileConfigOrigin

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

the class MergeOriginConfigTest method shouldShowDisplayName.

@Test
public void shouldShowDisplayName() {
    FileConfigOrigin fileConfigOrigin = new FileConfigOrigin();
    RepoConfigOrigin repoConfigOrigin = new RepoConfigOrigin(new ConfigRepoConfig(new SvnMaterialConfig("http://mysvn", false), "myplugin"), "123");
    MergeConfigOrigin mergeOrigin = new MergeConfigOrigin(fileConfigOrigin, repoConfigOrigin);
    assertThat(mergeOrigin.displayName(), is("Merged: [ cruise-config.xml; http://mysvn at 123; ]"));
}
Also used : ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) Test(org.junit.Test)

Aggregations

FileConfigOrigin (com.thoughtworks.go.config.remote.FileConfigOrigin)59 Test (org.junit.Test)51 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)23 PipelineModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineModel)5 MergeEnvironmentConfig (com.thoughtworks.go.config.merge.MergeEnvironmentConfig)4 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)4 Permissions (com.thoughtworks.go.config.security.Permissions)4 AllowedUsers (com.thoughtworks.go.config.security.users.AllowedUsers)4 BasicPipelineConfigs (com.thoughtworks.go.config.BasicPipelineConfigs)3 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)3 PipelineConfigs (com.thoughtworks.go.config.PipelineConfigs)3 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)3 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)3 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)3 MergePipelineConfigs (com.thoughtworks.go.config.merge.MergePipelineConfigs)2 BasicEnvironmentConfig (com.thoughtworks.go.config.BasicEnvironmentConfig)1 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)1 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)1 MergeConfigOrigin (com.thoughtworks.go.config.merge.MergeConfigOrigin)1