1 | /*
|
---|
2 | * To change this template, choose Tools | Templates
|
---|
3 | * and open the template in the editor.
|
---|
4 | */
|
---|
5 |
|
---|
6 | package gov.hhs.fha.nhinc.hibernate;
|
---|
7 |
|
---|
8 | import java.util.Date;
|
---|
9 | import java.util.List;
|
---|
10 | import org.junit.After;
|
---|
11 | import org.junit.AfterClass;
|
---|
12 | import org.junit.Before;
|
---|
13 | import org.junit.BeforeClass;
|
---|
14 | import org.junit.Test;
|
---|
15 | import static org.junit.Assert.*;
|
---|
16 |
|
---|
17 | import org.apache.commons.logging.*;
|
---|
18 | import java.util.ArrayList;
|
---|
19 |
|
---|
20 | /**
|
---|
21 | *
|
---|
22 | * @author MFLYNN02
|
---|
23 | */
|
---|
24 | public class AuditRepositoryDAOTest {
|
---|
25 | private AuditRepositoryDAO auditDao =null;
|
---|
26 | private static Log log = LogFactory.getLog(AuditRepositoryDAOTest.class);
|
---|
27 | public AuditRepositoryDAOTest() {
|
---|
28 | auditDao = AuditRepositoryDAO.getAuditRepositoryDAOInstance();
|
---|
29 | }
|
---|
30 |
|
---|
31 | @BeforeClass
|
---|
32 | public static void setUpClass() throws Exception {
|
---|
33 | }
|
---|
34 |
|
---|
35 | @AfterClass
|
---|
36 | public static void tearDownClass() throws Exception {
|
---|
37 | }
|
---|
38 |
|
---|
39 | @Before
|
---|
40 | public void setUp() {
|
---|
41 | }
|
---|
42 |
|
---|
43 | @After
|
---|
44 | public void tearDown() {
|
---|
45 | }
|
---|
46 |
|
---|
47 | /**
|
---|
48 | * Test of getAuditRepositoryDAOInstance method, of class AuditRepositoryDAO.
|
---|
49 | */
|
---|
50 | @Test
|
---|
51 | public void testGetAuditRepositoryDAOInstance() {
|
---|
52 | AuditRepositoryDAO result = AuditRepositoryDAO.getAuditRepositoryDAOInstance();
|
---|
53 | }
|
---|
54 |
|
---|
55 | /**
|
---|
56 | * Test of queryAuditRepository method, of class AuditRepositoryDAO.
|
---|
57 | */
|
---|
58 | @Test
|
---|
59 | public void testQueryAuditRepository() {
|
---|
60 | log.debug("Begin - testQueryAuditRepository");
|
---|
61 |
|
---|
62 | String query = "select * from auditRepository";
|
---|
63 | List result = auditDao.queryAuditRepository(query);
|
---|
64 | assertNotNull(result);
|
---|
65 | log.debug("getAuditRepository number of records : " + result.size());
|
---|
66 |
|
---|
67 | log.debug("End - testQueryAuditRepository");
|
---|
68 | }
|
---|
69 |
|
---|
70 | /**
|
---|
71 | * Test of insertAuditRepository method, of class AuditRepositoryDAO.
|
---|
72 | */
|
---|
73 | @Test
|
---|
74 | public void testInsertAuditRepository() {
|
---|
75 | log.debug("Begin - testInsertAuditRepository");
|
---|
76 | List<AuditRepositoryRecord> eventLogList = new ArrayList();
|
---|
77 | Date now = new Date();
|
---|
78 |
|
---|
79 | AuditRepositoryRecord record = new AuditRepositoryRecord();
|
---|
80 | record.setMessageType("Record 1 - Message Type");
|
---|
81 | record.setTimeStamp(now);
|
---|
82 | record.setUserId("UnitTest1");
|
---|
83 | eventLogList.add(record);
|
---|
84 |
|
---|
85 | boolean expResult = true;
|
---|
86 | boolean result = auditDao.insertAuditRepository(eventLogList);
|
---|
87 | assertEquals(expResult, result);
|
---|
88 | log.debug ("End - testInsertAuditRepository");
|
---|
89 | }
|
---|
90 |
|
---|
91 | /**
|
---|
92 | * Test of queryAuditRepositoryOnCriteria method, of class AuditRepositoryDAO.
|
---|
93 | */
|
---|
94 | @Test
|
---|
95 | public void testQueryAuditRepositoryOnCriteria() {
|
---|
96 | log.debug("Begin - testQueryAuditRepositoryOnCriteria");
|
---|
97 | String eUserId = "UnitTest1";
|
---|
98 | String ePatientId = "";
|
---|
99 | String eCommunityId = "";
|
---|
100 | Date startDate = null;
|
---|
101 | Date endDate = null;
|
---|
102 | List result = auditDao.queryAuditRepositoryOnCriteria(eUserId, ePatientId, startDate, endDate);
|
---|
103 | assertNotNull(result);
|
---|
104 | log.debug("Number of records returned : " + result.size());
|
---|
105 | log.debug("End - testQueryAuditRepositoryOnCriteria");
|
---|
106 | }
|
---|
107 |
|
---|
108 | }
|
---|