AuditRepositoryDAO { public boolean insertAuditRepository(final List<AuditRepositoryRecord> auditList) { Session session = null; boolean result = true; if (auditList != null && !auditList.isEmpty()) { final int size = auditList.size(); AuditRepositoryRecord auditRecord = null; Transaction tx = null; try { session = getSession(); tx = session.beginTransaction(); LOG.info("Inserting Record..."); for (int i = 0; i < size; i++) { auditRecord = auditList.get(i); session.persist(auditRecord); } tx.commit(); LOG.info("AuditRepository List Inserted successfully..."); } catch (final HibernateException e) { result = false; if (tx != null) { tx.rollback(); } LOG.error("Error during insertion caused by : {}", e.getLocalizedMessage(), e); } finally { closeSession(session); } } return result; } 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 testInsertAuditRepository() { List<AuditRepositoryRecord> eventLogList = new ArrayList(); Date now = new Date(); AuditRepositoryRecord record = new AuditRepositoryRecord(); record.setDirection("Record 1 - Message Type"); record.setEventTimestamp(now); record.setUserId("UnitTest1"); eventLogList.add(record); boolean expResult = true; boolean result = auditDao.insertAuditRepository(eventLogList); assertEquals(expResult, result); }