use of com.thoughtworks.go.presentation.TriStateSelection in project gocd by gocd.
the class PipelineConfigServiceIntegrationTest method setup.
@Before
public void setup() throws Exception {
cachedGoPartials.clear();
configHelper = new GoConfigFileHelper();
dbHelper.onSetUp();
configHelper.usingCruiseConfigDao(goConfigDao).initializeConfigFile();
configHelper.onSetUp();
goConfigService.forceNotifyListeners();
user = new Username(new CaseInsensitiveString("current"));
pipelineConfig = GoConfigMother.createPipelineConfigWithMaterialConfig(UUID.randomUUID().toString(), new GitMaterialConfig("FOO"));
goConfigService.addPipeline(pipelineConfig, groupName);
repoConfig1 = new ConfigRepoConfig(MaterialConfigsMother.gitMaterialConfig("url"), XmlPartialConfigProvider.providerName);
repoConfig2 = new ConfigRepoConfig(MaterialConfigsMother.gitMaterialConfig("url2"), XmlPartialConfigProvider.providerName);
goConfigService.updateConfig(new UpdateConfigCommand() {
@Override
public CruiseConfig update(CruiseConfig cruiseConfig) throws Exception {
cruiseConfig.getConfigRepos().add(repoConfig1);
cruiseConfig.getConfigRepos().add(repoConfig2);
return cruiseConfig;
}
});
GoCipher goCipher = new GoCipher();
goConfigService.updateServerConfig(new MailHost(goCipher), new LdapConfig(goCipher), new PasswordFileConfig("path"), false, goConfigService.configFileMd5(), "artifacts", null, null, "0", null, null, "foo");
UpdateConfigCommand command = goConfigService.modifyAdminPrivilegesCommand(asList(user.getUsername().toString()), new TriStateSelection(Admin.GO_SYSTEM_ADMIN, TriStateSelection.Action.add));
goConfigService.updateConfig(command);
remoteDownstreamPipelineName = "remote-downstream";
partialConfig = PartialConfigMother.pipelineWithDependencyMaterial(remoteDownstreamPipelineName, pipelineConfig, new RepoConfigOrigin(repoConfig1, "repo1_r1"));
goPartialConfig.onSuccessPartialConfig(repoConfig1, partialConfig);
PartialConfig partialConfigFromRepo2 = PartialConfigMother.withPipeline("independent-pipeline", new RepoConfigOrigin(repoConfig2, "repo2_r1"));
goPartialConfig.onSuccessPartialConfig(repoConfig2, partialConfigFromRepo2);
result = new HttpLocalizedOperationResult();
headCommitBeforeUpdate = configRepository.getCurrentRevCommit().name();
}
use of com.thoughtworks.go.presentation.TriStateSelection in project gocd by gocd.
the class AgentServiceIntegrationTest method shouldNotFailTryingToAddAnAgentThatsAlreadyPresentInEnvironment.
@Test
public void shouldNotFailTryingToAddAnAgentThatsAlreadyPresentInEnvironment() throws Exception {
createEnvironment("uat");
createEnabledAgent(UUID);
createEnabledAgent(UUID2);
CONFIG_HELPER.addAgentToEnvironment("uat", UUID);
HttpOperationResult operationResult = new HttpOperationResult();
agentService.modifyEnvironments(USERNAME, operationResult, Arrays.asList(UUID, UUID2), Arrays.asList(new TriStateSelection("uat", TriStateSelection.Action.add)));
assertThat(operationResult.httpCode(), is(200));
assertThat(environmentConfigService.environmentsFor(UUID), containsSet("uat"));
assertThat(environmentConfigService.environmentsFor(UUID2), containsSet("uat"));
}
use of com.thoughtworks.go.presentation.TriStateSelection in project gocd by gocd.
the class AgentServiceIntegrationTest method updateAgentAttributesShouldUpdateAnAgentEnvironments.
@Test
public void updateAgentAttributesShouldUpdateAnAgentEnvironments() throws Exception {
createEnvironment("a", "b", "c", "d", "e");
AgentConfig agent = createEnabledAgent(UUID);
HttpOperationResult operationResult = new HttpOperationResult();
agentService.modifyEnvironments(USERNAME, operationResult, Arrays.asList(UUID), Arrays.asList(new TriStateSelection("a", TriStateSelection.Action.add), new TriStateSelection("b", TriStateSelection.Action.add), new TriStateSelection("c", TriStateSelection.Action.add)));
assertThat(operationResult.httpCode(), is(200));
goConfigDao.load();
assertThat(agentService.agents().size(), is(1));
assertThat(getFirstAgent().getResources(), is(empty()));
operationResult = new HttpOperationResult();
agentService.updateAgentAttributes(USERNAME, operationResult, UUID, null, null, "c,d,e", TriState.UNSET);
assertThat(operationResult.httpCode(), is(200));
assertThat(operationResult.message(), is("Updated agent with uuid uuid."));
assertThat(agentService.agents().size(), is(1));
assertThat(getEnvironments(getFirstAgent().getUuid()).equals(new HashSet<>(Arrays.asList("c", "d", "e"))), is(true));
}
use of com.thoughtworks.go.presentation.TriStateSelection in project gocd by gocd.
the class AgentServiceIntegrationTest method shouldAddResourcesToMultipleAgents.
@Test
public void shouldAddResourcesToMultipleAgents() {
createEnabledAgent(UUID);
createEnabledAgent(UUID2);
HttpOperationResult operationResult = new HttpOperationResult();
agentService.modifyResources(USERNAME, operationResult, Arrays.asList(UUID, UUID2), Arrays.asList(new TriStateSelection("old-resource", TriStateSelection.Action.add), new TriStateSelection("new-resource", TriStateSelection.Action.add)));
assertThat(operationResult.httpCode(), is(200));
assertThat(operationResult.message(), is("Resource(s) modified on 2 agent(s)"));
assertThat(agentService.findAgentAndRefreshStatus(UUID).agentConfig().getResources(), hasItem(new Resource("old-resource")));
assertThat(agentService.findAgentAndRefreshStatus(UUID).agentConfig().getResources(), hasItem(new Resource("new-resource")));
assertThat(agentService.findAgentAndRefreshStatus(UUID2).agentConfig().getResources(), hasItem(new Resource("old-resource")));
assertThat(agentService.findAgentAndRefreshStatus(UUID2).agentConfig().getResources(), hasItem(new Resource("new-resource")));
}
use of com.thoughtworks.go.presentation.TriStateSelection in project gocd by gocd.
the class AgentServiceIntegrationTest method shouldNotChangeResourcesForNoChange.
@Test
public void shouldNotChangeResourcesForNoChange() {
createEnabledAgent(UUID);
createEnabledAgent(UUID2);
HttpOperationResult operationResult = new HttpOperationResult();
agentService.modifyResources(USERNAME, operationResult, Arrays.asList(UUID), Arrays.asList(new TriStateSelection("resource-1", TriStateSelection.Action.add)));
agentService.modifyResources(USERNAME, operationResult, Arrays.asList(UUID, UUID2), Arrays.asList(new TriStateSelection("resource-1", TriStateSelection.Action.nochange)));
assertThat(operationResult.httpCode(), is(200));
assertThat(operationResult.message(), is("Resource(s) modified on 2 agent(s)"));
assertThat(agentService.findAgentAndRefreshStatus(UUID).agentConfig().getResources(), hasItem(new Resource("resource-1")));
assertThat(agentService.findAgentAndRefreshStatus(UUID2).agentConfig().getResources(), not(hasItem(new Resource("resource-1"))));
}
Aggregations