AuditRepositoryDAO { public List<AuditRepositoryRecord> queryAuditRecords(final String messageId, final String relatesTo) { Session session = null; List<AuditRepositoryRecord> queryList = null; try { session = getSession(); LOG.info("Getting Record for Audit Viewer "); if (session != null) { final Criteria queryCriteria = session.createCriteria(AuditRepositoryRecord.class); boolean idHasPrefix = NullChecker.isNotNullish(messageId) && messageId.startsWith(NhincConstants.WS_SOAP_HEADER_MESSAGE_ID_PREFIX); if (idHasPrefix) { queryCriteria.add(Restrictions.eq("messageId", messageId)); } else if (NullChecker.isNotNullish(messageId)) { queryCriteria.add( Restrictions.eq("messageId", NhincConstants.WS_SOAP_HEADER_MESSAGE_ID_PREFIX + messageId)); } if (NullChecker.isNotNullish(relatesTo)) { queryCriteria.add(Restrictions.eq("relatesTo", relatesTo)); } queryList = queryCriteria.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 testQueryByMessageIdAndCheckPrecedence() { messageId = "urn:uuid%"; outcome = 0; responseList = auditLogDao.queryAuditRecords(messageId, relatesTo); assertNotNull(responseList); }