AsyncMsgRecordDao { public List<AsyncMsgRecord> queryForDeferredQueueProcessing() { LOG.debug("Performing database record retrieve for deferred queue manager processing."); List<AsyncMsgRecord> asyncMsgRecs = null; Session sess = null; try { sess = getSession(); if (sess != null) { Query query = sess.getNamedQuery("queryForDeferredQueueProcessing"); asyncMsgRecs = query.list(); } else { LOG.error("Failed to obtain a session from the sessionFactory"); } if (LOG.isDebugEnabled()) { LOG.debug("Completed database record retrieve for deferred queue manager processing. Results found: " + (asyncMsgRecs == null ? "0" : Integer.toString(asyncMsgRecs.size()))); } } finally { if (sess != null) { try { sess.close(); } catch (HibernateException he) { LOG.error("Failed to close session: {}", he.getLocalizedMessage(), he); } } } return asyncMsgRecs; } AsyncMsgRecordDao();  AsyncMsgRecordDao(PropertyAccessor accessor); List<AsyncMsgRecord> queryByMessageIdAndDirection(String messageId, String direction); List<AsyncMsgRecord> queryByMessageIdAndServiceName(String messageId, String serviceName); List<AsyncMsgRecord> queryByTime(Date timestamp); List<AsyncMsgRecord> queryForExpired(Date timestamp); List<AsyncMsgRecord> queryForDeferredQueueProcessing(); List<AsyncMsgRecord> queryForDeferredQueueSelected(); List<AsyncMsgRecord> queryByCriteria(QueryDeferredQueueRequestType queryCriteria); boolean insertRecords(List<AsyncMsgRecord> asyncMsgRecs); void save(AsyncMsgRecord asyncMsgRecord); void save(List<AsyncMsgRecord> asyncMsgRecs); void delete(AsyncMsgRecord asyncMsgRecord); void checkExpiration(); static final String QUEUE_DIRECTION_INBOUND; static final String QUEUE_DIRECTION_OUTBOUND; static final String QUEUE_RESPONSE_TYPE_AUTO; static final String QUEUE_RESPONSE_TYPE_EXTERNAL; static final String QUEUE_STATUS_EXPIRED; static final String QUEUE_STATUS_REQPROCESS; static final String QUEUE_STATUS_REQRCVD; static final String QUEUE_STATUS_REQRCVDACK; static final String QUEUE_STATUS_REQRCVDERR; static final String QUEUE_STATUS_REQSENT; static final String QUEUE_STATUS_REQSENTACK; static final String QUEUE_STATUS_REQSENTERR; static final String QUEUE_STATUS_RSPSELECT; static final String QUEUE_STATUS_RSPPROCESS; static final String QUEUE_STATUS_RSPRCVD; static final String QUEUE_STATUS_RSPRCVDACK; static final String QUEUE_STATUS_RSPRCVDERR; static final String QUEUE_STATUS_RSPSENT; static final String QUEUE_STATUS_RSPSENTACK; static final String QUEUE_STATUS_RSPSENTERR; }
@Test public void testQueryForDeferredQueueProcessing() { System.out.println("queryForDeferredQueueProcessing"); List<AsyncMsgRecord> asyncRecords = new ArrayList<>(); AsyncMsgRecord asyncMsgRecord = new AsyncMsgRecord(); asyncMsgRecord.setMessageId("1.1"); asyncMsgRecord.setDirection("Sevice1"); asyncMsgRecord.setCreationTime(new Date()); asyncRecords.add(asyncMsgRecord); asyncMsgRecord = new AsyncMsgRecord(); asyncMsgRecord.setMessageId("2.1"); asyncMsgRecord.setDirection("Sevice2"); asyncMsgRecord.setCreationTime(new Date()); asyncRecords.add(asyncMsgRecord); asyncMsgRecord = new AsyncMsgRecord(); asyncMsgRecord.setMessageId("3.1"); asyncMsgRecord.setDirection("Sevice3"); asyncMsgRecord.setCreationTime(new Date()); asyncRecords.add(asyncMsgRecord); Query query = mock(Query.class); when(session.getNamedQuery(Mockito.anyString())).thenReturn(query); when(query.list()).thenReturn(asyncRecords); List returnedRows = asyncMsgRecordDao.queryForDeferredQueueProcessing(); assertEquals(asyncRecords, returnedRows); }