Search in sources :

Example 1 with BasicEnvironmentConfig

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

the class EnvironmentsConfigTest method shouldRemoveAgentFromAllEnvironments.

@Test
public void shouldRemoveAgentFromAllEnvironments() throws Exception {
    BasicEnvironmentConfig env2 = new BasicEnvironmentConfig(new CaseInsensitiveString("prod"));
    env2.addPipeline(new CaseInsensitiveString("test"));
    env2.addAgent("agent-one");
    env2.addAgent("agent-two");
    configs.add(env2);
    BasicEnvironmentConfig env3 = new BasicEnvironmentConfig(new CaseInsensitiveString("dev"));
    env3.addPipeline(new CaseInsensitiveString("build"));
    env3.addAgent("agent-two");
    env3.addAgent("agent-three");
    configs.add(env3);
    assertThat(configs.get(0).getAgents().size(), is(1));
    assertThat(configs.get(1).getAgents().size(), is(2));
    assertThat(configs.environmentsForAgent("agent-one").size(), is(2));
    configs.removeAgentFromAllEnvironments("agent-one");
    assertThat(configs.get(0).getAgents().size(), is(0));
    assertThat(configs.get(1).getAgents().size(), is(1));
    assertThat(configs.get(2).getAgents().size(), is(2));
    assertThat(configs.environmentsForAgent("agent-one").size(), is(0));
    assertThat(configs.environmentsForAgent("agent-two").size(), is(2));
    assertThat(configs.environmentsForAgent("agent-three").size(), is(1));
}
Also used : BasicEnvironmentConfig(com.thoughtworks.go.config.BasicEnvironmentConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 2 with BasicEnvironmentConfig

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

the class EnvironmentsConfigTest method shouldGetLocalPartsWhenOriginIsMixed.

@Test
public void shouldGetLocalPartsWhenOriginIsMixed() {
    env.setOrigins(new FileConfigOrigin());
    BasicEnvironmentConfig prodLocalPart = new BasicEnvironmentConfig(new CaseInsensitiveString("PROD"));
    prodLocalPart.addAgent("1235");
    prodLocalPart.setOrigins(new FileConfigOrigin());
    BasicEnvironmentConfig prodRemotePart = new BasicEnvironmentConfig(new CaseInsensitiveString("PROD"));
    prodRemotePart.setOrigins(new RepoConfigOrigin());
    MergeEnvironmentConfig pairEnvironmentConfig = new MergeEnvironmentConfig(prodLocalPart, prodRemotePart);
    configs.add(pairEnvironmentConfig);
    assertThat(configs.getLocal().size(), is(2));
    assertThat(configs.getLocal(), hasItem(env));
    assertThat(configs.getLocal(), hasItem(prodLocalPart));
}
Also used : FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) BasicEnvironmentConfig(com.thoughtworks.go.config.BasicEnvironmentConfig) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) MergeEnvironmentConfig(com.thoughtworks.go.config.merge.MergeEnvironmentConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 3 with BasicEnvironmentConfig

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

the class EnvironmentConfigMother method environment.

public static BasicEnvironmentConfig environment(String name) {
    BasicEnvironmentConfig uat = new BasicEnvironmentConfig(new CaseInsensitiveString(name));
    uat.addPipeline(new CaseInsensitiveString(name + "-pipeline"));
    uat.addAgent(name + "-agent");
    uat.addAgent(OMNIPRESENT_AGENT);
    return uat;
}
Also used : BasicEnvironmentConfig(com.thoughtworks.go.config.BasicEnvironmentConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 4 with BasicEnvironmentConfig

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

the class AddEnvironmentCommandTest method setup.

@Before
public void setup() throws Exception {
    initMocks(this);
    currentUser = new Username(new CaseInsensitiveString("user"));
    cruiseConfig = new GoConfigMother().defaultCruiseConfig();
    environmentName = new CaseInsensitiveString("Dev");
    environmentConfig = new BasicEnvironmentConfig(environmentName);
    result = new HttpLocalizedOperationResult();
    actionFailed = LocalizedMessage.string("ENV_ADD_FAILED");
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) BasicEnvironmentConfig(com.thoughtworks.go.config.BasicEnvironmentConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) GoConfigMother(com.thoughtworks.go.helper.GoConfigMother) Before(org.junit.Before)

Example 5 with BasicEnvironmentConfig

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

the class DeleteEnvironmentCommandTest method setup.

@Before
public void setup() throws Exception {
    initMocks(this);
    currentUser = new Username(new CaseInsensitiveString("user"));
    cruiseConfig = new GoConfigMother().defaultCruiseConfig();
    environmentName = new CaseInsensitiveString("Dev");
    environmentConfig = new BasicEnvironmentConfig(environmentName);
    result = new HttpLocalizedOperationResult();
    cruiseConfig.addEnvironment(environmentConfig);
    actionFailed = LocalizedMessage.string("ENV_DELETE_FAILED", environmentName);
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) BasicEnvironmentConfig(com.thoughtworks.go.config.BasicEnvironmentConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) GoConfigMother(com.thoughtworks.go.helper.GoConfigMother) Before(org.junit.Before)

Aggregations

BasicEnvironmentConfig (com.thoughtworks.go.config.BasicEnvironmentConfig)7 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)7 Before (org.junit.Before)4 GoConfigMother (com.thoughtworks.go.helper.GoConfigMother)3 Username (com.thoughtworks.go.server.domain.Username)3 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)3 Test (org.junit.Test)2 EnvironmentsConfig (com.thoughtworks.go.config.EnvironmentsConfig)1 MergeEnvironmentConfig (com.thoughtworks.go.config.merge.MergeEnvironmentConfig)1 FileConfigOrigin (com.thoughtworks.go.config.remote.FileConfigOrigin)1 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)1