FlowRepositoryImpl extends HibernateDaoSupport implements FlowRepository { @Override @SuppressWarnings("unchecked") public List<Long> findFlowIds(final FlowFinderCriteria finderCriteria) { return getHibernateTemplate().executeFind(new HibernateCallback() { @Override public Object doInHibernate(Session session) throws HibernateException { return execute(finderCriteria, createFlowsCriteria(finderCriteria), session, true); } }); } FlowRepositoryImpl(); @Override void initDao(); @Override void persist(Flow flow); @Override void merge(Flow flow); @Override void remove(Flow flow); @Override Flow find(Long id); @Override Flow lock(Long id); @Override int purgeFlows(FlowPurgeCriteria purgeCriteria); @Override @SuppressWarnings("unchecked") List<Flow> findFlows(final FlowFinderCriteria finderCriteria); @Override @SuppressWarnings("unchecked") List<Flow> findErrorFlows(final FlowFinderCriteria finderCriteria); @Override @SuppressWarnings("unchecked") List<Flow> findUnackFlows(final FlowFinderCriteria finderCriteria); @Override @SuppressWarnings("unchecked") List<Long> findFlowIds(final FlowFinderCriteria finderCriteria); @Override @SuppressWarnings("unchecked") List<Long> findErrorFlowIds(final FlowFinderCriteria finderCriteria); @Override @SuppressWarnings("unchecked") List<Long> findUnackFlowIds(final FlowFinderCriteria finderCriteria);  }
@Test public void testFindFlowIdsVarSince() throws Exception { Thread.sleep(2L); Flow flow = persistFlow("blah"); Date d1 = flow.getCreationTime(); Date d2 = new Date(d1.getTime() + 1L); Date d3 = new Date(d1.getTime() - 1L); testTransactionManager.commitTransaction(); testTransactionManager.beginTransaction(); List<Long> ids = flowRepository.findFlowIds(new FlowFinderCriteria(d1, null, "test")); assertEquals(1, ids.size()); assertTrue(ids.contains(flow.getIdentifier())); ids = flowRepository.findFlowIds(new FlowFinderCriteria(d1, d1, "test")); assertEquals(1, ids.size()); assertTrue(ids.contains(flow.getIdentifier())); ids = flowRepository.findFlowIds(new FlowFinderCriteria(d1, d2, "test")); assertEquals(1, ids.size()); assertTrue(ids.contains(flow.getIdentifier())); ids = flowRepository.findFlowIds(new FlowFinderCriteria(d1, d3, "test")); assertEquals(0, ids.size()); ids = flowRepository.findFlowIds(new FlowFinderCriteria(d1, null, "wrong")); assertEquals(0, ids.size()); ids = flowRepository.findFlowIds(new FlowFinderCriteria(d2, null, "test")); assertEquals(0, ids.size()); }
@Test public void testFindMaxResults() throws Exception { Date since = new Date(); persistFlow("blah"); persistFlow("blah"); persistFlow("blah"); testTransactionManager.commitTransaction(); testTransactionManager.beginTransaction(); List<Long> ids = flowRepository.findFlowIds(new FlowFinderCriteria(since, null, "test")); assertEquals(3, ids.size()); ids = flowRepository.findFlowIds(new FlowFinderCriteria(since, null, "test", 2)); assertEquals(2, ids.size()); }