1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.openehealth.ipf.modules.cda.support;
17
18 import org.junit.Before;
19 import org.junit.Test;
20 import org.openehealth.ipf.commons.xml.SchematronProfile;
21 import org.openehealth.ipf.commons.xml.SchematronValidator;
22 import org.openehealth.ipf.commons.xml.XsdValidator;
23
24 import javax.xml.transform.Source;
25 import javax.xml.transform.stream.StreamSource;
26 import java.util.HashMap;
27 import java.util.Map;
28
29 import static org.openehealth.ipf.modules.cda.CDAR2Constants.*;
30
31
32
33
34
35
36
37 public class HITSPC32ValidationTest {
38
39 private XsdValidator validator;
40 private SchematronValidator schematron;
41 private Map<String, Object> params;
42
43 private static final String sample_c32 = "/MU_Rev3_HITSP_C32C83_4Sections_RobustEntries_NoErrors.xml";
44
45 @Before
46 public void setUp() throws Exception {
47 validator = new XsdValidator();
48 params = new HashMap<>();
49 params.put("phase", "errors");
50 schematron = new SchematronValidator();
51 }
52
53 @Test
54 public void validateSchemaGoodSample24() throws Exception {
55 Source testXml = new StreamSource(getClass().getResourceAsStream(sample_c32));
56 validator.validate(testXml, HITSP_32_2_4_SCHEMA);
57 }
58
59 @Test
60 public void validateSchemaGoodSample25() throws Exception {
61 Source testXml = new StreamSource(getClass().getResourceAsStream(sample_c32));
62 validator.validate(testXml, HITSP_32_2_5_SCHEMA);
63 }
64
65 @Test
66 public void validateComplete24() throws Exception {
67 Source testXml = new StreamSource(getClass().getResourceAsStream(sample_c32));
68 schematron.validate(testXml, new SchematronProfile(
69 HITSP_32_2_4_SCHEMATRON_RULES, params));
70 }
71
72 @Test
73 public void validateComplete25() throws Exception {
74 Source testXml = new StreamSource(getClass().getResourceAsStream(sample_c32));
75 schematron.validate(testXml, new SchematronProfile(
76 HITSP_32_2_5_SCHEMATRON_RULES, params));
77 }
78 }