1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.openehealth.ipf.commons.ihe.hl7v2ws.pcd01;
17
18 import org.junit.Test;
19
20 import ca.uhn.hl7v2.HL7Exception;
21
22
23
24
25
26 public class QA_Pcd01MSHValidatorTest extends AbstractPCD01ValidatorTest {
27
28 @Test
29 public void testMaximalMessage() throws HL7Exception {
30 validate(maximumMessage);
31 }
32
33
34 @Test(expected = HL7Exception.class)
35 public void testMissingMSH3() throws HL7Exception {
36 validate(maxMsgReplace("AcmeInc^ACDE48234567ABCD^EUI-64", ""));
37 }
38
39 @Test(expected = HL7Exception.class)
40 public void testMissingMSH7() throws HL7Exception {
41 validate(maxMsgReplace("20090713090030+0500", ""));
42 }
43
44 @Test(expected = HL7Exception.class)
45 public void testMissingMSH9() throws HL7Exception {
46 validate(maxMsgReplace("ORU^R01^ORU_R01", ""));
47 }
48
49 @Test(expected = HL7Exception.class)
50 public void testMissingMSH9dot1() throws HL7Exception {
51 validate(maxMsgReplace("ORU^R01^ORU_R01", "^R01^ORU_R01"));
52 }
53
54 @Test(expected = HL7Exception.class)
55 public void testMissingMSH9dot1_9dot3() throws HL7Exception {
56 validate(maxMsgReplace("ORU^R01^ORU_R01", "^R01"));
57 }
58
59 @Test(expected = Exception.class)
60 public void testMissingMSH9dot2_9dot3() throws HL7Exception {
61 validate(maxMsgReplace("ORU^R01^ORU_R01", "ORU"));
62 }
63
64 @Test(expected = HL7Exception.class)
65 public void testMissingMSH10() throws HL7Exception {
66 validate(maxMsgReplace("MSGID1234", ""));
67 }
68
69 @Test(expected = HL7Exception.class)
70 public void testMissingMSH11() throws HL7Exception {
71 validate(maxMsgReplace("P", ""));
72 }
73
74 @Test(expected = HL7Exception.class)
75 public void testWrongMSH11() throws HL7Exception {
76 validate(maxMsgReplace("P", "X"));
77 }
78
79 @Test(expected = HL7Exception.class)
80 public void testMissingMSH12() throws HL7Exception {
81 validate(maxMsgReplace("2.6", ""));
82 }
83
84 @Test(expected = HL7Exception.class)
85 public void testMissingMSH21() throws HL7Exception {
86 validate(maxMsgReplace("IHE PCD ORU-R01 2006^HL7^1.3.6.1.4.1.19376.1.6.1.1.1^ISO",
87 ""));
88 }
89
90 @Test(expected = HL7Exception.class)
91 public void testMissingMSH21dot1() throws HL7Exception {
92 validate(maxMsgReplace("IHE PCD ORU-R01 2006^HL7^1.3.6.1.4.1.19376.1.6.1.1.1^ISO",
93 "^HL7^2.16.840.1.113883.9.n.m^HL7"));
94 }
95
96 @Test(expected = HL7Exception.class)
97 public void testMissingMSH21dot2_3_4() throws HL7Exception {
98 validate(maxMsgReplace("IHE PCD ORU-R01 2006^HL7^1.3.6.1.4.1.19376.1.6.1.1.1^ISO",
99 "IHE PCD ORU-R01 2006"));
100 }
101
102 @Test(expected = HL7Exception.class)
103 public void testMissingMSH21dot2_3() throws HL7Exception {
104 validate(maxMsgReplace("IHE PCD ORU-R01 2006^HL7^1.3.6.1.4.1.19376.1.6.1.1.1^ISO",
105 "IHE PCD ORU-R01 2006^^^HL7"));
106 }
107
108 }