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 ca.uhn.fhir.context.FhirVersionEnum;
20  import ca.uhn.fhir.rest.gclient.ICriterion;
21  import org.hl7.fhir.dstu3.model.Bundle;
22  import org.openehealth.ipf.commons.ihe.fhir.IpfFhirServlet;
23  import org.openehealth.ipf.commons.ihe.fhir.iti78.PdqPatient;
24  import org.openehealth.ipf.platform.camel.ihe.fhir.test.FhirTestContainer;
25  import org.slf4j.Logger;
26  import org.slf4j.LoggerFactory;
27  
28  /**
29   *
30   */
31  abstract class AbstractTestIti78 extends FhirTestContainer {
32  
33      private static final Logger LOG = LoggerFactory.getLogger(AbstractTestIti78.class);
34  
35      public static void startServer(String contextDescriptor, boolean secure) {
36          IpfFhirServlet servlet = new IpfFhirServlet(FhirVersionEnum.DSTU3);
37          startServer(servlet, contextDescriptor, secure, FhirTestContainer.DEMO_APP_PORT, "FhirServlet");
38  
39      }
40  
41      public static void startClient() {
42          startClient(String.format("http://localhost:%d/", FhirTestContainer.DEMO_APP_PORT));
43      }
44  
45      protected ICriterion<?> familyParameters() {
46          return PdqPatient.FAMILY.matches().value("Test");
47      }
48  
49      protected Bundle sendManually(ICriterion<?> requestData) {
50          return client.search()
51                  .forResource(PdqPatient.class)
52                  .where(requestData)
53                  .returnBundle(Bundle.class)
54                  .execute();
55      }
56  
57      protected Bundle sendManuallyWithCount(ICriterion<?> requestData, int count) {
58          return client.search()
59                  .forResource(PdqPatient.class)
60                  .where(requestData)
61                  .count(count)
62                  .returnBundle(Bundle.class)
63                  .execute();
64      }
65  
66      protected Bundle nextPage(Bundle bundle) {
67          return client.loadPage()
68                  .next(bundle)
69                  .execute();
70      }
71  
72      protected Bundle previousPage(Bundle bundle) {
73          return client.loadPage()
74                  .previous(bundle)
75                  .execute();
76      }
77  
78  
79  }