Search in sources :

Example 1 with AgentsUpdateCommand

use of com.thoughtworks.go.config.update.AgentsUpdateCommand in project gocd by gocd.

the class AgentConfigServiceTest method shouldEnableMultipleAgents.

@Test
public void shouldEnableMultipleAgents() {
    AgentRuntimeInfo agentRuntimeInfo = AgentRuntimeInfo.fromAgent(new AgentIdentifier("remote-host", "50.40.30.20", "abc"), AgentRuntimeStatus.Unknown, "cookie", false);
    AgentInstance pending = AgentInstance.createFromLiveAgent(agentRuntimeInfo, new SystemEnvironment(), null);
    AgentConfig agentConfig = new AgentConfig("UUID2", "remote-host", "50.40.30.20");
    agentConfig.disable();
    AgentInstance fromConfigFile = AgentInstance.createFromConfig(agentConfig, new SystemEnvironment(), null);
    when(goConfigService.hasAgent(fromConfigFile.getUuid())).thenReturn(true);
    when(goConfigService.hasAgent(pending.getUuid())).thenReturn(false);
    agentConfigService.enableAgents(Username.ANONYMOUS, pending, fromConfigFile);
    GoConfigDao.CompositeConfigCommand command = new GoConfigDao.CompositeConfigCommand(new AgentConfigService.AddAgentCommand(pending.agentConfig()), new AgentConfigService.UpdateAgentApprovalStatus("UUID2", false));
    ArgumentCaptor<AgentsUpdateCommand> captor = ArgumentCaptor.forClass(AgentsUpdateCommand.class);
    verify(goConfigService).updateConfig(captor.capture(), eq(Username.ANONYMOUS));
    AgentsUpdateCommand updateCommand = captor.getValue();
    assertThat(ReflectionUtil.getField(updateCommand, "command"), is(command));
}
Also used : AgentInstance(com.thoughtworks.go.domain.AgentInstance) GoConfigDao(com.thoughtworks.go.config.GoConfigDao) SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) AgentConfig(com.thoughtworks.go.config.AgentConfig) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) AgentsUpdateCommand(com.thoughtworks.go.config.update.AgentsUpdateCommand) Test(org.junit.Test)

Example 2 with AgentsUpdateCommand

use of com.thoughtworks.go.config.update.AgentsUpdateCommand in project gocd by gocd.

the class AgentConfigServiceTest method shouldPerformCommand.

private void shouldPerformCommand(UpdateConfigCommand command) {
    ArgumentCaptor<AgentsUpdateCommand> captor = ArgumentCaptor.forClass(AgentsUpdateCommand.class);
    verify(goConfigService).updateConfig(captor.capture(), eq(Username.ANONYMOUS));
    AgentsUpdateCommand updateCommand = captor.getValue();
    assertThat(ReflectionUtil.getField(updateCommand, "command"), is(command));
}
Also used : AgentsUpdateCommand(com.thoughtworks.go.config.update.AgentsUpdateCommand)

Example 3 with AgentsUpdateCommand

use of com.thoughtworks.go.config.update.AgentsUpdateCommand in project gocd by gocd.

the class AgentConfigService method updateAgents.

private void updateAgents(final UpdateConfigCommand command, final ConfigUpdateValidator validator, Username currentUser) {
    AgentsUpdateCommand updateCommand = new AgentsUpdateCommand(command, validator);
    goConfigService.updateConfig(updateCommand, currentUser);
}
Also used : AgentsUpdateCommand(com.thoughtworks.go.config.update.AgentsUpdateCommand)

Aggregations

AgentsUpdateCommand (com.thoughtworks.go.config.update.AgentsUpdateCommand)3 AgentConfig (com.thoughtworks.go.config.AgentConfig)1 GoConfigDao (com.thoughtworks.go.config.GoConfigDao)1 AgentInstance (com.thoughtworks.go.domain.AgentInstance)1 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)1 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)1 Test (org.junit.Test)1