View Javadoc
1   /*
2    * Copyright 2012 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.openehealth.ipf.commons.ihe.core.atna;
17  
18  import org.junit.Test;
19  import org.openehealth.ipf.commons.ihe.core.atna.custom.CustomXdsAuditor;
20  import org.openhealthtools.ihe.atna.auditor.codes.rfc3881.RFC3881EventCodes.RFC3881EventOutcomeCodes;
21  
22  import static org.junit.Assert.assertEquals;
23  
24  /**
25   * @author Dmytro Rud
26   */
27  public class XdsAuditorTest extends OhtAuditorTestBase {
28  
29      private static final String SUBMISSION_SET_ID    = "submission-set-id";
30      private static final String[] OBJECT_UUIDS       = {"objectUuid1", "objectUuid2", "objectUuid3"};
31      private static final String[] DOCUMENT_OIDS      = {"1.1.1", "1.1.2", "1.1.3"};
32      private static final String[] REPOSITORY_OIDS    = {"2.1.1", "2.1.2", "2.1.3"};
33      private static final String[] HOME_COMMUNITY_IDS = {"3.1.1", "3.1.2", "3.1.3"};
34  
35      @Test
36      public void testAuditors() {
37          final CustomXdsAuditor auditor = AuditorManager.getCustomXdsAuditor();
38  
39          auditor.auditIti51(true,
40                  RFC3881EventOutcomeCodes.SUCCESS, REPLY_TO_URI, USER_NAME, SERVER_URI, CLIENT_IP_ADDRESS,
41                  QUERY_ID,
42                  QUERY_PAYLOAD,
43                  HOME_COMMUNITY_ID,
44                  PATIENT_IDS[0],
45                  PURPOSES_OF_USE,
46                  USER_ROLES);
47  
48          auditor.auditIti51(false,
49                  RFC3881EventOutcomeCodes.SUCCESS, REPLY_TO_URI, USER_NAME, SERVER_URI, null,
50                  QUERY_ID,
51                  QUERY_PAYLOAD,
52                  HOME_COMMUNITY_ID,
53                  PATIENT_IDS[0],
54                  PURPOSES_OF_USE,
55                  USER_ROLES);
56  
57          auditor.auditIti61(true,
58                  RFC3881EventOutcomeCodes.SUCCESS, REPLY_TO_URI, USER_NAME, SERVER_URI, CLIENT_IP_ADDRESS,
59                  SUBMISSION_SET_ID,
60                  PATIENT_IDS[0],
61                  PURPOSES_OF_USE,
62                  USER_ROLES);
63  
64          auditor.auditIti61(false,
65                  RFC3881EventOutcomeCodes.SUCCESS, REPLY_TO_URI, USER_NAME, SERVER_URI, null,
66                  SUBMISSION_SET_ID,
67                  PATIENT_IDS[0],
68                  PURPOSES_OF_USE,
69                  USER_ROLES);
70  
71          auditor.auditIti62(true,
72                  RFC3881EventOutcomeCodes.SUCCESS, REPLY_TO_URI, USER_NAME, SERVER_URI, CLIENT_IP_ADDRESS,
73                  PATIENT_IDS[0],
74                  OBJECT_UUIDS,
75                  PURPOSES_OF_USE,
76                  USER_ROLES);
77  
78          auditor.auditIti62(false,
79                  RFC3881EventOutcomeCodes.SUCCESS, REPLY_TO_URI, USER_NAME, SERVER_URI, null,
80                  PATIENT_IDS[0],
81                  OBJECT_UUIDS,
82                  PURPOSES_OF_USE,
83                  USER_ROLES);
84  
85          auditor.auditIti63(true,
86                  RFC3881EventOutcomeCodes.SUCCESS, REPLY_TO_URI, USER_NAME, SERVER_URI, CLIENT_IP_ADDRESS,
87                  QUERY_ID,
88                  QUERY_PAYLOAD,
89                  HOME_COMMUNITY_ID,
90                  PATIENT_IDS[0],
91                  PURPOSES_OF_USE,
92                  USER_ROLES);
93  
94          auditor.auditIti63(false,
95                  RFC3881EventOutcomeCodes.SUCCESS, REPLY_TO_URI, USER_NAME, SERVER_URI, null,
96                  QUERY_ID,
97                  QUERY_PAYLOAD,
98                  HOME_COMMUNITY_ID,
99                  PATIENT_IDS[0],
100                 PURPOSES_OF_USE,
101                 USER_ROLES);
102 
103         auditor.auditIti86(true,
104                 RFC3881EventOutcomeCodes.SUCCESS, REPLY_TO_URI, USER_NAME, SERVER_URI, CLIENT_IP_ADDRESS,
105                 PATIENT_IDS[0],
106                 DOCUMENT_OIDS,
107                 REPOSITORY_OIDS,
108                 HOME_COMMUNITY_IDS,
109                 PURPOSES_OF_USE,
110                 USER_ROLES);
111 
112         auditor.auditIti86(false,
113                 RFC3881EventOutcomeCodes.SUCCESS, REPLY_TO_URI, USER_NAME, SERVER_URI, CLIENT_IP_ADDRESS,
114                 PATIENT_IDS[0],
115                 DOCUMENT_OIDS,
116                 REPOSITORY_OIDS,
117                 HOME_COMMUNITY_IDS,
118                 PURPOSES_OF_USE,
119                 USER_ROLES);
120 
121         assertEquals(10, sender.getMessages().size());
122     }
123 
124 }