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.commons.ihe.xds.core.transform.requests;
17  
18  import static org.junit.Assert.*;
19  
20  import org.junit.Before;
21  import org.junit.Test;
22  import org.openehealth.ipf.commons.ihe.xds.core.ebxml.EbXMLAdhocQueryRequest;
23  import org.openehealth.ipf.commons.ihe.xds.core.requests.QueryRegistry;
24  import org.openehealth.ipf.commons.ihe.xds.core.requests.query.FindDocumentsQuery;
25  import org.openehealth.ipf.commons.ihe.xds.core.requests.query.FindFoldersQuery;
26  import org.openehealth.ipf.commons.ihe.xds.core.requests.query.FindSubmissionSetsQuery;
27  import org.openehealth.ipf.commons.ihe.xds.core.requests.query.GetAllQuery;
28  import org.openehealth.ipf.commons.ihe.xds.core.requests.query.GetAssociationsQuery;
29  import org.openehealth.ipf.commons.ihe.xds.core.requests.query.GetDocumentsAndAssociationsQuery;
30  import org.openehealth.ipf.commons.ihe.xds.core.requests.query.GetDocumentsQuery;
31  import org.openehealth.ipf.commons.ihe.xds.core.requests.query.GetFolderAndContentsQuery;
32  import org.openehealth.ipf.commons.ihe.xds.core.requests.query.GetFoldersForDocumentQuery;
33  import org.openehealth.ipf.commons.ihe.xds.core.requests.query.GetFoldersQuery;
34  import org.openehealth.ipf.commons.ihe.xds.core.requests.query.GetRelatedDocumentsQuery;
35  import org.openehealth.ipf.commons.ihe.xds.core.requests.query.GetSubmissionSetAndContentsQuery;
36  import org.openehealth.ipf.commons.ihe.xds.core.requests.query.GetSubmissionSetsQuery;
37  import org.openehealth.ipf.commons.ihe.xds.core.requests.query.Query;
38  
39  /**
40   * Tests for {@link QueryRegistryTransformer}.
41   * @author Jens Riemschneider
42   */
43  public class QueryRegistryTransformerTest {
44      private QueryRegistryTransformer transformer;
45      
46      @Before
47      public void setUp() {
48          transformer = new QueryRegistryTransformer();
49      }
50      
51      @Test
52      public void testQueryTypes() {
53          checkForQuery(new FindDocumentsQuery());
54          checkForQuery(new FindFoldersQuery());
55          checkForQuery(new FindSubmissionSetsQuery());
56          checkForQuery(new GetAllQuery());
57          checkForQuery(new GetAssociationsQuery());
58          checkForQuery(new GetDocumentsAndAssociationsQuery());
59          checkForQuery(new GetDocumentsQuery());
60          checkForQuery(new GetFolderAndContentsQuery());
61          checkForQuery(new GetFoldersForDocumentQuery());
62          checkForQuery(new GetFoldersQuery());
63          checkForQuery(new GetRelatedDocumentsQuery());
64          checkForQuery(new GetSubmissionSetAndContentsQuery());
65          checkForQuery(new GetSubmissionSetsQuery());
66      }
67      
68      @Test
69      public void testToEbXMLNull() {
70          assertNull(transformer.toEbXML(null));
71      }
72  
73      @Test
74      public void testFromEbXMLNull() {
75          assertNull(transformer.fromEbXML(null));
76      }
77  
78      private void checkForQuery(Query query) {
79          QueryRegistry request = new QueryRegistry(query);
80          EbXMLAdhocQueryRequest ebXML = transformer.toEbXML(request);
81          QueryRegistry result = transformer.fromEbXML(ebXML);
82          assertEquals(request, result);
83      }
84  }