Search in sources :

Example 81 with HttpOperationResult

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"));
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) Test(org.junit.Test)

Example 82 with HttpOperationResult

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"))));
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) TriStateSelection(com.thoughtworks.go.presentation.TriStateSelection) Test(org.junit.Test)

Example 83 with HttpOperationResult

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"));
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) TriStateSelection(com.thoughtworks.go.presentation.TriStateSelection) Test(org.junit.Test)

Example 84 with HttpOperationResult

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));
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) Test(org.junit.Test)

Example 85 with HttpOperationResult

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")));
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) Test(org.junit.Test)

Aggregations

HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)146 Test (org.junit.jupiter.api.Test)64 Test (org.junit.Test)53 Username (com.thoughtworks.go.server.domain.Username)34 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)23 TriStateSelection (com.thoughtworks.go.presentation.TriStateSelection)12 Pagination (com.thoughtworks.go.server.util.Pagination)7 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)6 StageStatusCache (com.thoughtworks.go.domain.activity.StageStatusCache)6 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)6 StageStatusTopic (com.thoughtworks.go.server.messaging.StageStatusTopic)6 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)5 AgentInstance (com.thoughtworks.go.domain.AgentInstance)5 BeforeEach (org.junit.jupiter.api.BeforeEach)5 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)4 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)4 NullStage (com.thoughtworks.go.domain.NullStage)4 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)4 PipelineStatusModel (com.thoughtworks.go.presentation.PipelineStatusModel)4 Stage (com.thoughtworks.go.domain.Stage)3