use of org.opennms.netmgt.dao.api.MinionDao in project opennms by OpenNMS.
the class MinionHeartBeatIT method minionHeartBeatTestForLastUpdated.
@Test
public void minionHeartBeatTestForLastUpdated() {
Date startOfTest = new Date();
InetSocketAddress pgsql = m_testEnvironment.getServiceAddress(ContainerAlias.POSTGRES, 5432);
HibernateDaoFactory daoFactory = new HibernateDaoFactory(pgsql);
MinionDao minionDao = daoFactory.getDao(MinionDaoHibernate.class);
NodeDao nodeDao = daoFactory.getDao(NodeDaoHibernate.class);
// The heartbeat runs every minute so if we miss the first one, poll long enough
// to catch the next one
await().atMost(90, SECONDS).pollInterval(5, SECONDS).until(DaoUtils.countMatchingCallable(minionDao, new CriteriaBuilder(OnmsMinion.class).ge("lastUpdated", startOfTest).toCriteria()), greaterThan(0));
await().atMost(180, SECONDS).pollInterval(5, SECONDS).until(DaoUtils.countMatchingCallable(nodeDao, new CriteriaBuilder(OnmsNode.class).eq("foreignSource", "Minions").eq("foreignId", "00000000-0000-0000-0000-000000ddba11").toCriteria()), equalTo(1));
Assert.assertEquals("MINION", nodeDao.get("Minions:00000000-0000-0000-0000-000000ddba11").getLocation().getLocationName());
}
Aggregations