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.iti65;
18
19 import ca.uhn.fhir.rest.api.MethodOutcome;
20 import org.hl7.fhir.dstu3.model.Bundle;
21 import org.hl7.fhir.dstu3.model.CapabilityStatement;
22 import org.junit.BeforeClass;
23 import org.junit.Ignore;
24 import org.junit.Test;
25 import org.openehealth.ipf.commons.audit.codes.*;
26 import org.openehealth.ipf.commons.audit.model.ActiveParticipantType;
27 import org.openehealth.ipf.commons.audit.model.AuditMessage;
28 import org.openehealth.ipf.commons.audit.model.ParticipantObjectIdentificationType;
29 import org.openehealth.ipf.commons.audit.queue.AbstractMockedAuditMessageQueue;
30 import org.openehealth.ipf.commons.audit.types.ParticipantObjectIdType;
31 import org.openehealth.ipf.commons.audit.utils.AuditUtils;
32 import org.openehealth.ipf.commons.ihe.fhir.audit.codes.FhirEventTypeCode;
33
34 import javax.servlet.ServletException;
35
36 import static org.junit.Assert.*;
37
38
39
40
41 public class TestIti65Success extends AbstractTestIti65 {
42
43 private static final String CONTEXT_DESCRIPTOR = "iti-65.xml";
44
45 @BeforeClass
46 public static void setUpClass() throws ServletException {
47 startServer(CONTEXT_DESCRIPTOR);
48 }
49
50 @Test
51 public void testGetConformance() {
52 CapabilityStatement conf = client.capabilities().ofType(CapabilityStatement.class).execute();
53 CapabilityStatement.CapabilityStatementRestComponent component = conf.getRest().iterator().next();
54 assertEquals(CapabilityStatement.SystemRestfulInteraction.TRANSACTION, component.getInteraction().get(0).getCode());
55 }
56
57 @Test
58 public void testSendManualMhd() throws Exception {
59
60 Bundle result = sendManually(provideAndRegister());
61
62
63
64 AbstractMockedAuditMessageQueue sender = getAuditSender();
65 assertEquals(1, sender.getMessages().size());
66 AuditMessage event = sender.getMessages().get(0);
67
68
69 assertEquals(
70 EventOutcomeIndicator.Success,
71 event.getEventIdentification().getEventOutcomeIndicator());
72 assertEquals(
73 EventActionCode.Create,
74 event.getEventIdentification().getEventActionCode());
75
76 assertEquals(EventIdCode.Import, event.getEventIdentification().getEventID());
77 assertEquals(FhirEventTypeCode.ProvideDocumentBundle, event.getEventIdentification().getEventTypeCode().get(0));
78
79
80 ActiveParticipantType source = event.getActiveParticipants().get(0);
81 assertTrue(source.isUserIsRequestor());
82 assertEquals("127.0.0.1", source.getNetworkAccessPointID());
83 assertEquals(NetworkAccessPointTypeCode.IPAddress, source.getNetworkAccessPointTypeCode());
84
85
86 ActiveParticipantType destination = event.getActiveParticipants().get(1);
87 assertFalse(destination.isUserIsRequestor());
88 assertEquals("http://localhost:" + DEMO_APP_PORT + "/", destination.getUserID());
89 assertEquals(AuditUtils.getLocalIPAddress(), destination.getNetworkAccessPointID());
90
91
92 ParticipantObjectIdentificationType patient = event.getParticipantObjectIdentifications().get(0);
93 assertEquals(ParticipantObjectTypeCode.Person, patient.getParticipantObjectTypeCode());
94 assertEquals(ParticipantObjectTypeCodeRole.Patient, patient.getParticipantObjectTypeCodeRole());
95 assertEquals(ParticipantObjectIdTypeCode.PatientNumber, patient.getParticipantObjectIDTypeCode());
96 assertEquals("Patient/a2", patient.getParticipantObjectID());
97
98
99 ParticipantObjectIdentificationType poit = event.getParticipantObjectIdentifications().get(1);
100 assertEquals(ParticipantObjectTypeCode.System, poit.getParticipantObjectTypeCode());
101 assertEquals(ParticipantObjectTypeCodeRole.Job, poit.getParticipantObjectTypeCodeRole());
102
103
104 ParticipantObjectIdType poitTypeCode = poit.getParticipantObjectIDTypeCode();
105 assertEquals("urn:uuid:a54d6aa5-d40d-43f9-88c5-b4633d873bdd", poitTypeCode.getCode());
106 assertEquals("IHE XDS Metadata", poitTypeCode.getCodeSystemName());
107 }
108
109 @Ignore
110 public void testSendEndpointMhd() throws Exception {
111 MethodOutcome result = getProducerTemplate().requestBody("direct:input", provideAndRegister(), MethodOutcome.class);
112
113
114
115 AbstractMockedAuditMessageQueue sender = getAuditSender();
116 assertEquals(2, sender.getMessages().size());
117 }
118
119
120 }