Collection<AgentInfo> agents = (Collection<AgentInfo>) model.get("agents");
}
@Test
public void testApproveAgent() {
AgentInfo agent = new AgentInfo();
agent.setApproved(false);
agent.setName("Test-Host");
agent.setIp("127.0.0.1");
agent.setState(AgentControllerState.READY);
agentManagerRepository.save(agent);
ModelMap model = new ModelMap();
// test get agent
agentController.getOne(agent.getId(), model);
AgentInfo agentInDB = (AgentInfo) model.get("agent");
assertThat(agentInDB.getName(), is(agent.getName()));
assertThat(agentInDB.getIp(), is(agent.getIp()));
assertThat(agentInDB.isApproved(), is(false));
// test approve agent
model.clear();
agentController.approve(agentInDB.getId());
agentController.getOne(agent.getId(), model);
agentInDB = (AgentInfo) model.get("agent");
assertThat(agentInDB.isApproved(), is(true));
// test un-approve
model.clear();
agentController.disapprove(agentInDB.getId());
agentController.getOne(agent.getId(), model);
agentInDB = (AgentInfo) model.get("agent");
assertThat(agentInDB.isApproved(), is(false));
}