View Javadoc
1   /*
2    * Copyright 2009 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.modules.cda;
17  
18  import java.io.InputStream;
19  
20  import org.junit.Assert;
21  import org.junit.Before;
22  import org.junit.Test;
23  import org.openhealthtools.mdht.uml.cda.ClinicalDocument;
24  
25  /**
26   * @author Christian Ohr
27   */
28  public class CDAR2ParserTest {
29  
30      private CDAR2Parser parser;
31      private CDAR2Renderer renderer;
32  
33      @Before
34      public void setUp() throws Exception {
35          parser = new CDAR2Parser();
36          renderer = new CDAR2Renderer();
37      }
38  
39      @Test
40      public void testParseCDADocument() throws Exception {
41          InputStream is = getClass().getResourceAsStream(
42                  "/builders/content/document/SampleCDADocument.xml");
43          ClinicalDocument clinicalDocument = parser.parse(is);
44          // TODO test document content
45          String result = renderer.render(clinicalDocument, (Object[]) null);
46          Assert.assertTrue(result.length() > 0);
47      }
48      
49      @Test
50      public void testParseCCDDocument() throws Exception {
51          CDAR2Utils.initCCD();
52          InputStream is = getClass().getResourceAsStream(
53                  "/builders/content/document/SampleCCDDocument.xml");
54          ClinicalDocument clinicalDocument = parser.parse(is);
55          String result = renderer.render(clinicalDocument, (Object[]) null);
56          Assert.assertTrue(result.length() > 0);
57      }
58  
59      @Test
60      public void testParseHITSPDocument() throws Exception {
61          CDAR2Utils.initHITSPC32();
62          InputStream is = getClass().getResourceAsStream(
63                  "/builders/content/document/SampleHITSPC32v25Document.xml");
64          ClinicalDocument clinicalDocument = parser.parse(is);
65          String result = renderer.render(clinicalDocument, (Object[]) null);
66          Assert.assertTrue(result.length() > 0);
67      }
68      
69  }