View Javadoc
1   /*
2    * Copyright 2011 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.hl7v2ws.pcd01;
17  
18  import ca.uhn.hl7v2.HL7Exception;
19  import org.junit.Test;
20  
21  /**
22   * @author Kingsley Nwaigbo
23   * 
24   */
25  public class QA_Pcd01PIDPV1ValidatorTest extends AbstractPCD01ValidatorTest {
26  
27      // ################ PID Segment tests ###############################
28  
29      @Test(expected = HL7Exception.class)
30      public void testMissingPID3() throws HL7Exception {
31          validate(maxMsgReplace("111222333444^^^Imaginary Hospital&1.3.4.565&ISO^PI",
32                                 ""));
33      }
34  
35      @Test(expected = HL7Exception.class)
36      public void testSpaceAsPID3() throws HL7Exception {
37          validate(maxMsgReplace("111222333444^^^Imaginary Hospital&1.3.4.565&ISO^PI",
38                                 " "));
39      }
40  
41      @Test(expected = HL7Exception.class)
42      public void testMissingPID3_1() throws HL7Exception {
43          validate(maxMsgReplace("111222333444^^^Imaginary Hospital&1.3.4.565&ISO^PI",
44                                 "^^^Imaginary Hospital&1.3.4.565&ISO^PI"));
45      }
46  
47      @Test(expected = HL7Exception.class)
48      public void testMissingPID34_1_2_3() throws HL7Exception {
49          validate(maxMsgReplace("111222333444^^^Imaginary Hospital&1.3.4.565&ISO^PI",
50                                 "111222333444"));
51      }
52  
53      @Test(expected = HL7Exception.class)
54      public void testMissingPID34_1_2() throws HL7Exception {
55          validate(maxMsgReplace("111222333444^^^Imaginary Hospital&1.3.4.565&ISO^PI",
56                                 "111222333444^^^ISO"));
57      }
58  
59      @Test(expected = HL7Exception.class)
60      public void testMissingPID5() throws HL7Exception {
61          validate(maxMsgReplace("Doe^John^Joseph", ""));
62      }
63  
64      @Test
65      public void testMissingPID5_1() throws HL7Exception {
66          validate(maxMsgReplace("Doe^John^Joseph", "^John^Joseph"));
67      }
68  
69      @Test
70      public void testMissingPID5_2_3() throws HL7Exception {
71          validate(maxMsgReplace("Doe^John^Joseph", "Doe^^"));
72      }
73  
74      @Test(expected = HL7Exception.class)
75      public void testMissingPV12() throws HL7Exception {
76          validate(maxMsgReplace("|I|", "||"));
77      }
78  
79  }