public void sync(Agents agents) { agentInstances.sync(agents); }
@Test public void shouldAddAgentIntoMemoryAfterAgentIsManuallyAddedInConfigFile() throws Exception { AgentInstances agentInstances = new AgentInstances(mock(AgentStatusChangeListener.class)); AgentConfig agentConfig = new AgentConfig("uuid20", "CCeDev01", "10.18.5.20"); agentInstances.sync(new Agents(agentConfig)); assertThat(agentInstances.size(), is(1)); assertThat(agentInstances.findAgentAndRefreshStatus("uuid20").agentConfig(), is(agentConfig)); }
@Test public void shouldRemoveAgentWhenAgentIsRemovedFromConfigFile() throws Exception { AgentInstances agentInstances = new AgentInstances(systemEnvironment, agentStatusChangeListener, idle, building); Agents oneAgentIsRemoved = new Agents(new AgentConfig("uuid2", "CCeDev01", "10.18.5.1")); agentInstances.sync(oneAgentIsRemoved); assertThat(agentInstances.size(), is(1)); assertThat(agentInstances.findAgentAndRefreshStatus("uuid2"), is(idle)); assertThat(agentInstances.findAgentAndRefreshStatus("uuid1"), is(new NullAgentInstance("uuid1"))); }
@Test public void shouldNotRemovePendingAgentDuringSync() throws Exception { AgentInstances agentInstances = new AgentInstances(systemEnvironment, agentStatusChangeListener, AgentInstanceMother.building()); agentInstances.add(pending); Agents agents = new Agents(); agentInstances.sync(agents); assertThat(agentInstances.size(), is(1)); assertThat(agentInstances.findAgentAndRefreshStatus("uuid4").getStatus(), is(AgentStatus.Pending)); }
@Test public void shouldSyncAgent() throws Exception { AgentInstances agentInstances = new AgentInstances(systemEnvironment, agentStatusChangeListener, AgentInstanceMother.building(), idle); AgentConfig agentConfig = new AgentConfig("uuid2", "CCeDev01", "10.18.5.1"); agentConfig.setDisabled(true); Agents oneAgentIsRemoved = new Agents(agentConfig); agentInstances.sync(oneAgentIsRemoved); assertThat(agentInstances.findAgentAndRefreshStatus("uuid2").getStatus(), is(AgentStatus.Disabled)); }