use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.
the class AgentServiceIntegrationTest method updateAgentAttributesShouldUpdateAnAgentHostname.
@Test
public void updateAgentAttributesShouldUpdateAnAgentHostname() throws Exception {
AgentConfig agent = createDisabledAndIdleAgent(UUID);
goConfigDao.load();
assertThat(agentService.agents().size(), is(1));
assertThat(getFirstAgent().getHostname(), is(not("some-hostname")));
HttpOperationResult operationResult = new HttpOperationResult();
agentService.updateAgentAttributes(USERNAME, operationResult, UUID, "some-hostname", null, null, TriState.UNSET);
assertThat(operationResult.httpCode(), is(200));
assertThat(operationResult.message(), is("Updated agent with uuid uuid."));
assertThat(agentService.agents().size(), is(1));
assertThat(getFirstAgent().getHostname(), is("some-hostname"));
}
use of com.thoughtworks.go.server.service.result.HttpOperationResult 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().getResourceConfigs(), hasItem(new ResourceConfig("resource-1")));
assertThat(agentService.findAgentAndRefreshStatus(UUID2).agentConfig().getResourceConfigs(), not(hasItem(new ResourceConfig("resource-1"))));
}
use of com.thoughtworks.go.server.service.result.HttpOperationResult 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.server.service.result.HttpOperationResult in project gocd by gocd.
the class AgentServiceIntegrationTest method shouldNOTDeleteAgentsIfAtLeastOneAgentIsBuildingGivenListOfUUIDs.
@Test
public void shouldNOTDeleteAgentsIfAtLeastOneAgentIsBuildingGivenListOfUUIDs() throws Exception {
AgentConfig disabledButBuildingAgent = createDisabledAgent(UUID);
AgentConfig disabledAgent1 = createDisabledAndIdleAgent(UUID2);
goConfigDao.load();
assertThat(agentService.agents().size(), is(2));
HttpOperationResult operationResult = new HttpOperationResult();
agentService.deleteAgents(USERNAME, operationResult, Arrays.asList(disabledAgent1.getUuid(), disabledButBuildingAgent.getUuid()));
assertThat(operationResult.httpCode(), is(406));
assertThat(operationResult.message(), is("Failed to delete 2 agent(s), as agent(s) might not be disabled or are still building."));
assertThat(agentService.agents().size(), is(2));
}
use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.
the class AgentServiceIntegrationTest method updateAgentAttributesShouldUpdateAnAgentResources.
@Test
public void updateAgentAttributesShouldUpdateAnAgentResources() throws Exception {
AgentConfig agent = createDisabledAndIdleAgent(UUID);
goConfigDao.load();
assertThat(agentService.agents().size(), is(1));
assertThat(getFirstAgent().getResourceConfigs(), is(empty()));
HttpOperationResult operationResult = new HttpOperationResult();
agentService.updateAgentAttributes(USERNAME, operationResult, UUID, null, "linux,java", null, TriState.UNSET);
assertThat(operationResult.httpCode(), is(200));
assertThat(operationResult.message(), is("Updated agent with uuid uuid."));
assertThat(agentService.agents().size(), is(1));
assertThat(getFirstAgent().getResourceConfigs(), is(new ResourceConfigs("linux,java")));
}
Aggregations