AuditRepositoryDAO { public List queryAuditRepositoryOnCriteria(final String eUserId, final String ePatientId, final Date startDate, final Date endDate) { List<AuditRepositoryRecord> queryList = new ArrayList<>(); Session session = null; if (eUserId == null && ePatientId == null && startDate == null) { LOG.info("-- No - Input Parameters found for Audit Query --"); return queryList; } try { session = getSession(); LOG.info("Getting Record"); if (session != null) { final Criteria aCriteria = session.createCriteria(AuditRepositoryRecord.class); if (eUserId != null && !eUserId.isEmpty()) { aCriteria.add(Expression.eq("userId", eUserId)); } if (ePatientId != null && !ePatientId.isEmpty()) { aCriteria.add(Expression.eq("receiverPatientId", ePatientId)); } if (startDate != null && endDate != null) { aCriteria.add(Expression.between("timeStamp", new Date(startDate.getTime()), new Date(endDate.getTime()))); } else if (startDate != null) { aCriteria.add(Expression.ge("timeStamp", new Date(startDate.getTime()))); } queryList = aCriteria.list(); } } catch (final HibernateException e) { LOG.error("Exception in AuditLog.get() occurred due to : {}", e.getLocalizedMessage(), e); } finally { closeSession(session); } return queryList; } AuditRepositoryDAO(); boolean insertAuditRepository(final List<AuditRepositoryRecord> auditList); List queryAuditRepositoryOnCriteria(final String eUserId, final String ePatientId, final Date startDate,
            final Date endDate); List<AuditRepositoryRecord> queryAuditRecords(final String messageId, final String relatesTo); List<AuditRepositoryRecord> queryByAuditOptions(final List<String> eventTypeList, final String userId,
            final List<String> remoteHcidList, final Date startDate, final Date endDate); Blob queryByAuditId(final long auditId);  }
@Test public void testQueryAuditRepositoryOnCriteria() { String eUserId = "UnitTest1"; String ePatientId = ""; String eCommunityId = ""; Date startDate = null; Date endDate = null; List result = auditDao.queryAuditRepositoryOnCriteria(eUserId, ePatientId, startDate, endDate); assertNotNull(result); }