@Test(groups = "integration.ejb3")
public void testFindScheduleByResourceAndDefinition() throws Exception {
getTransactionManager().begin();
EntityManager em = getEntityManager();
try {
MeasurementDefinition def = setupTables(em);
List<MeasurementSchedule> schedules = def.getSchedules();
MeasurementSchedule sched = schedules.get(0);
Resource res = sched.getResource();
Query q = em.createNamedQuery(MeasurementSchedule.FIND_BY_RESOURCE_IDS_AND_DEFINITION_IDS);
q.setParameter("definitionIds", ArrayUtils.wrapInList(new int[] { def.getId() }));
q.setParameter("resourceIds", ArrayUtils.wrapInList(new int[] { res.getId() }));
List<MeasurementSchedule> scheds = q.getResultList();
assert scheds.size() == 1 : "Did not find 1 schedule, but " + scheds.size();
int rid = res.getId();
q = em.createNamedQuery(MeasurementSchedule.FIND_BY_RESOURCE_IDS_AND_DEFINITION_IDS);
q.setParameter("definitionIds", ArrayUtils.wrapInList(new int[] { def.getId() }));
q.setParameter("resourceIds", ArrayUtils.wrapInList(new int[] { rid, rid, rid, rid }));
scheds = q.getResultList();
assert scheds.size() == 1 : "Did not find 1 schedule, but " + scheds.size();
} finally {