@Test public void shouldOnlyAssignWorkToIdleAgentsRegisteredInAgentRemoteHandler() { AgentConfig agentConfig = AgentMother.remoteAgent(); configHelper.addAgent(agentConfig); fixture.createPipelineWithFirstStageScheduled(); AgentRuntimeInfo info = AgentRuntimeInfo.fromServer(agentConfig, true, "location", 1000000l, "OS"); info.setCookie("cookie"); AgentStatus[] statuses = new AgentStatus[] { AgentStatus.Building, AgentStatus.Pending, AgentStatus.Disabled, AgentStatus.Disabled, AgentStatus.LostContact, AgentStatus.Missing }; for (AgentStatus status : statuses) { info.setStatus(status); agent = new AgentStub(); agentRemoteHandler.process(agent, new Message(Action.ping, info)); buildAssignmentService.onTimer(); assertThat( "Should not assign work when agent status is " + status, agent.messages.size(), is(0)); } }