q = em.createNamedQuery(Agent.QUERY_FIND_ALL_SUSPECT_AGENTS);
q.setParameter("dateThreshold", now - 2500);
pings = q.getResultList();
assert pings.size() == 2 + baselineSize : pings;
i = pings.indexOf(new AgentLastAvailabilityPingComposite(agent3.getId(), null, null, null, false));
assert pings.get(i).getAgentId() == agent3.getId();
assert pings.get(i).getAgentName().equals(agent3.getName());
assert pings.get(i).getRemoteEndpoint().equals(agent3.getRemoteEndpoint());
assert pings.get(i).getLastAvailabilityPing().equals(agent3.getLastAvailabilityPing());
i = pings.indexOf(new AgentLastAvailabilityPingComposite(agent4.getId(), null, null, null, false));
assert pings.get(i).getAgentId() == agent4.getId();
assert pings.get(i).getAgentName().equals(agent4.getName());
assert pings.get(i).getRemoteEndpoint().equals(agent4.getRemoteEndpoint());
assert pings.get(i).getLastAvailabilityPing().equals(agent4.getLastAvailabilityPing());
assert -1 == pings.indexOf(new AgentLastAvailabilityPingComposite(agent2.getId(), null, null, null, false));
assert -1 == pings.indexOf(new AgentLastAvailabilityPingComposite(agent1.getId(), null, null, null, false));
// add an agent with a null in the date column
Agent agent0 = createAgent(em, 0, -1);
assert em.find(Agent.class, agent0.getId()) != null;
pings = q.getResultList();
assert pings.size() == 2 + baselineSize : pings;
i = pings.indexOf(new AgentLastAvailabilityPingComposite(agent3.getId(), null, null, null, false));
assert pings.get(i).getAgentId() == agent3.getId();
assert pings.get(i).getAgentName().equals(agent3.getName());
assert pings.get(i).getRemoteEndpoint().equals(agent3.getRemoteEndpoint());
assert pings.get(i).getLastAvailabilityPing().equals(agent3.getLastAvailabilityPing());
i = pings.indexOf(new AgentLastAvailabilityPingComposite(agent4.getId(), null, null, null, false));
assert pings.get(i).getAgentId() == agent4.getId();
assert pings.get(i).getAgentName().equals(agent4.getName());
assert pings.get(i).getRemoteEndpoint().equals(agent4.getRemoteEndpoint());
assert pings.get(i).getLastAvailabilityPing().equals(agent4.getLastAvailabilityPing());
assert -1 == pings.indexOf(new AgentLastAvailabilityPingComposite(agent2.getId(), null, null, null, false));
assert -1 == pings.indexOf(new AgentLastAvailabilityPingComposite(agent1.getId(), null, null, null, false));
// get all of them, except the one with the null
q.setParameter("dateThreshold", now - 1);
pings = q.getResultList();
assert pings.size() == 4 + baselineSize : pings;