Search in sources :

Example 21 with GoConfigMother

use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.

the class UpdateEnvironmentsCommandTest method shouldNotThrowUpIfEnvironmentNameIsInvalid.

@Test
public void shouldNotThrowUpIfEnvironmentNameIsInvalid() throws Exception {
    String agentUuid = "uuid";
    UpdateEnvironmentsCommand command = new UpdateEnvironmentsCommand(agentUuid, "foo, bar, monkey");
    CruiseConfig cruiseConfig = new GoConfigMother().defaultCruiseConfig();
    cruiseConfig.addEnvironment("foo");
    cruiseConfig.addEnvironment("bar");
    command.update(cruiseConfig);
    EnvironmentsConfig environments = cruiseConfig.getEnvironments();
    assertThat(environments.named(new CaseInsensitiveString("foo")).getAgents().getUuids().contains(agentUuid), is(true));
    assertThat(environments.named(new CaseInsensitiveString("bar")).getAgents().getUuids().contains(agentUuid), is(true));
}
Also used : CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) GoConfigMother(com.thoughtworks.go.helper.GoConfigMother) EnvironmentsConfig(com.thoughtworks.go.config.EnvironmentsConfig) Test(org.junit.Test)

Example 22 with GoConfigMother

use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.

the class UpdateSCMConfigCommandTest method setup.

@Before
public void setup() throws Exception {
    initMocks(this);
    result = new HttpLocalizedOperationResult();
    currentUser = new Username(new CaseInsensitiveString("user"));
    cruiseConfig = new GoConfigMother().defaultCruiseConfig();
    scm = new SCM("id", new PluginConfiguration("plugin-id", "1"), new Configuration(new ConfigurationProperty(new ConfigurationKey("key"), new ConfigurationValue("value"))));
    scm.setName("material");
    scms = new SCMs();
    scms.add(scm);
    cruiseConfig.setSCMs(scms);
}
Also used : SCMs(com.thoughtworks.go.domain.scm.SCMs) HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) SCM(com.thoughtworks.go.domain.scm.SCM) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) GoConfigMother(com.thoughtworks.go.helper.GoConfigMother) Before(org.junit.Before)

Example 23 with GoConfigMother

use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.

the class UpdateTemplateConfigCommandTest method setup.

@Before
public void setup() {
    initMocks(this);
    currentUser = new Username(new CaseInsensitiveString("user"));
    cruiseConfig = new GoConfigMother().defaultCruiseConfig();
    result = new HttpLocalizedOperationResult();
    pipelineTemplateConfig = new PipelineTemplateConfig(new CaseInsensitiveString("template"), StageConfigMother.oneBuildPlanWithResourcesAndMaterials("stage", "job"));
    authorization = new Authorization(new AdminsConfig(new AdminUser(new CaseInsensitiveString("user"))));
    pipelineTemplateConfig.setAuthorization(authorization);
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) GoConfigMother(com.thoughtworks.go.helper.GoConfigMother) Before(org.junit.Before)

Example 24 with GoConfigMother

use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.

the class GoConfigPipelinePermissionsAuthorityTest method setUp.

@Before
public void setUp() throws Exception {
    configService = mock(GoConfigService.class);
    service = new GoConfigPipelinePermissionsAuthority(configService);
    configMother = new GoConfigMother();
    config = GoConfigMother.defaultCruiseConfig();
    pluginRoleUsersStore = PluginRoleUsersStore.instance();
}
Also used : GoConfigService(com.thoughtworks.go.server.service.GoConfigService) GoConfigMother(com.thoughtworks.go.helper.GoConfigMother) Before(org.junit.Before)

Example 25 with GoConfigMother

use of com.thoughtworks.go.helper.GoConfigMother 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)

Aggregations

GoConfigMother (com.thoughtworks.go.helper.GoConfigMother)80 Test (org.junit.Test)48 Username (com.thoughtworks.go.server.domain.Username)33 Before (org.junit.Before)25 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)18 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)17 GoConfigValidity (com.thoughtworks.go.config.validation.GoConfigValidity)11 StringContains.containsString (org.hamcrest.core.StringContains.containsString)8 PartialConfig (com.thoughtworks.go.config.remote.PartialConfig)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 Matchers.containsString (org.hamcrest.Matchers.containsString)7 File (java.io.File)6 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)5 PackageRepositories (com.thoughtworks.go.domain.packagerepository.PackageRepositories)4 PackageRepository (com.thoughtworks.go.domain.packagerepository.PackageRepository)4 BasicEnvironmentConfig (com.thoughtworks.go.config.BasicEnvironmentConfig)3 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)3 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)3 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)3 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)3