View Javadoc
1   /*
2    * Copyright 2016 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  
17  package org.openehealth.ipf.platform.camel.ihe.fhir.iti78;
18  
19  import org.hl7.fhir.dstu3.model.Bundle;
20  import org.hl7.fhir.dstu3.model.ResourceType;
21  import org.junit.BeforeClass;
22  import org.junit.Test;
23  
24  import javax.servlet.ServletException;
25  
26  import static org.junit.Assert.assertEquals;
27  import static org.junit.Assert.assertTrue;
28  
29  /**
30   *
31   */
32  public class TestIti78Paging extends AbstractTestIti78 {
33  
34      private static final String CONTEXT_DESCRIPTOR = "iti-78-paging.xml";
35  
36      @BeforeClass
37      public static void setUpClass() throws ServletException {
38          startServer(CONTEXT_DESCRIPTOR, false);
39          startClient();
40      }
41  
42  
43      @Test
44      public void testSendManualPdqmWithCount() {
45  
46          Bundle page1 = sendManuallyWithCount(familyParameters(), 2);
47  
48          assertEquals(Bundle.BundleType.SEARCHSET, page1.getType());
49          assertEquals(ResourceType.Bundle, page1.getResourceType());
50          assertTrue(page1.hasEntry());
51          assertEquals(3, page1.getTotal());
52          assertEquals(2, page1.getEntry().size());
53  
54          Bundle page2 = nextPage(page1);
55          assertEquals(Bundle.BundleType.SEARCHSET, page2.getType());
56          assertEquals(ResourceType.Bundle, page2.getResourceType());
57          assertTrue(page2.hasEntry());
58          assertEquals(3, page2.getTotal());
59          assertEquals(1, page2.getEntry().size());
60  
61      }
62  }