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.transform.audit;
|
---|
7 |
|
---|
8 | import org.apache.commons.logging.Log;
|
---|
9 | import org.apache.commons.logging.LogFactory;
|
---|
10 |
|
---|
11 | import com.services.nhinc.schema.auditmessage.AuditMessageType;
|
---|
12 | import com.services.nhinc.schema.auditmessage.AuditSourceIdentificationType;
|
---|
13 | import com.services.nhinc.schema.auditmessage.EventIdentificationType;
|
---|
14 | import com.services.nhinc.schema.auditmessage.FindAuditEventsType;
|
---|
15 | import com.services.nhinc.schema.auditmessage.ParticipantObjectIdentificationType;
|
---|
16 |
|
---|
17 | import org.junit.After;
|
---|
18 | import org.junit.AfterClass;
|
---|
19 | import org.junit.Before;
|
---|
20 | import org.junit.BeforeClass;
|
---|
21 | import org.junit.Test;
|
---|
22 | import static org.junit.Assert.*;
|
---|
23 |
|
---|
24 | import gov.hhs.fha.nhinc.common.nhinccommon.HomeCommunityType;
|
---|
25 | import gov.hhs.fha.nhinc.common.nhinccommon.PersonNameType;
|
---|
26 | import gov.hhs.fha.nhinc.common.nhinccommon.UserType;
|
---|
27 | import gov.hhs.fha.nhinc.common.auditlog.LogFindAuditEventsRequestType;
|
---|
28 | import gov.hhs.fha.nhinc.common.auditlog.FindAuditEventsMessageType;
|
---|
29 | import gov.hhs.fha.nhinc.common.nhinccommon.AssertionType;
|
---|
30 | import gov.hhs.fha.nhinc.common.auditlog.LogEventRequestType;
|
---|
31 |
|
---|
32 | /**
|
---|
33 | *
|
---|
34 | * @author mflynn02
|
---|
35 | */
|
---|
36 | public class FindAuditEventsTransformsTest {
|
---|
37 | private static Log log = LogFactory.getLog(FindAuditEventsTransformsTest.class);
|
---|
38 |
|
---|
39 | public FindAuditEventsTransformsTest() {
|
---|
40 | }
|
---|
41 |
|
---|
42 | @BeforeClass
|
---|
43 | public static void setUpClass() throws Exception {
|
---|
44 | }
|
---|
45 |
|
---|
46 | @AfterClass
|
---|
47 | public static void tearDownClass() throws Exception {
|
---|
48 | }
|
---|
49 |
|
---|
50 | @Before
|
---|
51 | public void setUp() {
|
---|
52 | }
|
---|
53 |
|
---|
54 | @After
|
---|
55 | public void tearDown() {
|
---|
56 | }
|
---|
57 |
|
---|
58 | /**
|
---|
59 | * Test of transformFindAuditEventsReq2AuditMsg method, of class FindAuditEventsTransforms.
|
---|
60 | */
|
---|
61 | @Test
|
---|
62 | public void testTransformFindAuditEventsReq2AuditMsg() {
|
---|
63 | log.debug("Begin - testTransformFindAuditEventsReq2AuditMsg");
|
---|
64 | LogFindAuditEventsRequestType logMessage = new LogFindAuditEventsRequestType();
|
---|
65 | FindAuditEventsMessageType FAEMessage = new FindAuditEventsMessageType();
|
---|
66 | AssertionType assertion = new AssertionType();
|
---|
67 |
|
---|
68 | FindAuditEventsType message = new FindAuditEventsType();
|
---|
69 | HomeCommunityType home = new HomeCommunityType();
|
---|
70 | AuditData auditData = new AuditData();
|
---|
71 | auditData.setReceiverPatientId("909090");
|
---|
72 | auditData.setMessageType("findAuditEvents");
|
---|
73 | message.setPatientId("4321");
|
---|
74 |
|
---|
75 | UserType userInfo = new UserType();
|
---|
76 | home.setHomeCommunityId("2.16.840.1.113883.3.200");
|
---|
77 | home.setName("Federal - VA");
|
---|
78 | userInfo.setOrg(home);
|
---|
79 | PersonNameType person = new PersonNameType();
|
---|
80 | person.setFamilyName("Armstrong");
|
---|
81 | person.setGivenName("Neil");
|
---|
82 | userInfo.setPersonName(person);
|
---|
83 | userInfo.setUserName(person.getGivenName() + " " + person.getFamilyName());
|
---|
84 | assertion.setUserInfo(userInfo);
|
---|
85 |
|
---|
86 | FAEMessage.setAssertion(assertion);
|
---|
87 | FAEMessage.setFindAuditEvents(message);
|
---|
88 | logMessage.setMessage(FAEMessage);
|
---|
89 |
|
---|
90 | AuditMessageType expResult = new AuditMessageType();
|
---|
91 | AuditMessageType.ActiveParticipant participant = new AuditMessageType.ActiveParticipant();
|
---|
92 | participant.setUserName(person.getGivenName() + " " + person.getFamilyName());
|
---|
93 | expResult.getActiveParticipant().add(participant);
|
---|
94 | AuditSourceIdentificationType sourceId = new AuditSourceIdentificationType();
|
---|
95 | sourceId.setAuditEnterpriseSiteID(home.getName());
|
---|
96 | expResult.getAuditSourceIdentification().add(sourceId);
|
---|
97 | ParticipantObjectIdentificationType partObjId = new ParticipantObjectIdentificationType();
|
---|
98 | partObjId.setParticipantObjectID(auditData.getReceiverPatientId() + "^^^&" + home.getHomeCommunityId() + "&ISO");
|
---|
99 | expResult.getParticipantObjectIdentification().add(partObjId);
|
---|
100 | EventIdentificationType eventId = new EventIdentificationType();
|
---|
101 | eventId.setEventActionCode(AuditDataTransformConstants.EVENT_ID_CODE_SYS_NAME_ADQ);
|
---|
102 | expResult.setEventIdentification(eventId);
|
---|
103 | LogEventRequestType expected = new LogEventRequestType();
|
---|
104 | expected.setAuditMessage(expResult);
|
---|
105 |
|
---|
106 | LogEventRequestType result = FindAuditEventsTransforms.transformFindAuditEventsReq2AuditMsg(logMessage);
|
---|
107 |
|
---|
108 | assertEquals(expected.getAuditMessage().getActiveParticipant().get(0).getUserName(), result.getAuditMessage().getActiveParticipant().get(0).getUserName());
|
---|
109 | assertEquals(expected.getAuditMessage().getAuditSourceIdentification().get(0).getAuditEnterpriseSiteID(), result.getAuditMessage().getAuditSourceIdentification().get(0).getAuditEnterpriseSiteID());
|
---|
110 | assertEquals(expected.getAuditMessage().getEventIdentification().getEventActionCode(), result.getAuditMessage().getEventIdentification().getEventID().getCode());
|
---|
111 |
|
---|
112 | log.debug("End - testTransformFindAuditEventsReq2AuditMsg");
|
---|
113 | }
|
---|
114 |
|
---|
115 | }
|
---|