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.platform.camel.ihe.xds.core.converters;
17  
18  import static org.junit.Assert.assertEquals;
19  import org.junit.Test;
20  import org.openehealth.ipf.commons.ihe.xds.core.SampleData;
21  import org.openehealth.ipf.commons.ihe.xds.core.ebxml.ebxml30.ProvideAndRegisterDocumentSetRequestType;
22  import org.openehealth.ipf.commons.ihe.xds.core.ebxml.ebxml30.RetrieveDocumentSetRequestType;
23  import org.openehealth.ipf.commons.ihe.xds.core.ebxml.ebxml30.RetrieveImagingDocumentSetRequestType;
24  import org.openehealth.ipf.commons.ihe.xds.core.requests.*;
25  import org.openehealth.ipf.commons.ihe.xds.core.responses.QueryResponse;
26  import org.openehealth.ipf.commons.ihe.xds.core.responses.Response;
27  import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.lcm.SubmitObjectsRequest;
28  import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.query.AdhocQueryRequest;
29  import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.query.AdhocQueryResponse;
30  import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.rs.RegistryResponseType;
31  
32  /**
33   * Tests for {@link EbXML30Converters}.
34   * @author Jens Riemschneider
35   */
36  public class TestEbXML30Converters {
37      @Test
38      public void testConvertProvideAndRegisterDocumentSet() {
39          ProvideAndRegisterDocumentSet org = SampleData.createProvideAndRegisterDocumentSet();
40          ProvideAndRegisterDocumentSetRequestType converted = EbXML30Converters.convert(org);
41          ProvideAndRegisterDocumentSet copy = EbXML30Converters.convert(converted);
42          assertEquals(org, copy);
43      }
44  
45      @Test
46      public void testConvertRegisterDocumentSet() {
47          RegisterDocumentSet org = SampleData.createRegisterDocumentSet();
48          SubmitObjectsRequest converted = EbXML30Converters.convert(org);
49          RegisterDocumentSet copy = EbXML30Converters.convert(converted);
50          assertEquals(org, copy);
51      }
52  
53      @Test
54      public void testConvertResponse() {
55          Response org = SampleData.createResponse();
56          RegistryResponseType converted = EbXML30Converters.convert(org);
57          Response copy = EbXML30Converters.convert(converted);
58          assertEquals(org, copy);
59      }
60  
61      @Test
62      public void testConvertQueryRegistry() {
63          QueryRegistry org = SampleData.createFindDocumentsQuery();
64          AdhocQueryRequest converted = EbXML30Converters.convert(org);
65          QueryRegistry copy = EbXML30Converters.convert(converted);
66          assertEquals(org, copy);
67      }
68  
69      @Test
70      public void testConvertQueryResponse() {
71          QueryResponse org = SampleData.createQueryResponseWithLeafClass();
72          AdhocQueryResponse converted = EbXML30Converters.convert(org);
73          QueryResponse copy = EbXML30Converters.convertToQueryResponse(converted);
74          assertEquals(org, copy);
75      }
76  
77      @Test
78      public void testConvertRetrieveDocumentSet() {
79          RetrieveDocumentSet org = SampleData.createRetrieveDocumentSet();
80          RetrieveDocumentSetRequestType converted = EbXML30Converters.convert(org);
81          RetrieveDocumentSet copy = EbXML30Converters.convert(converted);
82          assertEquals(org, copy);
83      }
84  
85      @Test
86      public void testConvertRetrieveImagingDocumentSet() {
87          RetrieveImagingDocumentSet org = SampleData.createRetrieveImagingDocumentSet();
88          RetrieveImagingDocumentSetRequestType converted = EbXML30Converters.convert(org);
89          RetrieveImagingDocumentSet copy = EbXML30Converters.convert(converted);
90          assertEquals(org, copy);
91      }
92  }