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));
}
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));
}
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);
}
Aggregations