1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.openehealth.ipf.platform.camel.ihe.fhir.iti68;
18
19 import org.junit.BeforeClass;
20 import org.junit.Test;
21 import org.openehealth.ipf.commons.audit.codes.*;
22 import org.openehealth.ipf.commons.audit.model.ActiveParticipantType;
23 import org.openehealth.ipf.commons.audit.model.AuditMessage;
24 import org.openehealth.ipf.commons.audit.model.AuditSourceIdentificationType;
25 import org.openehealth.ipf.commons.audit.model.ParticipantObjectIdentificationType;
26 import org.openehealth.ipf.commons.audit.queue.AbstractMockedAuditMessageQueue;
27 import org.openehealth.ipf.commons.audit.utils.AuditUtils;
28 import org.openehealth.ipf.commons.ihe.fhir.audit.codes.FhirEventTypeCode;
29
30 import javax.servlet.ServletException;
31
32 import static org.junit.Assert.*;
33
34
35
36
37 public class TestIti68Success extends AbstractTestIti68 {
38
39 private static final String CONTEXT_DESCRIPTOR = "iti-68.xml";
40
41 @BeforeClass
42 public static void setUpClass() {
43 startServer(CONTEXT_DESCRIPTOR);
44 }
45
46
47 @Test
48 public void testRetrieveDocument() {
49
50 byte[] response = getProducerTemplate().requestBody("direct:input", null, byte[].class);
51 assertArrayEquals(Iti68TestRouteBuilder.DATA, response);
52
53
54
55 AbstractMockedAuditMessageQueue sender = getAuditSender();
56 assertEquals(1, sender.getMessages().size());
57 AuditMessage event = sender.getMessages().get(0);
58
59
60 assertEquals(
61 EventOutcomeIndicator.Success,
62 event.getEventIdentification().getEventOutcomeIndicator());
63 assertEquals(
64 EventActionCode.Create,
65 event.getEventIdentification().getEventActionCode());
66 assertEquals(EventIdCode.Export, event.getEventIdentification().getEventID());
67 assertEquals(FhirEventTypeCode.MobileDocumentRetrieval, event.getEventIdentification().getEventTypeCode().get(0));
68
69
70
71 ActiveParticipantType source = event.getActiveParticipants().get(0);
72 assertTrue(source.isUserIsRequestor());
73 assertEquals("127.0.0.1", source.getNetworkAccessPointID());
74 assertEquals(NetworkAccessPointTypeCode.IPAddress, source.getNetworkAccessPointTypeCode());
75
76
77 ActiveParticipantType destination = event.getActiveParticipants().get(1);
78 assertFalse(destination.isUserIsRequestor());
79 assertEquals(AuditUtils.getLocalIPAddress(), destination.getNetworkAccessPointID());
80 assertEquals("http://localhost:" + DEMO_APP_PORT + "/", destination.getUserID());
81
82
83 AuditSourceIdentificationType sourceIdentificationType = event.getAuditSourceIdentification();
84 assertEquals("IPF", sourceIdentificationType.getAuditSourceID());
85 assertEquals("IPF", sourceIdentificationType.getAuditEnterpriseSiteID());
86
87 ParticipantObjectIdentificationType poit = event.findParticipantObjectIdentifications(p ->
88 p.getParticipantObjectTypeCode() == ParticipantObjectTypeCode.System).get(0);
89 assertEquals(Iti68TestRouteBuilder.DOCUMENT_UNIQUE_ID, poit.getParticipantObjectID());
90 assertEquals(2, poit.getParticipantObjectDetails().size());
91
92 }
93
94
95 }