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 Clay Sebourn
26   */
27  public class RadAuditorTest extends OhtAuditorTestBase {
28  
29      private static final String[] STUDY_INSTANCE_UUIDS  = {"study-instance_uuid-1", "study-instance_uuid-1", "study-instance_uuid-2"};
30      private static final String[] SERIES_INSTANCE_UUIDS = {"series-instance_uuid-11", "series-instance_uuid-12", "series-instance_uuid-21"};
31      private static final String[] DOCUMENT_UUIDS        = {"document_uuid-1-11-1", "document_uuid1-11-2", "document_uuid2-21-1"};
32      private static final String[] REPOSITORY_UUIDS      = {"repository_uuid1", "repository_uuid2", "repository_uuid1"};
33      private static final String[] HOME_COMMUNITY_UUIDS  = {"home-community_uuid1", "home-community_uuid1", "home-community_uuid1"};
34  
35      @Test
36      public void testAuditors() {
37          final CustomXdsAuditor auditor = AuditorManager.getCustomXdsAuditor();
38  
39          // Client RAD-69 event
40          auditor.auditRad69(
41              false,
42              RFC3881EventOutcomeCodes.SUCCESS,
43              USER_ID,
44              USER_NAME,
45              SERVER_URI,
46              null,
47              STUDY_INSTANCE_UUIDS,
48              SERIES_INSTANCE_UUIDS,
49              DOCUMENT_UUIDS,
50              REPOSITORY_UUIDS,
51              HOME_COMMUNITY_UUIDS,
52              PATIENT_IDS[0],
53              PURPOSES_OF_USE,
54              USER_ROLES);
55  
56          // Server RAD-69 event
57          auditor.auditRad69(
58              true,
59              RFC3881EventOutcomeCodes.SUCCESS,
60              USER_ID,
61              USER_NAME,
62              SERVER_URI,
63                  CLIENT_IP_ADDRESS,
64              STUDY_INSTANCE_UUIDS,
65              SERIES_INSTANCE_UUIDS,
66              DOCUMENT_UUIDS,
67              REPOSITORY_UUIDS,
68              HOME_COMMUNITY_UUIDS,
69              PATIENT_IDS[0],
70              PURPOSES_OF_USE,
71              USER_ROLES);
72  
73          // Client RAD-75 event
74          auditor.auditRad75(
75              false,
76              RFC3881EventOutcomeCodes.SUCCESS,
77              USER_ID,
78              USER_NAME,
79              SERVER_URI,
80              null,
81              STUDY_INSTANCE_UUIDS,
82              SERIES_INSTANCE_UUIDS,
83              DOCUMENT_UUIDS,
84              REPOSITORY_UUIDS,
85              HOME_COMMUNITY_UUIDS,
86              PATIENT_IDS[0],
87              PURPOSES_OF_USE,
88              USER_ROLES);
89  
90          // Server RAD-75
91          auditor.auditRad75(
92              true,
93              RFC3881EventOutcomeCodes.SUCCESS,
94              USER_ID,
95              USER_NAME,
96              SERVER_URI,
97                  CLIENT_IP_ADDRESS,
98              STUDY_INSTANCE_UUIDS,
99              SERIES_INSTANCE_UUIDS,
100             DOCUMENT_UUIDS,
101             REPOSITORY_UUIDS,
102             HOME_COMMUNITY_UUIDS,
103             PATIENT_IDS[0],
104             PURPOSES_OF_USE,
105             USER_ROLES);
106 
107         assertEquals(4, sender.getMessages().size());
108     }
109 }