Search in sources :

Example 16 with GoConfigMother

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

the class PipelineConfigSaveValidationContextTest method shouldReturnNullIfMatchingMaterialConfigIsNotFound.

@Test
public void shouldReturnNullIfMatchingMaterialConfigIsNotFound() throws Exception {
    CruiseConfig cruiseConfig = new GoConfigMother().cruiseConfigWithPipelineUsingTwoMaterials();
    PipelineConfigSaveValidationContext context = PipelineConfigSaveValidationContext.forChain(true, "group", cruiseConfig);
    assertThat(context.getAllMaterialsByFingerPrint("does_not_exist"), is(nullValue()));
}
Also used : GoConfigMother(com.thoughtworks.go.helper.GoConfigMother) Test(org.junit.Test)

Example 17 with GoConfigMother

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

the class PatchEnvironmentCommandTest method setup.

@Before
public void setup() throws Exception {
    initMocks(this);
    pipelinesToAdd = new ArrayList<>();
    pipelinesToRemove = new ArrayList<>();
    agentsToAdd = new ArrayList<>();
    agentsToRemove = new ArrayList<>();
    envVarsToAdd = new ArrayList<>();
    envVarsToRemove = new ArrayList<>();
    result = new HttpLocalizedOperationResult();
    currentUser = new Username(new CaseInsensitiveString("user"));
    cruiseConfig = new GoConfigMother().defaultCruiseConfig();
    environmentName = new CaseInsensitiveString("Dev");
    environmentConfig = new BasicEnvironmentConfig(environmentName);
    cruiseConfig.addEnvironment(environmentConfig);
    pipelineConfig = new PipelineConfig();
    String pipelineName = "pipeline-1";
    pipelineConfig.setName(pipelineName);
    cruiseConfig.addPipeline("First-Group", pipelineConfig);
    agentConfig = new AgentConfig("uuid-1");
    cruiseConfig.agents().add(agentConfig);
    actionFailed = LocalizedMessage.string("ENV_UPDATE_FAILED", environmentConfig.name());
}
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 18 with GoConfigMother

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

the class TemplateConfigCommandTest method setup.

@Before
public void setup() {
    initMocks(this);
    currentUser = new Username(new CaseInsensitiveString("user"));
    cruiseConfig = new GoConfigMother().defaultCruiseConfig();
}
Also used : Username(com.thoughtworks.go.server.domain.Username) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) GoConfigMother(com.thoughtworks.go.helper.GoConfigMother) Before(org.junit.Before)

Example 19 with GoConfigMother

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

the class UpdateConfigRepoCommandTest method setup.

@Before
public void setup() throws Exception {
    initMocks(this);
    currentUser = new Username(new CaseInsensitiveString("user"));
    cruiseConfig = new GoConfigMother().defaultCruiseConfig();
    oldConfigRepoId = "old-repo";
    newConfigRepoId = "new-repo";
    oldConfigRepo = new ConfigRepoConfig(new GitMaterialConfig("foo.git", "master"), "json-plugin", oldConfigRepoId);
    newConfigRepo = new ConfigRepoConfig(new GitMaterialConfig("bar.git", "master"), "yaml-plugin", newConfigRepoId);
    result = new HttpLocalizedOperationResult();
    md5 = "md5";
    cruiseConfig.getConfigRepos().add(oldConfigRepo);
    actionFailed = LocalizedMessage.string("RESOURCE_UPDATE_FAILED", "Config repo", oldConfigRepoId);
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) GoConfigMother(com.thoughtworks.go.helper.GoConfigMother) Before(org.junit.Before)

Example 20 with GoConfigMother

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

the class UpdateEnvironmentsCommandTest method shouldAddAgentToListOfEnvironment.

@Test
public void shouldAddAgentToListOfEnvironment() throws Exception {
    String agentUuid = "uuid";
    UpdateEnvironmentsCommand command = new UpdateEnvironmentsCommand(agentUuid, "foo, bar, baz");
    CruiseConfig cruiseConfig = new GoConfigMother().defaultCruiseConfig();
    cruiseConfig.addEnvironment("foo");
    cruiseConfig.addEnvironment("bar");
    cruiseConfig.addEnvironment("baz");
    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));
    assertThat(environments.named(new CaseInsensitiveString("baz")).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)

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