@Test
public void removeAgent() {

  service.setAgentConfiguration("agent1", capabilities);
  assertEquals(1, service.getKnownAgents().size());
  service.setAgentConfiguration("agent2", capabilities);
  service.setAgentState("agent2", UPLOADING);
  verifyAgent("notAnAgent", null, capabilities);
  verifyAgent("agent1", UNKNOWN, capabilities);
  verifyAgent("agent2", UPLOADING, capabilities);
  try {
    service.removeAgent("agent1");
    assertEquals(1, service.getKnownAgents().size());
    verifyAgent("notAnAgent", null, capabilities);
    verifyAgent("agent1", null, capabilities);
    verifyAgent("agent2", UPLOADING, capabilities);
  } catch (NotFoundException e) {
    fail();
  }
  try {
    service.removeAgent("notAnAgent");
    fail();
  } catch (NotFoundException e) {
    assertNotNull(e);
  }
  assertEquals(1, service.getKnownAgents().size());
  verifyAgent("notAnAgent", null, capabilities);
  verifyAgent("agent1", null, capabilities);
  verifyAgent("agent2", UPLOADING, capabilities);
}