Merge branch 'master' into documentOperation
This commit is contained in:
commit
38b7b00f52
|
@ -4,10 +4,11 @@
|
|||
|
||||
# Use VM based build environment
|
||||
sudo: required
|
||||
dist: trusty
|
||||
|
||||
language: java
|
||||
jdk:
|
||||
- oraclejdk8
|
||||
- oraclejdk9
|
||||
env:
|
||||
global:
|
||||
- MAVEN_OPTS="-Xmx1024m"
|
||||
|
@ -25,5 +26,4 @@ before_script:
|
|||
script:
|
||||
# - mvn -e -B clean install && cd hapi-fhir-ra && mvn -e -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID clean test jacoco:report coveralls:report
|
||||
# - mvn -Dci=true -e -B -P ALLMODULES,NOPARALLEL,ERRORPRONE clean install && cd hapi-fhir-jacoco && mvn -e -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID jacoco:report coveralls:report
|
||||
- mvn -Dci=true -e -B -P ALLMODULES,REDUCED_JPA_TESTS,ERRORPRONE_JDK8,JACOCO clean install && cd hapi-fhir-jacoco && mvn -e -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID jacoco:report coveralls:report
|
||||
|
||||
- mvn -Dci=true -e -B -P ALLMODULES,REDUCED_JPA_TESTS,ERRORPRONE,JACOCO clean install && cd hapi-fhir-jacoco && mvn -e -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID jacoco:report coveralls:report
|
||||
|
|
|
@ -1,21 +1,19 @@
|
|||
hapi-fhir
|
||||
HAPI FHIR
|
||||
=========
|
||||
|
||||
HAPI FHIR - Java API for HL7 FHIR Clients and Servers
|
||||
|
||||
[![Coverage Status](https://coveralls.io/repos/jamesagnew/hapi-fhir/badge.svg?branch=master&service=github)](https://coveralls.io/github/jamesagnew/hapi-fhir?branch=master)
|
||||
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/ca.uhn.hapi.fhir/hapi-fhir-base/badge.svg)](http://search.maven.org/#search|ga|1|ca.uhn.hapi.fhir)
|
||||
[![Dependency Status](https://www.versioneye.com/user/projects/55e1d0d9c6d8f2001c00043e/badge.svg?style=flat)](https://www.versioneye.com/user/projects/55e1d0d9c6d8f2001c00043e)
|
||||
[![License](https://img.shields.io/badge/license-apache%202.0-60C060.svg)](http://jamesagnew.github.io/hapi-fhir/license.html)
|
||||
|
||||
* Linux Build: [![Build Status](https://travis-ci.org/jamesagnew/hapi-fhir.svg?branch=master)](https://travis-ci.org/jamesagnew/hapi-fhir)
|
||||
* Windows Build: <a href="https://ci.appveyor.com/project/jamesagnew/hapi-fhir"><img src="https://ci.appveyor.com/api/projects/status/github/jamesagnew/hapi-fhir?branch=master&svg=true"></a>
|
||||
|
||||
|
||||
Complete project documentation is available here:
|
||||
http://jamesagnew.github.io/hapi-fhir/
|
||||
|
||||
A demonstration of this project is available here:
|
||||
http://fhirtest.uhn.ca/
|
||||
http://hapi.fhir.org/
|
||||
|
||||
This project is Open Source, licensed under the Apache Software License 2.0.
|
||||
|
|
|
@ -4,4 +4,6 @@ cache:
|
|||
- C:\maven\
|
||||
- C:\Users\appveyor\.m2\repository
|
||||
build_script:
|
||||
- cmd: mvn -P MINPARALLEL,ALLMODULES clean install
|
||||
- SET JAVA_HOME=C:\Program Files\Java\jdk10
|
||||
- SET PATH=C:\Program Files\Java\jdk10\bin;%PATH%
|
||||
- cmd: mvn -P MINPARALLEL,ALLMODULES,REDUCED_JPA_TESTS clean install
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.junit.AfterClass;
|
|||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
|
@ -188,7 +189,8 @@ public class CdsExampleTests {
|
|||
Assert.assertTrue(procedureRequest.getDoNotPerform());
|
||||
}
|
||||
|
||||
//@Test
|
||||
@Test
|
||||
@Ignore
|
||||
public void CdsHooksPatientViewTest() throws IOException {
|
||||
putResource("cds-bcs-library.json", "patient-view");
|
||||
putResource("cds-bcs-patient.json", "Patient-6532");
|
||||
|
|
|
@ -96,6 +96,7 @@
|
|||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>${slf4j_version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
|
|
@ -72,6 +72,7 @@ public class BuiltJarDstu2IT {
|
|||
* android uses) and see if this passes
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
public void testClient() {
|
||||
FhirContext ctx = FhirContext.forDstu2();
|
||||
try {
|
||||
|
|
|
@ -190,7 +190,7 @@ public class GenericClientDstu3IT {
|
|||
@Test
|
||||
public void testClientFailures() throws Exception {
|
||||
ResponseBody body = mock(ResponseBody.class);
|
||||
when(body.source()).thenThrow(IllegalStateException.class, RuntimeException.class, Exception.class);
|
||||
when(body.source()).thenThrow(IllegalStateException.class, RuntimeException.class);
|
||||
|
||||
myHttpResponse = new Response.Builder()
|
||||
.request(myRequest)
|
||||
|
@ -216,12 +216,6 @@ public class GenericClientDstu3IT {
|
|||
assertEquals("java.lang.RuntimeException", e.toString());
|
||||
}
|
||||
|
||||
try {
|
||||
client.read().resource(Patient.class).withId("1").execute();
|
||||
fail();
|
||||
} catch (FhirClientConnectionException e) {
|
||||
assertEquals("java.lang.Exception", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1757,8 +1757,8 @@ public class XmlUtil {
|
|||
|
||||
private static void throwUnitTestExceptionIfConfiguredToDoSo() throws FactoryConfigurationError, XMLStreamException {
|
||||
if (ourNextException != null) {
|
||||
if (ourNextException instanceof FactoryConfigurationError) {
|
||||
throw ((FactoryConfigurationError)ourNextException);
|
||||
if (ourNextException instanceof javax.xml.stream.FactoryConfigurationError) {
|
||||
throw ((javax.xml.stream.FactoryConfigurationError)ourNextException);
|
||||
}
|
||||
throw (XMLStreamException)ourNextException;
|
||||
}
|
||||
|
|
|
@ -166,13 +166,22 @@
|
|||
<artifactId>thymeleaf-spring4</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Dependencies for Schematron -->
|
||||
<dependency>
|
||||
<groupId>com.helger</groupId>
|
||||
<artifactId>ph-schematron</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>Saxon-HE</artifactId>
|
||||
<groupId>net.sf.saxon</groupId>
|
||||
<groupId>org.glassfish.jaxb</groupId>
|
||||
<artifactId>jaxb-runtime</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.glassfish.jaxb</groupId>
|
||||
<artifactId>jaxb-core</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.sun.istack</groupId>
|
||||
<artifactId>istack-commons-runtime</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
@ -180,18 +189,17 @@
|
|||
<groupId>com.helger</groupId>
|
||||
<artifactId>ph-commons</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--
|
||||
These have been added as explicit dependencies
|
||||
as JDK9 no longer includes them by default
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jaxb</groupId>
|
||||
<artifactId>jaxb-runtime</artifactId>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-impl</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
|
|
@ -80,23 +80,13 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.core</groupId>
|
||||
<artifactId>jersey-server</artifactId>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-jaxrs</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.containers</groupId>
|
||||
<artifactId>jersey-container-servlet-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.containers</groupId>
|
||||
<artifactId>jersey-container-jetty-http</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.media</groupId>
|
||||
<artifactId>jersey-media-moxy</artifactId>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-client</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
|
|
@ -77,6 +77,21 @@
|
|||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.mail</groupId>
|
||||
<artifactId>javax.mail-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.mail</groupId>
|
||||
<artifactId>javax.mail</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>javax.activation</groupId>
|
||||
<artifactId>activation</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.helger</groupId>
|
||||
<artifactId>ph-schematron</artifactId>
|
||||
|
@ -330,6 +345,13 @@
|
|||
<sourceDirectory>../hapi-fhir-client-okhttp/src/main/java</sourceDirectory>
|
||||
</sourceDirectories>
|
||||
</configuration>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>2.3.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
|
|
|
@ -88,6 +88,11 @@
|
|||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.annotation</groupId>
|
||||
<artifactId>javax.annotation-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Unit test dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.codehaus.woodstox</groupId>
|
||||
|
@ -109,6 +114,20 @@
|
|||
<artifactId>jetty-servlet</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-jaxrs</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-client</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.core</groupId>
|
||||
<artifactId>jersey-server</artifactId>
|
||||
|
@ -129,6 +148,8 @@
|
|||
<artifactId>jersey-media-moxy</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
-->
|
||||
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
|
|
|
@ -69,6 +69,7 @@ public abstract class AbstractJaxRsConformanceProvider extends AbstractJaxRsProv
|
|||
private org.hl7.fhir.dstu2016may.model.Conformance myDstu2_1Conformance;
|
||||
private org.hl7.fhir.instance.model.Conformance myDstu2Hl7OrgConformance;
|
||||
private ca.uhn.fhir.model.dstu2.resource.Conformance myDstu2Conformance;
|
||||
private boolean myInitialized;
|
||||
|
||||
/**
|
||||
* Constructor allowing the description, servername and server to be set
|
||||
|
@ -112,7 +113,11 @@ public abstract class AbstractJaxRsConformanceProvider extends AbstractJaxRsProv
|
|||
* conformance
|
||||
*/
|
||||
@PostConstruct
|
||||
protected void setUpPostConstruct() {
|
||||
protected synchronized void setUpPostConstruct() {
|
||||
if (myInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (Entry<Class<? extends IResourceProvider>, IResourceProvider> provider : getProviders().entrySet()) {
|
||||
addProvider(provider.getValue(), provider.getKey());
|
||||
}
|
||||
|
@ -155,6 +160,8 @@ public abstract class AbstractJaxRsConformanceProvider extends AbstractJaxRsProv
|
|||
default:
|
||||
throw new ConfigurationException("Unsupported Fhir version: " + fhirContextVersion);
|
||||
}
|
||||
|
||||
myInitialized = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -184,6 +191,8 @@ public abstract class AbstractJaxRsConformanceProvider extends AbstractJaxRsProv
|
|||
@GET
|
||||
@Path("/metadata")
|
||||
public Response conformance() throws IOException {
|
||||
setUpPostConstruct();
|
||||
|
||||
Builder request = getRequest(RequestTypeEnum.OPTIONS, RestOperationTypeEnum.METADATA);
|
||||
IRestfulResponse response = request.build().getResponse();
|
||||
response.addHeader(Constants.HEADER_CORS_ALLOW_ORIGIN, "*");
|
||||
|
|
|
@ -47,8 +47,8 @@ import ca.uhn.fhir.rest.server.method.BaseMethodBinding;
|
|||
* a large amount of the fhir api functionality using JAXRS
|
||||
* @author Peter Van Houte | peter.vanhoute@agfa.com | Agfa Healthcare
|
||||
*/
|
||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN })
|
||||
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED, MediaType.APPLICATION_JSON, Constants.CT_FHIR_JSON, Constants.CT_FHIR_XML, Constants.CT_FHIR_JSON_NEW, Constants.CT_FHIR_XML_NEW })
|
||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN, Constants.CT_FHIR_JSON, Constants.CT_FHIR_XML })
|
||||
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED, MediaType.APPLICATION_JSON, Constants.CT_FHIR_JSON, Constants.CT_FHIR_XML, Constants.CT_FHIR_JSON_NEW, Constants.CT_FHIR_XML_NEW, "application/octet-stream" })
|
||||
@Interceptors(JaxRsExceptionInterceptor.class)
|
||||
public abstract class AbstractJaxRsResourceProvider<R extends IBaseResource> extends AbstractJaxRsProvider
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ public class JaxRsMethodBindings {
|
|||
*/
|
||||
public BaseMethodBinding<?> getBinding(RestOperationTypeEnum operationType, String theBindingKey) {
|
||||
String bindingKey = StringUtils.defaultIfBlank(theBindingKey, DEFAULT_METHOD_KEY);
|
||||
ConcurrentHashMap<String, BaseMethodBinding<?>> map = operationBindings.get(operationType);
|
||||
ConcurrentHashMap<String, BaseMethodBinding<?>> map = getMapForOperation(operationType);
|
||||
if(map == null || !map.containsKey(bindingKey)) {
|
||||
throw new NotImplementedOperationException("Operation not implemented");
|
||||
} else {
|
||||
|
|
|
@ -6,6 +6,7 @@ import static org.junit.Assert.*;
|
|||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import javax.annotation.Priority;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
@ -81,7 +82,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testAcceptHeaderFetchConformance() throws Exception {
|
||||
public void testAcceptHeaderFetchConformance() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Conformance conf = new Conformance();
|
||||
|
@ -115,7 +116,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testAcceptHeaderPreflightConformance() throws Exception {
|
||||
public void testAcceptHeaderPreflightConformance() {
|
||||
final IParser p = ourCtx.newXmlParser();
|
||||
|
||||
final Conformance conf = new Conformance();
|
||||
|
@ -145,7 +146,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testAcceptHeaderPreflightConformancePreferJson() throws Exception {
|
||||
public void testAcceptHeaderPreflightConformancePreferJson() {
|
||||
final IParser p = ourCtx.newXmlParser();
|
||||
|
||||
final Conformance conf = new Conformance();
|
||||
|
@ -175,7 +176,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testConformance() throws Exception {
|
||||
public void testConformance() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Conformance conf = new Conformance();
|
||||
|
@ -198,7 +199,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testProviderWhereWeForgotToSetTheContext() throws Exception {
|
||||
public void testProviderWhereWeForgotToSetTheContext() {
|
||||
JaxRsRestfulClientFactory clientFactory = new JaxRsRestfulClientFactory(); // no ctx
|
||||
clientFactory.setServerValidationMode(ServerValidationModeEnum.NEVER);
|
||||
|
||||
|
@ -214,7 +215,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
|
||||
@Test
|
||||
public void testCreate() throws Exception {
|
||||
public void testCreate() {
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
||||
|
||||
|
@ -246,7 +247,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCreateConditional() throws Exception {
|
||||
public void testCreateConditional() {
|
||||
|
||||
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
@ -290,7 +291,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
|
||||
@Test
|
||||
public void testCreatePrefer() throws Exception {
|
||||
public void testCreatePrefer() {
|
||||
|
||||
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
@ -315,7 +316,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCreateReturningResourceBody() throws Exception {
|
||||
public void testCreateReturningResourceBody() {
|
||||
Patient p = new Patient();
|
||||
p.setId("123");
|
||||
final String formatted = ourCtx.newXmlParser().encodeResourceToString(p);
|
||||
|
@ -338,7 +339,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteConditional() throws Exception {
|
||||
public void testDeleteConditional() {
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
@ -363,7 +364,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDelete() throws Exception {
|
||||
public void testDelete() {
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
@ -377,7 +378,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testHistory() throws Exception {
|
||||
public void testHistory() {
|
||||
|
||||
final String msg = getPatientFeedWithOneResult();
|
||||
|
||||
|
@ -474,7 +475,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testMetaAdd() throws Exception {
|
||||
public void testMetaAdd() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
MetaDt inMeta = new MetaDt().addProfile("urn:profile:in");
|
||||
|
@ -507,7 +508,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testMetaGet() throws Exception {
|
||||
public void testMetaGet() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters inParams = new Parameters();
|
||||
|
@ -563,7 +564,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationAsGetWithInParameters() throws Exception {
|
||||
public void testOperationAsGetWithInParameters() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters inParams = new Parameters();
|
||||
|
@ -642,7 +643,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationAsGetWithNoInParameters() throws Exception {
|
||||
public void testOperationAsGetWithNoInParameters() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters outParams = new Parameters();
|
||||
|
@ -713,7 +714,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithBundleResponseJson() throws Exception {
|
||||
public void testOperationWithBundleResponseJson() {
|
||||
|
||||
ourResponseContentType = Constants.CT_FHIR_JSON;
|
||||
final String respString = "{\n" + " \"resourceType\":\"Bundle\",\n" + " \"id\":\"8cef5f2a-0ba9-43a5-be26-c8dde9ff0e19\",\n" + " \"base\":\"http://localhost:" + ourPort + "/fhir\"\n" + "}";
|
||||
|
@ -743,7 +744,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithBundleResponseXml() throws Exception {
|
||||
public void testOperationWithBundleResponseXml() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters inParams = new Parameters();
|
||||
|
@ -780,7 +781,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithInlineParams() throws Exception {
|
||||
public void testOperationWithInlineParams() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters outParams = new Parameters();
|
||||
|
@ -899,7 +900,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithProfiledDatatypeParam() throws IOException, Exception {
|
||||
public void testOperationWithProfiledDatatypeParam() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters outParams = new Parameters();
|
||||
|
@ -948,7 +949,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithListOfParameterResponse() throws Exception {
|
||||
public void testOperationWithListOfParameterResponse() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters inParams = new Parameters();
|
||||
|
@ -1023,7 +1024,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithNoInParameters() throws Exception {
|
||||
public void testOperationWithNoInParameters() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters inParams = new Parameters();
|
||||
|
@ -1102,7 +1103,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPageNext() throws Exception {
|
||||
public void testPageNext() {
|
||||
|
||||
ourResponseContentType = Constants.CT_FHIR_XML + "; charset=UTF-8";
|
||||
ourResponseBody = getPatientFeedWithOneResult();
|
||||
|
@ -1129,7 +1130,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPageNextNoLink() throws Exception {
|
||||
public void testPageNextNoLink() {
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
||||
ca.uhn.fhir.model.dstu2.resource.Bundle sourceBundle = new ca.uhn.fhir.model.dstu2.resource.Bundle();
|
||||
|
@ -1141,7 +1142,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPagePrev() throws Exception {
|
||||
public void testPagePrev() {
|
||||
|
||||
|
||||
|
||||
|
@ -1187,7 +1188,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testReadByUri() throws Exception {
|
||||
public void testReadByUri() {
|
||||
|
||||
Patient patient = new Patient();
|
||||
patient.addName().addFamily("FAM");
|
||||
|
@ -1207,7 +1208,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testReadFluentByUri() throws Exception {
|
||||
public void testReadFluentByUri() {
|
||||
|
||||
Patient patient = new Patient();
|
||||
patient.addName().addFamily("FAM");
|
||||
|
@ -1220,13 +1221,13 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
Patient response;
|
||||
|
||||
response = (Patient) client.read().resource(Patient.class).withUrl(new IdDt("http://localhost:" + ourPort + "/AAA/Patient/123")).execute();
|
||||
response = client.read().resource(Patient.class).withUrl(new IdDt("http://localhost:" + ourPort + "/AAA/Patient/123")).execute();
|
||||
assertEquals("http://localhost:" + ourPort + "/AAA/Patient/123", ourRequestUri);
|
||||
assertEquals("FAM", response.getName().get(0).getFamily().get(0).getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadUpdatedHeaderDoesntOverwriteResourceValue() throws Exception {
|
||||
public void testReadUpdatedHeaderDoesntOverwriteResourceValue() {
|
||||
|
||||
|
||||
final String input = "<Bundle xmlns=\"http://hl7.org/fhir\">\n" +
|
||||
|
@ -1264,7 +1265,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testReadWithElementsParam() throws Exception {
|
||||
public void testReadWithElementsParam() {
|
||||
String msg = "{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}";
|
||||
|
||||
|
||||
|
@ -1287,7 +1288,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testReadWithSummaryInvalid() throws Exception {
|
||||
public void testReadWithSummaryInvalid() {
|
||||
String msg = "<>>>><<<<>";
|
||||
|
||||
|
||||
|
@ -1313,7 +1314,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testReadWithSummaryParamHtml() throws Exception {
|
||||
public void testReadWithSummaryParamHtml() {
|
||||
String msg = "<div>HELP IM A DIV</div>";
|
||||
|
||||
|
||||
|
@ -1338,7 +1339,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSearchByString() throws Exception {
|
||||
public void testSearchByString() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
|
@ -1362,7 +1363,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSearchByUrl() throws Exception {
|
||||
public void testSearchByUrl() {
|
||||
|
||||
final String msg = getPatientFeedWithOneResult();
|
||||
|
||||
|
@ -1469,7 +1470,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSearchWithElementsParam() throws Exception {
|
||||
public void testSearchWithElementsParam() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
|
@ -1496,7 +1497,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSearchByPost() throws Exception {
|
||||
public void testSearchByPost() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
|
@ -1533,7 +1534,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSearchByPostUseJson() throws Exception {
|
||||
public void testSearchByPostUseJson() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
|
@ -1571,7 +1572,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSearchWithLastUpdated() throws Exception {
|
||||
public void testSearchWithLastUpdated() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
|
@ -1598,7 +1599,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSearchWithProfileAndSecurity() throws Exception {
|
||||
public void testSearchWithProfileAndSecurity() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
|
@ -1628,7 +1629,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
|
||||
@SuppressWarnings("unused")
|
||||
@Test
|
||||
public void testSearchWithReverseInclude() throws Exception {
|
||||
public void testSearchWithReverseInclude() {
|
||||
|
||||
String msg = getPatientFeedWithOneResult();
|
||||
|
||||
|
@ -1655,7 +1656,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSearchWithSummaryParam() throws Exception {
|
||||
public void testSearchWithSummaryParam() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
|
@ -1682,7 +1683,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testTransactionWithListOfResources() throws Exception {
|
||||
public void testTransactionWithListOfResources() {
|
||||
|
||||
ca.uhn.fhir.model.dstu2.resource.Bundle resp = new ca.uhn.fhir.model.dstu2.resource.Bundle();
|
||||
resp.addEntry().getResponse().setLocation("Patient/1/_history/1");
|
||||
|
@ -1735,7 +1736,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testTransactionWithString() throws Exception {
|
||||
public void testTransactionWithString() {
|
||||
|
||||
ca.uhn.fhir.model.dstu2.resource.Bundle req = new ca.uhn.fhir.model.dstu2.resource.Bundle();
|
||||
Patient patient = new Patient();
|
||||
|
@ -1781,7 +1782,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testTransactionWithTransactionResource() throws Exception {
|
||||
public void testTransactionWithTransactionResource() {
|
||||
|
||||
ca.uhn.fhir.model.dstu2.resource.Bundle resp = new ca.uhn.fhir.model.dstu2.resource.Bundle();
|
||||
resp.addEntry().getResponse().setLocation("Patient/1/_history/1");
|
||||
|
@ -1822,7 +1823,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateConditional() throws Exception {
|
||||
public void testUpdateConditional() {
|
||||
|
||||
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
@ -1877,7 +1878,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateNonFluent() throws Exception {
|
||||
public void testUpdateNonFluent() {
|
||||
|
||||
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
@ -1907,7 +1908,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testUpdatePrefer() throws Exception {
|
||||
public void testUpdatePrefer() {
|
||||
|
||||
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
@ -1933,7 +1934,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateReturningResourceBody() throws Exception {
|
||||
public void testUpdateReturningResourceBody() {
|
||||
Patient p = new Patient();
|
||||
p.setId("123");
|
||||
final String formatted = ourCtx.newXmlParser().encodeResourceToString(p);
|
||||
|
@ -1956,7 +1957,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testValidateFluent() throws Exception {
|
||||
public void testValidateFluent() {
|
||||
|
||||
OperationOutcome oo = new OperationOutcome();
|
||||
oo.addIssue().setDiagnostics("FOOBAR");
|
||||
|
@ -2010,7 +2011,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testValidateNonFluent() throws Exception {
|
||||
public void testValidateNonFluent() {
|
||||
OperationOutcome oo = new OperationOutcome();
|
||||
oo.addIssue().setDiagnostics("FOOBAR");
|
||||
final String msg = ourCtx.newXmlParser().encodeResourceToString(oo);
|
||||
|
@ -2080,7 +2081,7 @@ public class GenericJaxRsClientDstu2Test {
|
|||
ourServer.setHandler(new AbstractHandler() {
|
||||
|
||||
@Override
|
||||
public void handle(String theArg0, Request theRequest, HttpServletRequest theServletRequest, HttpServletResponse theResp) throws IOException, ServletException {
|
||||
public void handle(String theArg0, Request theRequest, HttpServletRequest theServletRequest, HttpServletResponse theResp) throws IOException {
|
||||
theRequest.setHandled(true);
|
||||
ourRequestUri = "http:" + theRequest.getHttpURI().toString();
|
||||
ourRequestUriAll.add(ourRequestUri);
|
||||
|
|
|
@ -79,7 +79,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testAcceptHeaderFetchConformance() throws Exception {
|
||||
public void testAcceptHeaderFetchConformance() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
CapabilityStatement conf = new CapabilityStatement();
|
||||
|
@ -113,7 +113,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testAcceptHeaderPreflightConformance() throws Exception {
|
||||
public void testAcceptHeaderPreflightConformance() {
|
||||
final IParser p = ourCtx.newXmlParser();
|
||||
|
||||
final CapabilityStatement conf = new CapabilityStatement();
|
||||
|
@ -143,7 +143,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testAcceptHeaderPreflightConformancePreferJson() throws Exception {
|
||||
public void testAcceptHeaderPreflightConformancePreferJson() {
|
||||
final IParser p = ourCtx.newXmlParser();
|
||||
|
||||
final CapabilityStatement conf = new CapabilityStatement();
|
||||
|
@ -172,7 +172,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testConformance() throws Exception {
|
||||
public void testConformance() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
CapabilityStatement conf = new CapabilityStatement();
|
||||
|
@ -188,7 +188,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
|
||||
|
||||
//@formatter:off
|
||||
CapabilityStatement resp = (CapabilityStatement)client.fetchConformance().ofType(CapabilityStatement.class).execute();
|
||||
CapabilityStatement resp = client.fetchConformance().ofType(CapabilityStatement.class).execute();
|
||||
|
||||
//@formatter:on
|
||||
assertEquals("http://localhost:" + ourPort + "/fhir/metadata", ourRequestUri);
|
||||
|
@ -199,7 +199,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testProviderWhereWeForgotToSetTheContext() throws Exception {
|
||||
public void testProviderWhereWeForgotToSetTheContext() {
|
||||
JaxRsRestfulClientFactory clientFactory = new JaxRsRestfulClientFactory(); // no ctx
|
||||
clientFactory.setServerValidationMode(ServerValidationModeEnum.NEVER);
|
||||
|
||||
|
@ -215,7 +215,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
|
||||
|
||||
@Test
|
||||
public void testCreate() throws Exception {
|
||||
public void testCreate() {
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
||||
|
||||
|
@ -247,7 +247,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCreateConditional() throws Exception {
|
||||
public void testCreateConditional() {
|
||||
|
||||
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
@ -289,7 +289,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCreate2() throws Exception {
|
||||
public void testCreate2() {
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
@ -310,7 +310,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCreatePrefer() throws Exception {
|
||||
public void testCreatePrefer() {
|
||||
|
||||
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
@ -335,7 +335,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCreateReturningResourceBody() throws Exception {
|
||||
public void testCreateReturningResourceBody() {
|
||||
Patient p = new Patient();
|
||||
p.setId("123");
|
||||
final String formatted = ourCtx.newXmlParser().encodeResourceToString(p);
|
||||
|
@ -358,7 +358,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteConditional() throws Exception {
|
||||
public void testDeleteConditional() {
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
@ -384,7 +384,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
public void testDeleteNonFluent() throws Exception {
|
||||
public void testDeleteNonFluent() {
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
@ -398,7 +398,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testHistory() throws Exception {
|
||||
public void testHistory() {
|
||||
|
||||
final String msg = getPatientFeedWithOneResult();
|
||||
|
||||
|
@ -494,7 +494,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testMetaAdd() throws Exception {
|
||||
public void testMetaAdd() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Meta inMeta = new Meta().addProfile("urn:profile:in");
|
||||
|
@ -527,7 +527,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testMetaGet() throws Exception {
|
||||
public void testMetaGet() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters inParams = new Parameters();
|
||||
|
@ -583,7 +583,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationAsGetWithInParameters() throws Exception {
|
||||
public void testOperationAsGetWithInParameters() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters inParams = new Parameters();
|
||||
|
@ -662,7 +662,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationAsGetWithNoInParameters() throws Exception {
|
||||
public void testOperationAsGetWithNoInParameters() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters outParams = new Parameters();
|
||||
|
@ -733,7 +733,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithBundleResponseJson() throws Exception {
|
||||
public void testOperationWithBundleResponseJson() {
|
||||
|
||||
ourResponseContentType = Constants.CT_FHIR_JSON;
|
||||
final String respString = "{\n" + " \"resourceType\":\"Bundle\",\n" + " \"id\":\"8cef5f2a-0ba9-43a5-be26-c8dde9ff0e19\",\n" + " \"base\":\"http://localhost:" + ourPort + "/fhir\"\n" + "}";
|
||||
|
@ -763,7 +763,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithBundleResponseXml() throws Exception {
|
||||
public void testOperationWithBundleResponseXml() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters inParams = new Parameters();
|
||||
|
@ -800,7 +800,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithInlineParams() throws Exception {
|
||||
public void testOperationWithInlineParams() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters outParams = new Parameters();
|
||||
|
@ -919,7 +919,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithProfiledDatatypeParam() throws IOException, Exception {
|
||||
public void testOperationWithProfiledDatatypeParam() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters outParams = new Parameters();
|
||||
|
@ -968,7 +968,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithListOfParameterResponse() throws Exception {
|
||||
public void testOperationWithListOfParameterResponse() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters inParams = new Parameters();
|
||||
|
@ -1043,7 +1043,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOperationWithNoInParameters() throws Exception {
|
||||
public void testOperationWithNoInParameters() {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
||||
Parameters inParams = new Parameters();
|
||||
|
@ -1122,7 +1122,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPageNext() throws Exception {
|
||||
public void testPageNext() {
|
||||
|
||||
ourResponseContentType = Constants.CT_FHIR_XML + "; charset=UTF-8";
|
||||
ourResponseBody = getPatientFeedWithOneResult();
|
||||
|
@ -1149,7 +1149,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPageNextNoLink() throws Exception {
|
||||
public void testPageNextNoLink() {
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
|
||||
|
||||
org.hl7.fhir.dstu3.model.Bundle sourceBundle = new org.hl7.fhir.dstu3.model.Bundle();
|
||||
|
@ -1161,7 +1161,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPagePrev() throws Exception {
|
||||
public void testPagePrev() {
|
||||
|
||||
|
||||
|
||||
|
@ -1207,7 +1207,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testReadByUri() throws Exception {
|
||||
public void testReadByUri() {
|
||||
|
||||
Patient patient = new Patient();
|
||||
patient.addName().setFamily("FAM");
|
||||
|
@ -1227,7 +1227,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testReadFluentByUri() throws Exception {
|
||||
public void testReadFluentByUri() {
|
||||
|
||||
Patient patient = new Patient();
|
||||
patient.addName().setFamily("FAM");
|
||||
|
@ -1240,13 +1240,13 @@ public class GenericJaxRsClientDstu3Test {
|
|||
|
||||
Patient response;
|
||||
|
||||
response = (Patient) client.read().resource(Patient.class).withUrl(new IdType("http://localhost:" + ourPort + "/AAA/Patient/123")).execute();
|
||||
response = client.read().resource(Patient.class).withUrl(new IdType("http://localhost:" + ourPort + "/AAA/Patient/123")).execute();
|
||||
assertEquals("http://localhost:" + ourPort + "/AAA/Patient/123", ourRequestUri);
|
||||
assertEquals("FAM", response.getName().get(0).getFamily());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadUpdatedHeaderDoesntOverwriteResourceValue() throws Exception {
|
||||
public void testReadUpdatedHeaderDoesntOverwriteResourceValue() {
|
||||
|
||||
//@formatter:off
|
||||
final String input = "<Bundle xmlns=\"http://hl7.org/fhir\">\n" +
|
||||
|
@ -1286,7 +1286,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testReadWithElementsParam() throws Exception {
|
||||
public void testReadWithElementsParam() {
|
||||
String msg = "{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}";
|
||||
|
||||
|
||||
|
@ -1311,7 +1311,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testReadWithSummaryInvalid() throws Exception {
|
||||
public void testReadWithSummaryInvalid() {
|
||||
String msg = "<>>>><<<<>";
|
||||
|
||||
|
||||
|
@ -1338,7 +1338,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testReadWithSummaryParamHtml() throws Exception {
|
||||
public void testReadWithSummaryParamHtml() {
|
||||
String msg = "<div>HELP IM A DIV</div>";
|
||||
|
||||
|
||||
|
@ -1365,7 +1365,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSearchByString() throws Exception {
|
||||
public void testSearchByString() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
|
@ -1391,7 +1391,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSearchByUrl() throws Exception {
|
||||
public void testSearchByUrl() {
|
||||
|
||||
final String msg = getPatientFeedWithOneResult();
|
||||
|
||||
|
@ -1498,7 +1498,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSearchWithElementsParam() throws Exception {
|
||||
public void testSearchWithElementsParam() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
|
@ -1525,7 +1525,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSearchByPost() throws Exception {
|
||||
public void testSearchByPost() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
|
@ -1562,7 +1562,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSearchByPostUseJson() throws Exception {
|
||||
public void testSearchByPostUseJson() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
|
@ -1600,7 +1600,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSearchWithLastUpdated() throws Exception {
|
||||
public void testSearchWithLastUpdated() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
|
@ -1627,7 +1627,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSearchWithProfileAndSecurity() throws Exception {
|
||||
public void testSearchWithProfileAndSecurity() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
|
@ -1657,7 +1657,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
|
||||
@SuppressWarnings("unused")
|
||||
@Test
|
||||
public void testSearchWithReverseInclude() throws Exception {
|
||||
public void testSearchWithReverseInclude() {
|
||||
|
||||
String msg = getPatientFeedWithOneResult();
|
||||
|
||||
|
@ -1684,7 +1684,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSearchWithSummaryParam() throws Exception {
|
||||
public void testSearchWithSummaryParam() {
|
||||
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
|
||||
|
||||
|
||||
|
@ -1711,7 +1711,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testTransactionWithListOfResources() throws Exception {
|
||||
public void testTransactionWithListOfResources() {
|
||||
|
||||
org.hl7.fhir.dstu3.model.Bundle resp = new org.hl7.fhir.dstu3.model.Bundle();
|
||||
resp.addEntry().getResponse().setLocation("Patient/1/_history/1");
|
||||
|
@ -1764,7 +1764,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testTransactionWithString() throws Exception {
|
||||
public void testTransactionWithString() {
|
||||
|
||||
org.hl7.fhir.dstu3.model.Bundle req = new org.hl7.fhir.dstu3.model.Bundle();
|
||||
Patient patient = new Patient();
|
||||
|
@ -1810,7 +1810,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testTransactionWithTransactionResource() throws Exception {
|
||||
public void testTransactionWithTransactionResource() {
|
||||
|
||||
org.hl7.fhir.dstu3.model.Bundle resp = new org.hl7.fhir.dstu3.model.Bundle();
|
||||
resp.addEntry().getResponse().setLocation("Patient/1/_history/1");
|
||||
|
@ -1851,7 +1851,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateConditional() throws Exception {
|
||||
public void testUpdateConditional() {
|
||||
|
||||
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
@ -1906,7 +1906,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateNonFluent() throws Exception {
|
||||
public void testUpdateNonFluent() {
|
||||
|
||||
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
@ -1936,7 +1936,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testUpdatePrefer() throws Exception {
|
||||
public void testUpdatePrefer() {
|
||||
|
||||
|
||||
ourResponseStatus = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
|
@ -1962,7 +1962,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateReturningResourceBody() throws Exception {
|
||||
public void testUpdateReturningResourceBody() {
|
||||
Patient p = new Patient();
|
||||
p.setId("123");
|
||||
final String formatted = ourCtx.newXmlParser().encodeResourceToString(p);
|
||||
|
@ -1985,7 +1985,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testValidateFluent() throws Exception {
|
||||
public void testValidateFluent() {
|
||||
|
||||
OperationOutcome oo = new OperationOutcome();
|
||||
oo.addIssue().setDiagnostics("FOOBAR");
|
||||
|
@ -2039,7 +2039,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testValidateNonFluent() throws Exception {
|
||||
public void testValidateNonFluent() {
|
||||
OperationOutcome oo = new OperationOutcome();
|
||||
oo.addIssue().setDiagnostics("FOOBAR");
|
||||
final String msg = ourCtx.newXmlParser().encodeResourceToString(oo);
|
||||
|
@ -2109,7 +2109,7 @@ public class GenericJaxRsClientDstu3Test {
|
|||
ourServer.setHandler(new AbstractHandler() {
|
||||
|
||||
@Override
|
||||
public void handle(String theArg0, Request theRequest, HttpServletRequest theServletRequest, HttpServletResponse theResp) throws IOException, ServletException {
|
||||
public void handle(String theArg0, Request theRequest, HttpServletRequest theServletRequest, HttpServletResponse theResp) throws IOException {
|
||||
theRequest.setHandled(true);
|
||||
ourRequestUri = "http:" + theRequest.getHttpURI().toString();
|
||||
ourRequestUriAll.add(ourRequestUri);
|
||||
|
|
|
@ -3,28 +3,26 @@ package ca.uhn.fhir.jaxrs.client;
|
|||
import ca.uhn.fhir.context.FhirContext;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.ws.rs.client.Client;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.hamcrest.CoreMatchers.hasItem;
|
||||
import static org.hamcrest.core.IsNot.not;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Sebastien Riviere on 31/07/2017.
|
||||
*/
|
||||
public class JaxRsRestfulClientFactoryTest {
|
||||
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(JaxRsRestfulClientFactoryTest.class);
|
||||
private final FhirContext context = FhirContext.forDstu2();
|
||||
private JaxRsRestfulClientFactory factory;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
factory = new JaxRsRestfulClientFactory(context);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void emptyConstructorTest() {
|
||||
assertNotNull(new JaxRsRestfulClientFactory());
|
||||
|
@ -37,10 +35,11 @@ public class JaxRsRestfulClientFactoryTest {
|
|||
|
||||
@Test
|
||||
public void getNativeClientEmptyRegisteredComponentListTest() {
|
||||
factory.register(new ArrayList<Class<?>>());
|
||||
factory.register(new ArrayList<>());
|
||||
final Client result = factory.getNativeClientClient();
|
||||
assertNotNull(result);
|
||||
assertTrue(result.getConfiguration().getClasses().isEmpty());
|
||||
ourLog.info("Classes: {}", result.getConfiguration().getClasses());
|
||||
assertThat(result.getConfiguration().getClasses(), not(hasItem(ca.uhn.fhir.jaxrs.client.MyFilter.class)));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -48,6 +47,12 @@ public class JaxRsRestfulClientFactoryTest {
|
|||
factory.register(Arrays.asList(MyFilter.class, String.class));
|
||||
final Client result = factory.getNativeClientClient();
|
||||
assertNotNull(result);
|
||||
assertEquals(1, result.getConfiguration().getClasses().size());
|
||||
ourLog.info("Classes: {}", result.getConfiguration().getClasses());
|
||||
assertThat(result.getConfiguration().getClasses(), hasItem(ca.uhn.fhir.jaxrs.client.MyFilter.class));
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
factory = new JaxRsRestfulClientFactory(context);
|
||||
}
|
||||
}
|
|
@ -1,27 +1,24 @@
|
|||
package ca.uhn.fhir.jaxrs.server;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProviderDstu2Hl7Org;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProviderDstu2Hl7Org;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import org.jboss.resteasy.specimpl.ResteasyHttpHeaders;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.ws.rs.HttpMethod;
|
||||
import javax.ws.rs.core.*;
|
||||
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProviderDstu2Hl7Org;
|
||||
import org.glassfish.jersey.internal.MapPropertiesDelegate;
|
||||
import org.glassfish.jersey.server.ContainerRequest;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProviderDstu2Hl7Org;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class AbstractJaxRsConformanceProviderDstu2Hl7OrgTest {
|
||||
|
||||
|
@ -29,16 +26,17 @@ public class AbstractJaxRsConformanceProviderDstu2Hl7OrgTest {
|
|||
private static final String REQUESTURI = BASEURI + "/metadata";
|
||||
AbstractJaxRsConformanceProvider provider;
|
||||
private ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider> providers;
|
||||
private ContainerRequest headers;
|
||||
private ResteasyHttpHeaders headers;
|
||||
private MultivaluedHashMap<String, String> queryParameters;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// headers
|
||||
headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
new MapPropertiesDelegate());
|
||||
// uri info
|
||||
queryParameters = new MultivaluedHashMap<String, String>();
|
||||
queryParameters = new MultivaluedHashMap<>();
|
||||
// headers
|
||||
// headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
// new MapPropertiesDelegate());
|
||||
headers = new ResteasyHttpHeaders(queryParameters);
|
||||
|
||||
|
||||
providers = new ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider>();
|
||||
|
|
|
@ -1,27 +1,24 @@
|
|||
package ca.uhn.fhir.jaxrs.server;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProviderDstu2_1;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProviderDstu2_1;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import org.jboss.resteasy.specimpl.ResteasyHttpHeaders;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.ws.rs.HttpMethod;
|
||||
import javax.ws.rs.core.*;
|
||||
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProviderDstu2_1;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProviderDstu2_1;
|
||||
import org.glassfish.jersey.internal.MapPropertiesDelegate;
|
||||
import org.glassfish.jersey.server.ContainerRequest;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class AbstractJaxRsConformanceProviderDstu2_1Test {
|
||||
|
||||
|
@ -29,19 +26,20 @@ public class AbstractJaxRsConformanceProviderDstu2_1Test {
|
|||
private static final String REQUESTURI = BASEURI + "/metadata";
|
||||
AbstractJaxRsConformanceProvider provider;
|
||||
private ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider> providers;
|
||||
private ContainerRequest headers;
|
||||
private ResteasyHttpHeaders headers;
|
||||
private MultivaluedHashMap<String, String> queryParameters;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// headers
|
||||
headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
new MapPropertiesDelegate());
|
||||
// uri info
|
||||
queryParameters = new MultivaluedHashMap<String, String>();
|
||||
queryParameters = new MultivaluedHashMap<>();
|
||||
// headers
|
||||
// headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
// new MapPropertiesDelegate());
|
||||
headers = new ResteasyHttpHeaders(queryParameters);
|
||||
|
||||
|
||||
providers = new ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider>();
|
||||
providers = new ConcurrentHashMap<>();
|
||||
provider = createConformanceProvider(providers);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,27 +1,24 @@
|
|||
package ca.uhn.fhir.jaxrs.server;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.ws.rs.HttpMethod;
|
||||
import javax.ws.rs.core.*;
|
||||
|
||||
import org.glassfish.jersey.internal.MapPropertiesDelegate;
|
||||
import org.glassfish.jersey.server.ContainerRequest;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProvider;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProviderDstu3;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import org.jboss.resteasy.specimpl.ResteasyHttpHeaders;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class AbstractJaxRsConformanceProviderDstu3Test {
|
||||
|
||||
|
@ -29,16 +26,17 @@ public class AbstractJaxRsConformanceProviderDstu3Test {
|
|||
private static final String REQUESTURI = BASEURI + "/metadata";
|
||||
AbstractJaxRsConformanceProvider provider;
|
||||
private ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider> providers;
|
||||
private ContainerRequest headers;
|
||||
private ResteasyHttpHeaders headers;
|
||||
private MultivaluedHashMap<String, String> queryParameters;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// headers
|
||||
headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
new MapPropertiesDelegate());
|
||||
// uri info
|
||||
queryParameters = new MultivaluedHashMap<String, String>();
|
||||
queryParameters = new MultivaluedHashMap<>();
|
||||
// headers
|
||||
// headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
// new MapPropertiesDelegate());
|
||||
headers = new ResteasyHttpHeaders(queryParameters);
|
||||
|
||||
|
||||
providers = new ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider>();
|
||||
|
|
|
@ -1,27 +1,24 @@
|
|||
package ca.uhn.fhir.jaxrs.server;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProviderR4;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProviderR4;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import org.jboss.resteasy.specimpl.ResteasyHttpHeaders;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.ws.rs.HttpMethod;
|
||||
import javax.ws.rs.core.*;
|
||||
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProviderR4;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProviderR4;
|
||||
import org.glassfish.jersey.internal.MapPropertiesDelegate;
|
||||
import org.glassfish.jersey.server.ContainerRequest;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class AbstractJaxRsConformanceProviderR4Test {
|
||||
|
||||
|
@ -29,16 +26,17 @@ public class AbstractJaxRsConformanceProviderR4Test {
|
|||
private static final String REQUESTURI = BASEURI + "/metadata";
|
||||
AbstractJaxRsConformanceProvider provider;
|
||||
private ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider> providers;
|
||||
private ContainerRequest headers;
|
||||
private ResteasyHttpHeaders headers;
|
||||
private MultivaluedHashMap<String, String> queryParameters;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// headers
|
||||
headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
new MapPropertiesDelegate());
|
||||
// uri info
|
||||
queryParameters = new MultivaluedHashMap<String, String>();
|
||||
queryParameters = new MultivaluedHashMap<>();
|
||||
// headers
|
||||
// headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
// new MapPropertiesDelegate());
|
||||
headers = new ResteasyHttpHeaders(queryParameters);
|
||||
|
||||
|
||||
providers = new ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider>();
|
||||
|
|
|
@ -1,26 +1,23 @@
|
|||
package ca.uhn.fhir.jaxrs.server;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.ws.rs.HttpMethod;
|
||||
import javax.ws.rs.core.*;
|
||||
|
||||
import org.glassfish.jersey.internal.MapPropertiesDelegate;
|
||||
import org.glassfish.jersey.server.ContainerRequest;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProvider;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProvider;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import org.jboss.resteasy.specimpl.ResteasyHttpHeaders;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class AbstractJaxRsConformanceProviderTest {
|
||||
|
||||
|
@ -28,16 +25,17 @@ public class AbstractJaxRsConformanceProviderTest {
|
|||
private static final String REQUESTURI = BASEURI + "/metadata";
|
||||
AbstractJaxRsConformanceProvider provider;
|
||||
private ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider> providers;
|
||||
private ContainerRequest headers;
|
||||
private ResteasyHttpHeaders headers;
|
||||
private MultivaluedHashMap<String, String> queryParameters;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// headers
|
||||
headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
new MapPropertiesDelegate());
|
||||
// uri info
|
||||
queryParameters = new MultivaluedHashMap<String, String>();
|
||||
queryParameters = new MultivaluedHashMap<>();
|
||||
// headers
|
||||
// headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
// new MapPropertiesDelegate());
|
||||
headers = new ResteasyHttpHeaders(queryParameters);
|
||||
|
||||
|
||||
providers = new ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider>();
|
||||
|
|
|
@ -1,11 +1,24 @@
|
|||
package ca.uhn.fhir.jaxrs.server;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Matchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jaxrs.client.JaxRsRestfulClientFactory;
|
||||
import ca.uhn.fhir.jaxrs.server.interceptor.JaxRsResponseException;
|
||||
import ca.uhn.fhir.jaxrs.server.test.RandomServerPortProvider;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsConformanceRestProviderDstu3;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPageProviderDstu3;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProviderDstu3;
|
||||
import ca.uhn.fhir.model.primitive.UriDt;
|
||||
import ca.uhn.fhir.rest.api.EncodingEnum;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.api.PreferReturnEnum;
|
||||
import ca.uhn.fhir.rest.api.SearchStyleEnum;
|
||||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum;
|
||||
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
|
||||
import ca.uhn.fhir.rest.param.StringAndListParam;
|
||||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
|
@ -16,22 +29,21 @@ import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
|
|||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.junit.*;
|
||||
import org.junit.runners.MethodSorters;
|
||||
import org.mockito.*;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.ArgumentMatcher;
|
||||
import org.mockito.ArgumentMatchers;
|
||||
import org.mockito.Matchers;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jaxrs.client.JaxRsRestfulClientFactory;
|
||||
import ca.uhn.fhir.jaxrs.server.interceptor.JaxRsExceptionInterceptor;
|
||||
import ca.uhn.fhir.jaxrs.server.interceptor.JaxRsResponseException;
|
||||
import ca.uhn.fhir.jaxrs.server.test.*;
|
||||
import ca.uhn.fhir.model.primitive.UriDt;
|
||||
import ca.uhn.fhir.rest.api.*;
|
||||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum;
|
||||
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
|
||||
import ca.uhn.fhir.rest.param.StringAndListParam;
|
||||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.argThat;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.isNull;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
public class AbstractJaxRsResourceProviderDstu3Test {
|
||||
|
@ -135,7 +147,7 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
|||
@Test
|
||||
public void testConformance() {
|
||||
final CapabilityStatement conf = client.fetchConformance().ofType(CapabilityStatement.class).execute();
|
||||
assertEquals(conf.getRest().get(0).getResource().get(0).getType().toString(), "Patient");
|
||||
assertEquals(conf.getRest().get(0).getResource().get(0).getType(), "Patient");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -149,7 +161,7 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
|||
client.setEncoding(EncodingEnum.JSON);
|
||||
final MethodOutcome response = client.create().resource(toCreate).prefer(PreferReturnEnum.REPRESENTATION)
|
||||
.execute();
|
||||
IBaseResource resource = (IBaseResource) response.getResource();
|
||||
IBaseResource resource = response.getResource();
|
||||
compareResultId(1, resource);
|
||||
assertEquals("myIdentifier", patientCaptor.getValue().getIdentifier().get(0).getValue());
|
||||
}
|
||||
|
@ -162,7 +174,7 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testConditionalDelete() throws Exception {
|
||||
public void testConditionalDelete() {
|
||||
when(mock.delete(idCaptor.capture(), conditionalCaptor.capture())).thenReturn(new MethodOutcome());
|
||||
client.delete().resourceConditionalByType("Patient").where(Patient.IDENTIFIER.exactly().identifier("2")).execute();
|
||||
assertEquals("Patient?identifier=2&_format=json", conditionalCaptor.getValue());
|
||||
|
@ -187,7 +199,7 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
|||
assertEquals("outputValue", ((StringType)outParams.getParameter().get(0).getValue()).getValueAsString());
|
||||
}
|
||||
|
||||
class StringTypeMatcher extends ArgumentMatcher<StringType> {
|
||||
class StringTypeMatcher implements ArgumentMatcher<StringType> {
|
||||
private StringType myStringType;
|
||||
|
||||
public StringTypeMatcher(StringType stringType) {
|
||||
|
@ -195,8 +207,8 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Object argument) {
|
||||
return myStringType.getValue().equals(((StringType)argument).getValue());
|
||||
public boolean matches(StringType argument) {
|
||||
return myStringType.getValue().equals(argument.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -214,17 +226,18 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
|||
inParams.addParameter().setName("dummy").setValue(new StringType("myAwesomeDummyValue"));
|
||||
|
||||
// invoke
|
||||
Parameters outParams = client.operation().onInstance(new IdType("Patient", "1")).named("$someCustomOperation")
|
||||
.withParameters(inParams).useHttpGet().execute();
|
||||
Parameters outParams = client
|
||||
.operation()
|
||||
.onInstance(new IdType("Patient", "1"))
|
||||
.named("$someCustomOperation")
|
||||
.withParameters(inParams)
|
||||
.useHttpGet()
|
||||
.execute();
|
||||
|
||||
// verify
|
||||
assertEquals("outputValue", ((StringType)outParams.getParameter().get(0).getValue()).getValueAsString());
|
||||
}
|
||||
|
||||
/** Search using other query options */
|
||||
public void testOther() {
|
||||
// missing
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRead() {
|
||||
when(mock.find(idCaptor.capture())).thenReturn(createPatient(1));
|
||||
|
@ -236,7 +249,7 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
|||
|
||||
/** Search - Compartments */
|
||||
@Test
|
||||
public void testSearchCompartements() {
|
||||
public void testSearchCompartments() {
|
||||
when(mock.searchCompartment(any(IdType.class))).thenReturn(Arrays.asList((IBaseResource) createPatient(1)));
|
||||
org.hl7.fhir.dstu3.model.Bundle response = client.search().forResource(Patient.class).withIdAndCompartment("1", "Condition")
|
||||
.returnBundle(org.hl7.fhir.dstu3.model.Bundle.class).execute();
|
||||
|
@ -248,7 +261,7 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
|||
/** */
|
||||
@Test
|
||||
public void testSearchPost() {
|
||||
when(mock.search(any(StringParam.class), Matchers.isNull(StringAndListParam.class)))
|
||||
when(mock.search(ArgumentMatchers.isNull(), ArgumentMatchers.isNull()))
|
||||
.thenReturn(createPatients(1, 13));
|
||||
org.hl7.fhir.dstu3.model.Bundle result = client.search().forResource("Patient").usingStyle(SearchStyleEnum.POST)
|
||||
.returnBundle(org.hl7.fhir.dstu3.model.Bundle.class).execute();
|
||||
|
@ -275,12 +288,12 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
|||
/** Search - Multi-valued Parameters (ANY/OR) */
|
||||
@Test
|
||||
public void testSearchUsingGenericClientBySearchWithMultiValues() {
|
||||
when(mock.search(any(StringParam.class), Matchers.isNotNull(StringAndListParam.class)))
|
||||
when(mock.search(any(StringParam.class), ArgumentMatchers.notNull()))
|
||||
.thenReturn(Arrays.asList(createPatient(1)));
|
||||
final Bundle results = client.search().forResource(Patient.class)
|
||||
.where(Patient.ADDRESS.matches().values("Toronto")).and(Patient.ADDRESS.matches().values("Ontario"))
|
||||
.and(Patient.ADDRESS.matches().values("Canada"))
|
||||
.where(Patient.IDENTIFIER.exactly().systemAndIdentifier("SHORTNAME", "TOYS")).returnBundle(Bundle.class).execute();
|
||||
.where(Patient.NAME.matches().value("SHORTNAME")).returnBundle(Bundle.class).execute();
|
||||
IBaseResource resource = results.getEntry().get(0).getResource();
|
||||
|
||||
compareResultId(1, resource);
|
||||
|
@ -291,7 +304,7 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
|||
@Test
|
||||
public void testSearchWithPaging() {
|
||||
// Perform a search
|
||||
when(mock.search(any(StringParam.class), Matchers.isNull(StringAndListParam.class)))
|
||||
when(mock.search(ArgumentMatchers.isNull(), ArgumentMatchers.isNull()))
|
||||
.thenReturn(createPatients(1, 13));
|
||||
final org.hl7.fhir.dstu3.model.Bundle results = client.search().forResource(Patient.class).count(8).returnBundle(org.hl7.fhir.dstu3.model.Bundle.class)
|
||||
.execute();
|
||||
|
@ -416,17 +429,17 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
|||
System.out.println(ourPort);
|
||||
jettyServer = new Server(ourPort);
|
||||
jettyServer.setHandler(context);
|
||||
ServletHolder jerseyServlet = context.addServlet(org.glassfish.jersey.servlet.ServletContainer.class, "/*");
|
||||
ServletHolder jerseyServlet = context.addServlet(org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.class, "/*");
|
||||
jerseyServlet.setInitOrder(0);
|
||||
|
||||
//@formatter:off
|
||||
jerseyServlet.setInitParameter("jersey.config.server.provider.classnames",
|
||||
jerseyServlet.setInitParameter("resteasy.resources",
|
||||
StringUtils.join(Arrays.asList(
|
||||
TestJaxRsMockPatientRestProviderDstu3.class.getCanonicalName(),
|
||||
JaxRsExceptionInterceptor.class.getCanonicalName(),
|
||||
// JaxRsExceptionInterceptor.class.getCanonicalName(),
|
||||
TestJaxRsConformanceRestProviderDstu3.class.getCanonicalName(),
|
||||
TestJaxRsMockPageProviderDstu3.class.getCanonicalName()
|
||||
), ";"));
|
||||
), ","));
|
||||
//@formatter:on
|
||||
|
||||
jettyServer.start();
|
||||
|
@ -441,7 +454,7 @@ public class AbstractJaxRsResourceProviderDstu3Test {
|
|||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() throws Exception {
|
||||
public static void tearDownClass() {
|
||||
try {
|
||||
jettyServer.destroy();
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -1,35 +1,23 @@
|
|||
package ca.uhn.fhir.jaxrs.server;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Matchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.hamcrest.BaseMatcher;
|
||||
import org.hamcrest.Description;
|
||||
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
|
||||
import org.junit.*;
|
||||
import org.junit.Test;
|
||||
import org.junit.runners.MethodSorters;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Matchers;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jaxrs.client.JaxRsRestfulClientFactory;
|
||||
import ca.uhn.fhir.jaxrs.server.interceptor.JaxRsExceptionInterceptor;
|
||||
import ca.uhn.fhir.jaxrs.server.interceptor.JaxRsResponseException;
|
||||
import ca.uhn.fhir.jaxrs.server.test.*;
|
||||
import ca.uhn.fhir.jaxrs.server.test.RandomServerPortProvider;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsConformanceRestProvider;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPageProvider;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsMockPatientRestProvider;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.dstu2.composite.IdentifierDt;
|
||||
import ca.uhn.fhir.model.dstu2.resource.*;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Bundle.Entry;
|
||||
import ca.uhn.fhir.model.primitive.*;
|
||||
import ca.uhn.fhir.rest.api.*;
|
||||
import ca.uhn.fhir.model.primitive.DateDt;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.model.primitive.UriDt;
|
||||
import ca.uhn.fhir.rest.api.EncodingEnum;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.api.PreferReturnEnum;
|
||||
import ca.uhn.fhir.rest.api.SearchStyleEnum;
|
||||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum;
|
||||
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
|
||||
|
@ -37,6 +25,26 @@ import ca.uhn.fhir.rest.param.StringAndListParam;
|
|||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
|
||||
import org.junit.*;
|
||||
import org.junit.runners.MethodSorters;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Matchers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.argThat;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.isNull;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
public class AbstractJaxRsResourceProviderTest {
|
||||
|
@ -127,7 +135,7 @@ public class AbstractJaxRsResourceProviderTest {
|
|||
@Test
|
||||
public void testConformance() {
|
||||
final Conformance conf = client.fetchConformance().ofType(Conformance.class).execute();
|
||||
assertEquals(conf.getRest().get(0).getResource().get(0).getType().toString(), "Patient");
|
||||
assertEquals(conf.getRest().get(0).getResource().get(0).getType(), "Patient");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -154,7 +162,7 @@ public class AbstractJaxRsResourceProviderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testConditionalDelete() throws Exception {
|
||||
public void testConditionalDelete() {
|
||||
when(mock.delete(idCaptor.capture(), conditionalCaptor.capture())).thenReturn(new MethodOutcome());
|
||||
client.delete().resourceConditionalByType("Patient").where(Patient.IDENTIFIER.exactly().identifier("2")).execute();
|
||||
assertEquals("Patient?identifier=2&_format=json", conditionalCaptor.getValue());
|
||||
|
@ -198,11 +206,6 @@ public class AbstractJaxRsResourceProviderTest {
|
|||
assertEquals("outputValue", ((StringDt) outParams.getParameter().get(0).getValue()).getValueAsString());
|
||||
}
|
||||
|
||||
/** Search using other query options */
|
||||
public void testOther() {
|
||||
// missing
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRead() {
|
||||
when(mock.find(idCaptor.capture())).thenReturn(createPatient(1));
|
||||
|
@ -226,9 +229,12 @@ public class AbstractJaxRsResourceProviderTest {
|
|||
/** */
|
||||
@Test
|
||||
public void testSearchPost() {
|
||||
when(mock.search(any(StringParam.class), Matchers.isNull(StringAndListParam.class)))
|
||||
when(mock.search(isNull(), isNull()))
|
||||
.thenReturn(createPatients(1, 13));
|
||||
Bundle result = client.search().forResource("Patient").usingStyle(SearchStyleEnum.POST)
|
||||
Bundle result = client
|
||||
.search()
|
||||
.forResource("Patient")
|
||||
.usingStyle(SearchStyleEnum.POST)
|
||||
.returnBundle(Bundle.class).execute();
|
||||
IResource resource = result.getEntry().get(0).getResource();
|
||||
compareResultId(1, resource);
|
||||
|
@ -253,12 +259,12 @@ public class AbstractJaxRsResourceProviderTest {
|
|||
/** Search - Multi-valued Parameters (ANY/OR) */
|
||||
@Test
|
||||
public void testSearchUsingGenericClientBySearchWithMultiValues() {
|
||||
when(mock.search(any(StringParam.class), Matchers.isNotNull(StringAndListParam.class)))
|
||||
when(mock.search(any(StringParam.class), any(StringAndListParam.class)))
|
||||
.thenReturn(Arrays.asList(createPatient(1)));
|
||||
Bundle results = client.search().forResource(Patient.class)
|
||||
.where(Patient.ADDRESS.matches().values("Toronto")).and(Patient.ADDRESS.matches().values("Ontario"))
|
||||
.and(Patient.ADDRESS.matches().values("Canada"))
|
||||
.where(Patient.IDENTIFIER.exactly().systemAndIdentifier("SHORTNAME", "TOYS")).returnBundle(Bundle.class).execute();
|
||||
.where(Patient.NAME.matches().value("SHORTNAME")).returnBundle(Bundle.class).execute();
|
||||
IResource resource = results.getEntry().get(0).getResource();
|
||||
|
||||
compareResultId(1, resource);
|
||||
|
@ -269,7 +275,7 @@ public class AbstractJaxRsResourceProviderTest {
|
|||
@Test
|
||||
public void testSearchWithPaging() {
|
||||
// Perform a search
|
||||
when(mock.search(any(StringParam.class), Matchers.isNull(StringAndListParam.class)))
|
||||
when(mock.search(isNull(), isNull()))
|
||||
.thenReturn(createPatients(1, 13));
|
||||
final Bundle results = client.search().forResource(Patient.class).limitTo(8).returnBundle(Bundle.class)
|
||||
.execute();
|
||||
|
@ -370,13 +376,7 @@ public class AbstractJaxRsResourceProviderTest {
|
|||
}
|
||||
|
||||
private <T> T withId(final T id) {
|
||||
return argThat(new BaseMatcher<T>() {
|
||||
@Override
|
||||
public void describeTo(Description arg0) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Object other) {
|
||||
return argThat(other -> {
|
||||
IdDt thisId;
|
||||
IdDt otherId;
|
||||
if (id instanceof IdDt) {
|
||||
|
@ -387,7 +387,6 @@ public class AbstractJaxRsResourceProviderTest {
|
|||
otherId = ((IResource) other).getId();
|
||||
}
|
||||
return thisId.getIdPartAsLong().equals(otherId.getIdPartAsLong());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -399,17 +398,16 @@ public class AbstractJaxRsResourceProviderTest {
|
|||
System.out.println(ourPort);
|
||||
jettyServer = new Server(ourPort);
|
||||
jettyServer.setHandler(context);
|
||||
ServletHolder jerseyServlet = context.addServlet(org.glassfish.jersey.servlet.ServletContainer.class, "/*");
|
||||
ServletHolder jerseyServlet = context.addServlet(org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.class, "/*");
|
||||
jerseyServlet.setInitOrder(0);
|
||||
|
||||
//@formatter:off
|
||||
jerseyServlet.setInitParameter("jersey.config.server.provider.classnames",
|
||||
jerseyServlet.setInitParameter("resteasy.resources",
|
||||
StringUtils.join(Arrays.asList(
|
||||
TestJaxRsMockPatientRestProvider.class.getCanonicalName(),
|
||||
JaxRsExceptionInterceptor.class.getCanonicalName(),
|
||||
TestJaxRsConformanceRestProvider.class.getCanonicalName(),
|
||||
TestJaxRsMockPageProvider.class.getCanonicalName()
|
||||
), ";"));
|
||||
), ","));
|
||||
//@formatter:on
|
||||
|
||||
jettyServer.start();
|
||||
|
@ -424,7 +422,7 @@ public class AbstractJaxRsResourceProviderTest {
|
|||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() throws Exception {
|
||||
public static void tearDownClass() {
|
||||
try {
|
||||
jettyServer.destroy();
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -1,34 +1,22 @@
|
|||
package ca.uhn.fhir.jaxrs.server.util;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.ws.rs.HttpMethod;
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProviderDstu3;
|
||||
import ca.uhn.fhir.rest.api.RequestTypeEnum;
|
||||
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.glassfish.jersey.internal.MapPropertiesDelegate;
|
||||
import org.glassfish.jersey.server.ContainerRequest;
|
||||
import org.jboss.resteasy.specimpl.ResteasyHttpHeaders;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProvider;
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProviderDstu3;
|
||||
import ca.uhn.fhir.jaxrs.server.util.JaxRsRequest;
|
||||
import ca.uhn.fhir.jaxrs.server.util.JaxRsResponse;
|
||||
import ca.uhn.fhir.rest.api.RequestTypeEnum;
|
||||
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
public class JaxRsRequestDstu3Test {
|
||||
|
||||
|
@ -38,7 +26,7 @@ public class JaxRsRequestDstu3Test {
|
|||
|
||||
private JaxRsRequest details;
|
||||
private MultivaluedMap<String, String> queryParameters = new MultivaluedHashMap<String, String>();
|
||||
private ContainerRequest headers;
|
||||
private ResteasyHttpHeaders headers;
|
||||
private TestJaxRsDummyPatientProviderDstu3 provider;
|
||||
|
||||
@Before
|
||||
|
@ -52,11 +40,11 @@ public class JaxRsRequestDstu3Test {
|
|||
String headerValue = "location_value";
|
||||
String headerValue2 = "location_value_2";
|
||||
assertTrue(StringUtils.isBlank(details.getHeader(headerKey)));
|
||||
headers.header(headerKey, headerValue);
|
||||
queryParameters.add(headerKey, headerValue);
|
||||
assertEquals(headerValue, details.getHeader(headerKey));
|
||||
assertEquals(Arrays.asList(headerValue), details.getHeaders(headerKey));
|
||||
|
||||
headers.header(headerKey, headerValue2);
|
||||
queryParameters.add(headerKey, headerValue2);
|
||||
assertEquals(headerValue, details.getHeader(headerKey));
|
||||
assertEquals(Arrays.asList(headerValue, headerValue2), details.getHeaders(headerKey));
|
||||
}
|
||||
|
@ -98,9 +86,9 @@ public class JaxRsRequestDstu3Test {
|
|||
assertEquals(this.provider, details.getServer());
|
||||
}
|
||||
|
||||
public JaxRsRequest createRequestDetails() throws URISyntaxException {
|
||||
public JaxRsRequest createRequestDetails() {
|
||||
// headers
|
||||
headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null, new MapPropertiesDelegate());
|
||||
headers = new ResteasyHttpHeaders(queryParameters);
|
||||
|
||||
//uri info
|
||||
UriInfo uriInfo = mock(UriInfo.class);
|
||||
|
|
|
@ -1,31 +1,22 @@
|
|||
package ca.uhn.fhir.jaxrs.server.util;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.ws.rs.HttpMethod;
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.glassfish.jersey.internal.MapPropertiesDelegate;
|
||||
import org.glassfish.jersey.server.ContainerRequest;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.jaxrs.server.test.TestJaxRsDummyPatientProvider;
|
||||
import ca.uhn.fhir.rest.api.RequestTypeEnum;
|
||||
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jboss.resteasy.specimpl.ResteasyHttpHeaders;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
public class JaxRsRequestTest {
|
||||
|
||||
|
@ -35,7 +26,7 @@ public class JaxRsRequestTest {
|
|||
|
||||
private JaxRsRequest details;
|
||||
private MultivaluedMap<String, String> queryParameters = new MultivaluedHashMap<String, String>();
|
||||
private ContainerRequest headers;
|
||||
private ResteasyHttpHeaders headers;
|
||||
private TestJaxRsDummyPatientProvider provider;
|
||||
|
||||
@Before
|
||||
|
@ -49,11 +40,11 @@ public class JaxRsRequestTest {
|
|||
String headerValue = "location_value";
|
||||
String headerValue2 = "location_value_2";
|
||||
assertTrue(StringUtils.isBlank(details.getHeader(headerKey)));
|
||||
headers.header(headerKey, headerValue);
|
||||
queryParameters.add(headerKey, headerValue);
|
||||
assertEquals(headerValue, details.getHeader(headerKey));
|
||||
assertEquals(Arrays.asList(headerValue), details.getHeaders(headerKey));
|
||||
|
||||
headers.header(headerKey, headerValue2);
|
||||
queryParameters.add(headerKey, headerValue2);
|
||||
assertEquals(headerValue, details.getHeader(headerKey));
|
||||
assertEquals(Arrays.asList(headerValue, headerValue2), details.getHeaders(headerKey));
|
||||
}
|
||||
|
@ -97,7 +88,9 @@ public class JaxRsRequestTest {
|
|||
|
||||
public JaxRsRequest createRequestDetails() throws URISyntaxException {
|
||||
// headers
|
||||
headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null, new MapPropertiesDelegate());
|
||||
// headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
|
||||
// new MapPropertiesDelegate());
|
||||
headers = new ResteasyHttpHeaders(queryParameters);
|
||||
|
||||
//uri info
|
||||
UriInfo uriInfo = mock(UriInfo.class);
|
||||
|
|
|
@ -58,24 +58,12 @@
|
|||
<version>${jetty_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.core</groupId>
|
||||
<artifactId>jersey-server</artifactId>
|
||||
<version>${jersey_version}</version>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-jaxrs</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.containers</groupId>
|
||||
<artifactId>jersey-container-servlet-core</artifactId>
|
||||
<version>${jersey_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.containers</groupId>
|
||||
<artifactId>jersey-container-jetty-http</artifactId>
|
||||
<version>${jersey_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.media</groupId>
|
||||
<artifactId>jersey-media-moxy</artifactId>
|
||||
<version>${jersey_version}</version>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-client</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
|
|
|
@ -43,15 +43,15 @@ public class JaxRsPatientProviderDstu3Test {
|
|||
System.out.println(ourPort);
|
||||
jettyServer = new Server(ourPort);
|
||||
jettyServer.setHandler(context);
|
||||
ServletHolder jerseyServlet = context.addServlet(org.glassfish.jersey.servlet.ServletContainer.class, "/*");
|
||||
ServletHolder jerseyServlet = context.addServlet(org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.class, "/*");
|
||||
jerseyServlet.setInitOrder(0);
|
||||
//@formatter:off
|
||||
jerseyServlet.setInitParameter("jersey.config.server.provider.classnames",
|
||||
jerseyServlet.setInitParameter("resteasy.resources",
|
||||
StringUtils.join(Arrays.asList(
|
||||
JaxRsConformanceProviderDstu3.class.getCanonicalName(),
|
||||
JaxRsPatientRestProviderDstu3.class.getCanonicalName(),
|
||||
JaxRsPageProviderDstu3.class.getCanonicalName()
|
||||
), ";"));
|
||||
), ","));
|
||||
//@formatter:on
|
||||
jettyServer.start();
|
||||
|
||||
|
@ -108,11 +108,6 @@ public class JaxRsPatientProviderDstu3Test {
|
|||
}
|
||||
}
|
||||
|
||||
/** Search using other query options */
|
||||
public void testOther() {
|
||||
//missing
|
||||
}
|
||||
|
||||
/** */
|
||||
@Test
|
||||
public void testSearchPost() {
|
||||
|
|
|
@ -47,15 +47,15 @@ public class JaxRsPatientProviderTest {
|
|||
System.out.println(ourPort);
|
||||
jettyServer = new Server(ourPort);
|
||||
jettyServer.setHandler(context);
|
||||
ServletHolder jerseyServlet = context.addServlet(org.glassfish.jersey.servlet.ServletContainer.class, "/*");
|
||||
ServletHolder jerseyServlet = context.addServlet(org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.class, "/*");
|
||||
jerseyServlet.setInitOrder(0);
|
||||
//@formatter:off
|
||||
jerseyServlet.setInitParameter("jersey.config.server.provider.classnames",
|
||||
jerseyServlet.setInitParameter("resteasy.resources",
|
||||
StringUtils.join(Arrays.asList(
|
||||
JaxRsConformanceProvider.class.getCanonicalName(),
|
||||
JaxRsPatientRestProvider.class.getCanonicalName(),
|
||||
JaxRsPageProvider.class.getCanonicalName()
|
||||
), ";"));
|
||||
), ","));
|
||||
//@formatter:on
|
||||
jettyServer.start();
|
||||
|
||||
|
@ -119,11 +119,6 @@ public class JaxRsPatientProviderTest {
|
|||
}
|
||||
}
|
||||
|
||||
/** Search using other query options */
|
||||
public void testOther() {
|
||||
// missing
|
||||
}
|
||||
|
||||
/** */
|
||||
@Test
|
||||
public void testSearchPost() {
|
||||
|
|
|
@ -205,7 +205,25 @@
|
|||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!--
|
||||
Dependencies that need to be added since JDK9
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>javax.annotation</groupId>
|
||||
<artifactId>javax.annotation-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-impl</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Test Database -->
|
||||
<dependency>
|
||||
|
@ -368,11 +386,22 @@
|
|||
<dependency>
|
||||
<groupId>com.sun.mail</groupId>
|
||||
<artifactId>javax.mail</artifactId>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>javax.activation</groupId>
|
||||
<artifactId>activation</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.activation</groupId>
|
||||
<artifactId>javax.activation</artifactId>
|
||||
</dependency>
|
||||
<!--<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
</dependency>
|
||||
</dependency>-->
|
||||
<dependency>
|
||||
<groupId>javax.el</groupId>
|
||||
<artifactId>javax.el-api</artifactId>
|
||||
|
@ -566,9 +595,19 @@
|
|||
as JDK9 no longer includes them by default
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jaxb</groupId>
|
||||
<artifactId>jaxb-runtime</artifactId>
|
||||
<version>${jaxb_runtime_version}</version>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>${jaxb_api_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-core</artifactId>
|
||||
<version>${jaxb_core_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-impl</artifactId>
|
||||
<version>${jaxb_core_version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
|
|
|
@ -372,22 +372,22 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao,
|
|||
}
|
||||
|
||||
private void expungeCurrentVersionOfResource(Long theResourceId) {
|
||||
ResourceTable resource = myResourceTableDao.findOne(theResourceId);
|
||||
ResourceTable resource = myResourceTableDao.findById(theResourceId).orElseThrow(IllegalStateException::new);
|
||||
|
||||
ResourceHistoryTable currentVersion = myResourceHistoryTableDao.findForIdAndVersion(resource.getId(), resource.getVersion());
|
||||
expungeHistoricalVersion(currentVersion.getId());
|
||||
|
||||
ourLog.info("Deleting current version of resource {}", resource.getIdDt().getValue());
|
||||
|
||||
myResourceIndexedSearchParamUriDao.delete(resource.getParamsUri());
|
||||
myResourceIndexedSearchParamCoordsDao.delete(resource.getParamsCoords());
|
||||
myResourceIndexedSearchParamDateDao.delete(resource.getParamsDate());
|
||||
myResourceIndexedSearchParamNumberDao.delete(resource.getParamsNumber());
|
||||
myResourceIndexedSearchParamQuantityDao.delete(resource.getParamsQuantity());
|
||||
myResourceIndexedSearchParamStringDao.delete(resource.getParamsString());
|
||||
myResourceIndexedSearchParamTokenDao.delete(resource.getParamsToken());
|
||||
myResourceIndexedSearchParamUriDao.deleteAll(resource.getParamsUri());
|
||||
myResourceIndexedSearchParamCoordsDao.deleteAll(resource.getParamsCoords());
|
||||
myResourceIndexedSearchParamDateDao.deleteAll(resource.getParamsDate());
|
||||
myResourceIndexedSearchParamNumberDao.deleteAll(resource.getParamsNumber());
|
||||
myResourceIndexedSearchParamQuantityDao.deleteAll(resource.getParamsQuantity());
|
||||
myResourceIndexedSearchParamStringDao.deleteAll(resource.getParamsString());
|
||||
myResourceIndexedSearchParamTokenDao.deleteAll(resource.getParamsToken());
|
||||
|
||||
myResourceTagDao.delete(resource.getTags());
|
||||
myResourceTagDao.deleteAll(resource.getTags());
|
||||
resource.getTags().clear();
|
||||
|
||||
if (resource.getForcedId() != null) {
|
||||
|
@ -402,15 +402,15 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao,
|
|||
}
|
||||
|
||||
protected void expungeHistoricalVersion(Long theNextVersionId) {
|
||||
ResourceHistoryTable version = myResourceHistoryTableDao.findOne(theNextVersionId);
|
||||
ResourceHistoryTable version = myResourceHistoryTableDao.findById(theNextVersionId).orElseThrow(IllegalArgumentException::new);
|
||||
ourLog.info("Deleting resource version {}", version.getIdDt().getValue());
|
||||
|
||||
myResourceHistoryTagDao.delete(version.getTags());
|
||||
myResourceHistoryTagDao.deleteAll(version.getTags());
|
||||
myResourceHistoryTableDao.delete(version);
|
||||
}
|
||||
|
||||
protected void expungeHistoricalVersionsOfId(Long theResourceId, AtomicInteger theRemainingCount) {
|
||||
ResourceTable resource = myResourceTableDao.findOne(theResourceId);
|
||||
ResourceTable resource = myResourceTableDao.findById(theResourceId).orElseThrow(IllegalArgumentException::new);
|
||||
|
||||
Pageable page = new PageRequest(0, theRemainingCount.get());
|
||||
|
||||
|
|
|
@ -1314,7 +1314,7 @@ public abstract class BaseHapiFhirResourceDao<T extends IBaseResource> extends B
|
|||
|
||||
if (myDaoConfig.isEnforceReferentialIntegrityOnDelete() == false && !theForValidate) {
|
||||
ourLog.debug("Deleting {} resource dependencies which can no longer be satisfied", resultList.size());
|
||||
myResourceLinkDao.delete(resultList);
|
||||
myResourceLinkDao.deleteAll(resultList);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -288,7 +288,7 @@ public abstract class BaseHapiFhirSystemDao<T, MT> extends BaseHapiFhirDao<IBase
|
|||
reindexFailure = txTemplate.execute(new TransactionCallback<Throwable>() {
|
||||
@Override
|
||||
public Throwable doInTransaction(TransactionStatus theStatus) {
|
||||
ResourceTable resourceTable = myResourceTableDao.findOne(myNextId);
|
||||
ResourceTable resourceTable = myResourceTableDao.findById(myNextId).orElseThrow(IllegalStateException::new);
|
||||
|
||||
try {
|
||||
/*
|
||||
|
|
|
@ -3,9 +3,11 @@ package ca.uhn.fhir.jpa.dao;
|
|||
import ca.uhn.fhir.jpa.entity.ResourceEncodingEnum;
|
||||
import ca.uhn.fhir.jpa.util.JpaConstants;
|
||||
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.hl7.fhir.r4.model.Bundle;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
@ -62,6 +64,19 @@ public class DaoConfig {
|
|||
* @see #setMaximumSearchResultCountInTransaction(Integer)
|
||||
*/
|
||||
private static final Integer DEFAULT_MAXIMUM_SEARCH_RESULT_COUNT_IN_TRANSACTION = null;
|
||||
/**
|
||||
* Default {@link #setBundleTypesAllowedForStorage(Set)} value:
|
||||
* <ul>
|
||||
* <li>collection</li>
|
||||
* <li>document</li>
|
||||
* <li>message</li>
|
||||
* </ul>
|
||||
*/
|
||||
private static final Set<String> DEFAULT_BUNDLE_TYPES_ALLOWED_FOR_STORAGE = Collections.unmodifiableSet(new TreeSet<>(Sets.newHashSet(
|
||||
Bundle.BundleType.COLLECTION.toCode(),
|
||||
Bundle.BundleType.DOCUMENT.toCode(),
|
||||
Bundle.BundleType.MESSAGE.toCode()
|
||||
)));
|
||||
private IndexEnabledEnum myIndexMissingFieldsEnabled = IndexEnabledEnum.DISABLED;
|
||||
/**
|
||||
* update setter javadoc if default changes
|
||||
|
@ -128,6 +143,7 @@ public class DaoConfig {
|
|||
private boolean myMarkResourcesForReindexingUponSearchParameterChange;
|
||||
private boolean myExpungeEnabled;
|
||||
private int myReindexThreadCount;
|
||||
private Set<String> myBundleTypesAllowedForStorage;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -138,6 +154,7 @@ public class DaoConfig {
|
|||
setSubscriptionPurgeInactiveAfterMillis(Long.MAX_VALUE);
|
||||
setMarkResourcesForReindexingUponSearchParameterChange(true);
|
||||
setReindexThreadCount(Runtime.getRuntime().availableProcessors());
|
||||
setBundleTypesAllowedForStorage(DEFAULT_BUNDLE_TYPES_ALLOWED_FOR_STORAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -154,6 +171,27 @@ public class DaoConfig {
|
|||
myTreatReferencesAsLogical.add(theTreatReferencesAsLogical);
|
||||
}
|
||||
|
||||
/**
|
||||
* This setting specifies the bundle types (<code>Bundle.type</code>) that
|
||||
* are allowed to be stored as-is on the /Bundle endpoint.
|
||||
*
|
||||
* @see #DEFAULT_BUNDLE_TYPES_ALLOWED_FOR_STORAGE
|
||||
*/
|
||||
public Set<String> getBundleTypesAllowedForStorage() {
|
||||
return myBundleTypesAllowedForStorage;
|
||||
}
|
||||
|
||||
/**
|
||||
* This setting specifies the bundle types (<code>Bundle.type</code>) that
|
||||
* are allowed to be stored as-is on the /Bundle endpoint.
|
||||
*
|
||||
* @see #DEFAULT_BUNDLE_TYPES_ALLOWED_FOR_STORAGE
|
||||
*/
|
||||
public void setBundleTypesAllowedForStorage(Set<String> theBundleTypesAllowedForStorage) {
|
||||
Validate.notNull(theBundleTypesAllowedForStorage, "theBundleTypesAllowedForStorage must not be null");
|
||||
myBundleTypesAllowedForStorage = theBundleTypesAllowedForStorage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the highest number that a client is permitted to use in a
|
||||
* <code>Cache-Control: nostore, max-results=NNN</code>
|
||||
|
@ -418,11 +456,8 @@ public class DaoConfig {
|
|||
/**
|
||||
* This may be used to optionally register server interceptors directly against the DAOs.
|
||||
*/
|
||||
public void setInterceptors(IServerInterceptor... theInterceptor) {
|
||||
setInterceptors(new ArrayList<IServerInterceptor>());
|
||||
if (theInterceptor != null && theInterceptor.length != 0) {
|
||||
getInterceptors().addAll(Arrays.asList(theInterceptor));
|
||||
}
|
||||
public void setInterceptors(List<IServerInterceptor> theInterceptors) {
|
||||
myInterceptors = theInterceptors;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1164,8 +1199,11 @@ public class DaoConfig {
|
|||
/**
|
||||
* This may be used to optionally register server interceptors directly against the DAOs.
|
||||
*/
|
||||
public void setInterceptors(List<IServerInterceptor> theInterceptors) {
|
||||
myInterceptors = theInterceptors;
|
||||
public void setInterceptors(IServerInterceptor... theInterceptor) {
|
||||
setInterceptors(new ArrayList<IServerInterceptor>());
|
||||
if (theInterceptor != null && theInterceptor.length != 0) {
|
||||
getInterceptors().addAll(Arrays.asList(theInterceptor));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -25,14 +25,19 @@ import ca.uhn.fhir.model.dstu2.resource.Bundle.Entry;
|
|||
import ca.uhn.fhir.model.dstu2.valueset.BundleTypeEnum;
|
||||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.defaultString;
|
||||
|
||||
public class FhirResourceDaoBundleDstu2 extends FhirResourceDaoDstu2<Bundle> {
|
||||
|
||||
@Override
|
||||
protected void preProcessResourceForStorage(Bundle theResource) {
|
||||
super.preProcessResourceForStorage(theResource);
|
||||
|
||||
if (theResource.getTypeElement().getValueAsEnum() != BundleTypeEnum.DOCUMENT && theResource.getTypeElement().getValueAsEnum() != BundleTypeEnum.COLLECTION) {
|
||||
String message = "Unable to store a Bundle resource on this server with a Bundle.type of: " + (theResource.getTypeElement().getValueAsEnum() != null ? theResource.getTypeElement().getValueAsEnum().getCode() : "(missing)");
|
||||
Set<String> allowedBundleTypes = getConfig().getBundleTypesAllowedForStorage();
|
||||
if (!allowedBundleTypes.contains(defaultString(theResource.getType()))) {
|
||||
String message = "Unable to store a Bundle resource on this server with a Bundle.type value of: " + (theResource.getType() != null ? theResource.getType() : "(missing)");
|
||||
throw new UnprocessableEntityException(message);
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,9 @@ import org.hibernate.search.query.dsl.QueryBuilder;
|
|||
import org.hl7.fhir.dstu3.model.BaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
@ -57,10 +59,14 @@ public class FulltextSearchSvcImpl implements IFulltextSearchSvc {
|
|||
|
||||
@PersistenceContext(type = PersistenceContextType.TRANSACTION)
|
||||
private EntityManager myEntityManager;
|
||||
@Autowired
|
||||
private PlatformTransactionManager myTxManager;
|
||||
|
||||
@Autowired
|
||||
protected IForcedIdDao myForcedIdDao;
|
||||
|
||||
private Boolean ourDisabled;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
|
@ -73,7 +79,7 @@ public class FulltextSearchSvcImpl implements IFulltextSearchSvc {
|
|||
return;
|
||||
}
|
||||
for (List<? extends IQueryParameterType> nextAnd : theTerms) {
|
||||
Set<String> terms = new HashSet<String>();
|
||||
Set<String> terms = new HashSet<>();
|
||||
for (IQueryParameterType nextOr : nextAnd) {
|
||||
StringParam nextOrString = (StringParam) nextOr;
|
||||
String nextValueTrimmed = StringUtils.defaultString(nextOrString.getValue()).trim();
|
||||
|
@ -229,15 +235,25 @@ public class FulltextSearchSvcImpl implements IFulltextSearchSvc {
|
|||
|
||||
@Override
|
||||
public boolean isDisabled() {
|
||||
Boolean retVal = ourDisabled;
|
||||
|
||||
if (retVal == null) {
|
||||
retVal = new TransactionTemplate(myTxManager).execute(t -> {
|
||||
try {
|
||||
FullTextEntityManager em = org.hibernate.search.jpa.Search.getFullTextEntityManager(myEntityManager);
|
||||
em.getSearchFactory().buildQueryBuilder().forEntity(ResourceTable.class).get();
|
||||
return Boolean.FALSE;
|
||||
} catch (Exception e) {
|
||||
ourLog.trace("FullText test failed", e);
|
||||
ourLog.debug("Hibernate Search (Lucene) appears to be disabled on this server, fulltext will be disabled");
|
||||
return true;
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
ourDisabled = retVal;
|
||||
}
|
||||
|
||||
assert retVal != null;
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@Transactional()
|
||||
|
@ -246,6 +262,7 @@ public class FulltextSearchSvcImpl implements IFulltextSearchSvc {
|
|||
return doSearch(theResourceName, theParams, null);
|
||||
}
|
||||
|
||||
@Transactional()
|
||||
@Override
|
||||
public List<Suggestion> suggestKeywords(String theContext, String theSearchParam, String theText) {
|
||||
Validate.notBlank(theContext, "theContext must be provided");
|
||||
|
|
|
@ -87,6 +87,7 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SearchBuilder.class);
|
||||
private static Long NO_MORE = -1L;
|
||||
private static HandlerTypeEnum ourLastHandlerMechanismForUnitTest;
|
||||
private static SearchParameterMap ourLastHandlerParamsForUnitTest;
|
||||
private List<Long> myAlsoIncludePids;
|
||||
private CriteriaBuilder myBuilder;
|
||||
private BaseHapiFhirDao<?> myCallingDao;
|
||||
|
@ -1017,6 +1018,8 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
num = builder.or(lowPred, highPred);
|
||||
}
|
||||
break;
|
||||
case ENDS_BEFORE:
|
||||
case STARTS_AFTER:
|
||||
default:
|
||||
String msg = myContext.getLocalizer().getMessage(SearchBuilder.class, invalidMessageName, thePrefix.getValue(), theParam.getValueAsQueryToken(myContext));
|
||||
throw new InvalidRequestException(msg);
|
||||
|
@ -1302,6 +1305,7 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
}
|
||||
|
||||
Set<String> uniqueQueryStrings = BaseHapiFhirDao.extractCompositeStringUniquesValueChains(myResourceName, params);
|
||||
ourLastHandlerParamsForUnitTest = theParams;
|
||||
ourLastHandlerMechanismForUnitTest = HandlerTypeEnum.UNIQUE_INDEX;
|
||||
return new UniqueIndexIterator(uniqueQueryStrings);
|
||||
|
||||
|
@ -1313,6 +1317,7 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
ourLastHandlerParamsForUnitTest = theParams;
|
||||
ourLastHandlerMechanismForUnitTest = HandlerTypeEnum.STANDARD_QUERY;
|
||||
return new QueryIterator();
|
||||
}
|
||||
|
@ -1526,6 +1531,8 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
sortAttrName = new String[] {"myValue"};
|
||||
joinType = JoinEnum.QUANTITY;
|
||||
break;
|
||||
case COMPOSITE:
|
||||
case HAS:
|
||||
default:
|
||||
throw new InvalidRequestException("This server does not support _sort specifications of type " + param.getParamType() + " - Can't serve _sort=" + theSort.getParamName());
|
||||
}
|
||||
|
@ -1698,7 +1705,6 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
roundCounts++;
|
||||
|
||||
HashSet<Long> pidsToInclude = new HashSet<>();
|
||||
Set<Long> nextRoundOmit = new HashSet<>();
|
||||
|
||||
for (Iterator<Include> iter = includes.iterator(); iter.hasNext(); ) {
|
||||
Include nextInclude = iter.next();
|
||||
|
@ -1793,8 +1799,6 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
pidsToInclude.removeAll(nextRoundOmit);
|
||||
|
||||
addedSomeThisRound = allAdded.addAll(pidsToInclude);
|
||||
nextRoundMatches = pidsToInclude;
|
||||
} while (includes.size() > 0 && nextRoundMatches.size() > 0 && addedSomeThisRound);
|
||||
|
@ -1970,6 +1974,8 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
case REFERENCE:
|
||||
qp = new ReferenceParam();
|
||||
break;
|
||||
case URI:
|
||||
case HAS:
|
||||
default:
|
||||
throw new InternalErrorException("Don't know how to convert param type: " + theParam.getParamType());
|
||||
}
|
||||
|
@ -2068,14 +2074,18 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
|
||||
@VisibleForTesting
|
||||
public static HandlerTypeEnum getLastHandlerMechanismForUnitTest() {
|
||||
ourLog.info("Retrieving last handler mechanism: {}", ourLastHandlerMechanismForUnitTest);
|
||||
return ourLastHandlerMechanismForUnitTest;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public static SearchParameterMap getLastHandlerParamsForUnitTest() {
|
||||
return ourLastHandlerParamsForUnitTest;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public static void resetLastHandlerMechanismForUnitTest() {
|
||||
ourLog.info("Clearing last handler mechanism (was {})", ourLastHandlerMechanismForUnitTest);
|
||||
ourLastHandlerMechanismForUnitTest = null;
|
||||
ourLastHandlerParamsForUnitTest = null;
|
||||
}
|
||||
|
||||
static Predicate[] toArray(List<Predicate> thePredicates) {
|
||||
|
|
|
@ -25,13 +25,18 @@ import org.hl7.fhir.dstu3.model.Bundle.BundleType;
|
|||
|
||||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.defaultString;
|
||||
|
||||
public class FhirResourceDaoBundleDstu3 extends FhirResourceDaoDstu3<Bundle> {
|
||||
|
||||
@Override
|
||||
protected void preProcessResourceForStorage(Bundle theResource) {
|
||||
super.preProcessResourceForStorage(theResource);
|
||||
|
||||
if (theResource.getType() != BundleType.DOCUMENT && theResource.getType() != BundleType.COLLECTION) {
|
||||
Set<String> allowedBundleTypes = getConfig().getBundleTypesAllowedForStorage();
|
||||
if (theResource.getType() == null || !allowedBundleTypes.contains(defaultString(theResource.getType().toCode()))) {
|
||||
String message = "Unable to store a Bundle resource on this server with a Bundle.type value of: " + (theResource.getType() != null ? theResource.getType().toCode() : "(missing)");
|
||||
throw new UnprocessableEntityException(message);
|
||||
}
|
||||
|
|
|
@ -25,19 +25,23 @@ import org.hl7.fhir.r4.model.Bundle.BundleType;
|
|||
|
||||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.defaultString;
|
||||
|
||||
public class FhirResourceDaoBundleR4 extends FhirResourceDaoR4<Bundle> {
|
||||
|
||||
@Override
|
||||
protected void preProcessResourceForStorage(Bundle theResource) {
|
||||
super.preProcessResourceForStorage(theResource);
|
||||
|
||||
if (theResource.getType() != BundleType.DOCUMENT && theResource.getType() != BundleType.COLLECTION) {
|
||||
Set<String> allowedBundleTypes = getConfig().getBundleTypesAllowedForStorage();
|
||||
if (theResource.getType() == null || !allowedBundleTypes.contains(defaultString(theResource.getType().toCode()))) {
|
||||
String message = "Unable to store a Bundle resource on this server with a Bundle.type value of: " + (theResource.getType() != null ? theResource.getType().toCode() : "(missing)");
|
||||
throw new UnprocessableEntityException(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -75,13 +75,13 @@ public class PersistedJpaBundleProvider implements IBundleProvider {
|
|||
mySearchEntity = null;
|
||||
}
|
||||
|
||||
protected List<IBaseResource> doHistoryInTransaction(int theFromIndex, int theToIndex) {
|
||||
private List<IBaseResource> doHistoryInTransaction(int theFromIndex, int theToIndex) {
|
||||
List<ResourceHistoryTable> results;
|
||||
|
||||
CriteriaBuilder cb = myEntityManager.getCriteriaBuilder();
|
||||
CriteriaQuery<ResourceHistoryTable> q = cb.createQuery(ResourceHistoryTable.class);
|
||||
Root<ResourceHistoryTable> from = q.from(ResourceHistoryTable.class);
|
||||
List<Predicate> predicates = new ArrayList<Predicate>();
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
|
||||
if (mySearchEntity.getResourceType() == null) {
|
||||
// All resource types
|
||||
|
@ -215,6 +215,7 @@ public class PersistedJpaBundleProvider implements IBundleProvider {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return myUuid;
|
||||
}
|
||||
|
@ -223,7 +224,7 @@ public class PersistedJpaBundleProvider implements IBundleProvider {
|
|||
return myCacheHit;
|
||||
}
|
||||
|
||||
public void setCacheHit(boolean theCacheHit) {
|
||||
void setCacheHit(boolean theCacheHit) {
|
||||
myCacheHit = theCacheHit;
|
||||
}
|
||||
|
||||
|
@ -253,7 +254,7 @@ public class PersistedJpaBundleProvider implements IBundleProvider {
|
|||
mySearchDao = theSearchDao;
|
||||
}
|
||||
|
||||
protected void setSearchEntity(Search theSearchEntity) {
|
||||
void setSearchEntity(Search theSearchEntity) {
|
||||
mySearchEntity = theSearchEntity;
|
||||
}
|
||||
|
||||
|
@ -269,8 +270,8 @@ public class PersistedJpaBundleProvider implements IBundleProvider {
|
|||
return Math.max(0, size);
|
||||
}
|
||||
|
||||
protected List<IBaseResource> toResourceList(ISearchBuilder sb, List<Long> pidsSubList) {
|
||||
Set<Long> includedPids = new HashSet<Long>();
|
||||
List<IBaseResource> toResourceList(ISearchBuilder sb, List<Long> pidsSubList) {
|
||||
Set<Long> includedPids = new HashSet<>();
|
||||
if (mySearchEntity.getSearchType() == SearchTypeEnum.SEARCH) {
|
||||
includedPids.addAll(sb.loadReverseIncludes(myDao, myContext, myEntityManager, pidsSubList, mySearchEntity.toRevIncludesList(), true, mySearchEntity.getLastUpdated()));
|
||||
includedPids.addAll(sb.loadReverseIncludes(myDao, myContext, myEntityManager, pidsSubList, mySearchEntity.toIncludesList(), false, mySearchEntity.getLastUpdated()));
|
||||
|
|
|
@ -420,7 +420,7 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc {
|
|||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public int getOffset() {
|
||||
public long getOffset() {
|
||||
return theFromIndex;
|
||||
}
|
||||
};
|
||||
|
@ -702,7 +702,7 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc {
|
|||
nextResult.setOrder(myCountSaved++);
|
||||
resultsToSave.add(nextResult);
|
||||
}
|
||||
mySearchResultDao.save(resultsToSave);
|
||||
mySearchResultDao.saveAll(resultsToSave);
|
||||
|
||||
synchronized (mySyncedPids) {
|
||||
int numSyncedThisPass = myUnsyncedPids.size();
|
||||
|
|
|
@ -67,13 +67,12 @@ public class StaleSearchDeletingSvcImpl implements IStaleSearchDeletingSvc {
|
|||
private PlatformTransactionManager myTransactionManager;
|
||||
|
||||
private void deleteSearch(final Long theSearchPid) {
|
||||
Search searchToDelete = mySearchDao.findOne(theSearchPid);
|
||||
if (searchToDelete != null) {
|
||||
mySearchDao.findById(theSearchPid).ifPresent(searchToDelete -> {
|
||||
ourLog.info("Deleting search {}/{} - Created[{}] -- Last returned[{}]", searchToDelete.getId(), searchToDelete.getUuid(), new InstantType(searchToDelete.getCreated()), new InstantType(searchToDelete.getSearchLastReturned()));
|
||||
mySearchIncludeDao.deleteForSearch(searchToDelete.getId());
|
||||
mySearchResultDao.deleteForSearch(searchToDelete.getId());
|
||||
mySearchDao.delete(searchToDelete);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -104,7 +104,7 @@ public class SearchParamPresenceSvcImpl implements ISearchParamPresenceSvc {
|
|||
}
|
||||
|
||||
mySearchParamPresentDao.deleteInBatch(entitiesToDelete);
|
||||
mySearchParamPresentDao.save(entitiesToSave);
|
||||
mySearchParamPresentDao.saveAll(entitiesToSave);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -243,7 +243,7 @@ public abstract class BaseHapiTerminologySvcImpl implements IHapiTerminologySvc,
|
|||
ourLog.info(" * Deleting code system {}", theCodeSystem.getPid());
|
||||
|
||||
myEntityManager.flush();
|
||||
TermCodeSystem cs = myCodeSystemDao.findOne(theCodeSystem.getPid());
|
||||
TermCodeSystem cs = myCodeSystemDao.findById(theCodeSystem.getPid()).orElseThrow(IllegalStateException::new);
|
||||
cs.setCurrentVersion(null);
|
||||
myCodeSystemDao.save(cs);
|
||||
myCodeSystemDao.flush();
|
||||
|
@ -252,8 +252,8 @@ public abstract class BaseHapiTerminologySvcImpl implements IHapiTerminologySvc,
|
|||
for (TermCodeSystemVersion next : myCodeSystemVersionDao.findByCodeSystemResource(theCodeSystem.getPid())) {
|
||||
myConceptParentChildLinkDao.deleteByCodeSystemVersion(next.getPid());
|
||||
for (TermConcept nextConcept : myConceptDao.findByCodeSystemVersion(next.getPid())) {
|
||||
myConceptPropertyDao.delete(nextConcept.getProperties());
|
||||
myConceptDesignationDao.delete(nextConcept.getDesignations());
|
||||
myConceptPropertyDao.deleteAll(nextConcept.getProperties());
|
||||
myConceptDesignationDao.deleteAll(nextConcept.getDesignations());
|
||||
myConceptDao.delete(nextConcept);
|
||||
}
|
||||
if (next.getCodeSystem().getCurrentVersion() == next) {
|
||||
|
@ -639,7 +639,7 @@ public abstract class BaseHapiTerminologySvcImpl implements IHapiTerminologySvc,
|
|||
while (relCount < count && myConceptLinksToSaveLater.size() > 0) {
|
||||
TermConceptParentChildLink next = myConceptLinksToSaveLater.remove(0);
|
||||
|
||||
if (myConceptDao.findOne(next.getChild().getId()) == null || myConceptDao.findOne(next.getParent().getId()) == null) {
|
||||
if (!myConceptDao.findById(next.getChild().getId()).isPresent() || !myConceptDao.findById(next.getParent().getId()).isPresent()) {
|
||||
ourLog.warn("Not inserting link from child {} to parent {} because it appears to have been deleted", next.getParent().getCode(), next.getChild().getCode());
|
||||
continue;
|
||||
}
|
||||
|
@ -850,7 +850,7 @@ public abstract class BaseHapiTerminologySvcImpl implements IHapiTerminologySvc,
|
|||
ourLog.info(" * Deleting code system version {}", next.getPid());
|
||||
myConceptParentChildLinkDao.deleteByCodeSystemVersion(next.getPid());
|
||||
for (TermConcept nextConcept : myConceptDao.findByCodeSystemVersion(next.getPid())) {
|
||||
myConceptPropertyDao.delete(nextConcept.getProperties());
|
||||
myConceptPropertyDao.deleteAll(nextConcept.getProperties());
|
||||
myConceptDao.delete(nextConcept);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,11 +21,6 @@ public class SearchBuilderTest {
|
|||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAA() {
|
||||
assertTrue(123.00004f <= 123.0001f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCalculateMultiplierEqualNoDecimal() {
|
||||
BigDecimal in = new BigDecimal("200");
|
||||
|
|
|
@ -14,7 +14,6 @@ import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
|
|||
import ca.uhn.fhir.jpa.search.ISearchCoordinatorSvc;
|
||||
import ca.uhn.fhir.jpa.sp.ISearchParamPresenceSvc;
|
||||
import ca.uhn.fhir.jpa.util.ResourceCountCache;
|
||||
import ca.uhn.fhir.jpa.util.SingleItemLoadingCache;
|
||||
import ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt;
|
||||
import ca.uhn.fhir.model.dstu2.composite.CodingDt;
|
||||
import ca.uhn.fhir.model.dstu2.composite.MetaDt;
|
||||
|
@ -42,7 +41,6 @@ import org.springframework.transaction.support.TransactionTemplate;
|
|||
import javax.persistence.EntityManager;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
@ -181,12 +179,13 @@ public abstract class BaseJpaDstu2Test extends BaseJpaTest {
|
|||
}
|
||||
|
||||
@Before
|
||||
@Transactional
|
||||
public void beforeFlushFT() {
|
||||
runInTransaction(() -> {
|
||||
FullTextEntityManager ftem = Search.getFullTextEntityManager(myEntityManager);
|
||||
ftem.purgeAll(ResourceTable.class);
|
||||
ftem.purgeAll(ResourceIndexedSearchParamString.class);
|
||||
ftem.flushToIndexes();
|
||||
});
|
||||
|
||||
myDaoConfig.setSchedulingDisabled(true);
|
||||
myDaoConfig.setIndexMissingFields(DaoConfig.IndexEnabledEnum.ENABLED);
|
||||
|
|
|
@ -319,7 +319,7 @@ public class FhirResourceDaoDstu2Test extends BaseJpaDstu2Test {
|
|||
myBundleDao.create(bundle, mySrd);
|
||||
fail();
|
||||
} catch (UnprocessableEntityException e) {
|
||||
assertEquals("Unable to store a Bundle resource on this server with a Bundle.type of: (missing)", e.getMessage());
|
||||
assertEquals("Unable to store a Bundle resource on this server with a Bundle.type value of: (missing)", e.getMessage());
|
||||
}
|
||||
|
||||
bundle = new Bundle();
|
||||
|
@ -329,7 +329,7 @@ public class FhirResourceDaoDstu2Test extends BaseJpaDstu2Test {
|
|||
myBundleDao.create(bundle, mySrd);
|
||||
fail();
|
||||
} catch (UnprocessableEntityException e) {
|
||||
assertEquals("Unable to store a Bundle resource on this server with a Bundle.type of: batch-response", e.getMessage());
|
||||
assertEquals("Unable to store a Bundle resource on this server with a Bundle.type value of: batch-response", e.getMessage());
|
||||
}
|
||||
|
||||
bundle = new Bundle();
|
||||
|
@ -2435,6 +2435,8 @@ public class FhirResourceDaoDstu2Test extends BaseJpaDstu2Test {
|
|||
assertThat(actual, contains(id3, id2, id1));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testSortByQuantity() {
|
||||
Observation res;
|
||||
|
||||
|
@ -2700,6 +2702,8 @@ public class FhirResourceDaoDstu2Test extends BaseJpaDstu2Test {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testSortByUri() {
|
||||
ConceptMap res = new ConceptMap();
|
||||
res.addElement().addTarget().addDependsOn().setElement("http://foo2");
|
||||
|
|
|
@ -277,12 +277,13 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest {
|
|||
}
|
||||
|
||||
@Before
|
||||
@Transactional
|
||||
public void beforeFlushFT() {
|
||||
runInTransaction(() -> {
|
||||
FullTextEntityManager ftem = Search.getFullTextEntityManager(myEntityManager);
|
||||
ftem.purgeAll(ResourceTable.class);
|
||||
ftem.purgeAll(ResourceIndexedSearchParamString.class);
|
||||
ftem.flushToIndexes();
|
||||
});
|
||||
|
||||
myDaoConfig.setSchedulingDisabled(true);
|
||||
myDaoConfig.setIndexMissingFields(DaoConfig.IndexEnabledEnum.ENABLED);
|
||||
|
|
|
@ -63,7 +63,7 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test {
|
|||
codeSystem.setContent(CodeSystemContentMode.NOTPRESENT);
|
||||
IIdType id = myCodeSystemDao.create(codeSystem, mySrd).getId().toUnqualified();
|
||||
|
||||
ResourceTable table = myResourceTableDao.findOne(id.getIdPartAsLong());
|
||||
ResourceTable table = myResourceTableDao.findById(id.getIdPartAsLong()).orElseThrow(IllegalStateException::new);
|
||||
|
||||
TermCodeSystemVersion cs = new TermCodeSystemVersion();
|
||||
cs.setResource(table);
|
||||
|
@ -106,7 +106,7 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test {
|
|||
codeSystem.setContent(CodeSystemContentMode.NOTPRESENT);
|
||||
IIdType id = myCodeSystemDao.create(codeSystem, mySrd).getId().toUnqualified();
|
||||
|
||||
ResourceTable table = myResourceTableDao.findOne(id.getIdPartAsLong());
|
||||
ResourceTable table = myResourceTableDao.findById(id.getIdPartAsLong()).orElseThrow(IllegalStateException::new);
|
||||
|
||||
TermCodeSystemVersion cs = new TermCodeSystemVersion();
|
||||
cs.setResource(table);
|
||||
|
@ -143,7 +143,7 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test {
|
|||
codeSystem.setContent(CodeSystemContentMode.NOTPRESENT);
|
||||
IIdType id = myCodeSystemDao.create(codeSystem, mySrd).getId().toUnqualified();
|
||||
|
||||
ResourceTable table = myResourceTableDao.findOne(id.getIdPartAsLong());
|
||||
ResourceTable table = myResourceTableDao.findById(id.getIdPartAsLong()).orElseThrow(IllegalStateException::new);
|
||||
|
||||
TermCodeSystemVersion cs = new TermCodeSystemVersion();
|
||||
cs.setResource(table);
|
||||
|
@ -707,7 +707,7 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test {
|
|||
codeSystem.setContent(CodeSystemContentMode.NOTPRESENT);
|
||||
IIdType id = myCodeSystemDao.create(codeSystem, mySrd).getId().toUnqualified();
|
||||
|
||||
ResourceTable table = myResourceTableDao.findOne(id.getIdPartAsLong());
|
||||
ResourceTable table = myResourceTableDao.findById(id.getIdPartAsLong()).orElseThrow(IllegalStateException::new);
|
||||
|
||||
TermCodeSystemVersion cs = new TermCodeSystemVersion();
|
||||
cs.setResource(table);
|
||||
|
|
|
@ -2938,6 +2938,9 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
|
|||
assertThat(actual, contains(toValues(id3, id2, id1)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
|
||||
public void testSortByQuantity() {
|
||||
Observation res;
|
||||
|
||||
|
@ -3203,6 +3206,8 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testSortByUri() {
|
||||
ConceptMap res = new ConceptMap();
|
||||
res.addGroup().setSource("http://foo2");
|
||||
|
|
|
@ -282,12 +282,13 @@ public abstract class BaseJpaR4Test extends BaseJpaTest {
|
|||
}
|
||||
|
||||
@Before
|
||||
@Transactional
|
||||
public void beforeFlushFT() {
|
||||
runInTransaction(()->{
|
||||
FullTextEntityManager ftem = Search.getFullTextEntityManager(myEntityManager);
|
||||
ftem.purgeAll(ResourceTable.class);
|
||||
ftem.purgeAll(ResourceIndexedSearchParamString.class);
|
||||
ftem.flushToIndexes();
|
||||
});
|
||||
|
||||
myDaoConfig.setSchedulingDisabled(true);
|
||||
myDaoConfig.setIndexMissingFields(DaoConfig.IndexEnabledEnum.ENABLED);
|
||||
|
|
|
@ -5,6 +5,7 @@ import ca.uhn.fhir.jpa.dao.DeleteMethodOutcome;
|
|||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||
import ca.uhn.fhir.rest.server.interceptor.IServerOperationInterceptor;
|
||||
import ca.uhn.fhir.rest.server.interceptor.ServerOperationInterceptorAdapter;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
|
@ -567,8 +568,8 @@ public class FhirResourceDaoR4InterceptorTest extends BaseJpaR4Test {
|
|||
@Test
|
||||
public void testServerOperationPreDelete() {
|
||||
|
||||
doAnswer(new MyOneResourceAnswer()).when(myJpaInterceptor).resourcePreDelete(any(RequestDetails.class), any(IBaseResource.class));
|
||||
doAnswer(new MyOneResourceAnswer()).when(myJpaInterceptor).resourceDeleted(any(RequestDetails.class), any(IBaseResource.class));
|
||||
doAnswer(new MyOneResourceAnswer()).when(myJpaInterceptor).resourcePreDelete(nullable(ServletRequestDetails.class), any(Patient.class));
|
||||
doAnswer(new MyOneResourceAnswer()).when(myJpaInterceptor).resourceDeleted(nullable(ServletRequestDetails.class), any(Patient.class));
|
||||
|
||||
Patient p = new Patient();
|
||||
p.setActive(false);
|
||||
|
@ -578,8 +579,8 @@ public class FhirResourceDaoR4InterceptorTest extends BaseJpaR4Test {
|
|||
myPatientDao.delete(id);
|
||||
|
||||
InOrder inorder = inOrder(myJpaInterceptor);
|
||||
inorder.verify(myJpaInterceptor, times(1)).resourcePreDelete(any(RequestDetails.class), any(IBaseResource.class));
|
||||
inorder.verify(myJpaInterceptor, times(1)).resourceDeleted(any(RequestDetails.class), any(IBaseResource.class));
|
||||
inorder.verify(myJpaInterceptor, times(1)).resourcePreDelete(nullable(ServletRequestDetails.class), any(Patient.class));
|
||||
inorder.verify(myJpaInterceptor, times(1)).resourceDeleted(nullable(ServletRequestDetails.class), any(Patient.class));
|
||||
// resourcePreDelete
|
||||
assertEquals(idPart, myIds.get(0).getIdPart());
|
||||
assertEquals("1", myIds.get(0).getVersionIdPart());
|
||||
|
|
|
@ -63,7 +63,7 @@ public class FhirResourceDaoR4TerminologyTest extends BaseJpaR4Test {
|
|||
codeSystem.setContent(CodeSystemContentMode.NOTPRESENT);
|
||||
IIdType id = myCodeSystemDao.create(codeSystem, mySrd).getId().toUnqualified();
|
||||
|
||||
ResourceTable table = myResourceTableDao.findOne(id.getIdPartAsLong());
|
||||
ResourceTable table = myResourceTableDao.findById(id.getIdPartAsLong()).orElseThrow(IllegalStateException::new);
|
||||
|
||||
TermCodeSystemVersion cs = new TermCodeSystemVersion();
|
||||
cs.setResource(table);
|
||||
|
@ -106,7 +106,7 @@ public class FhirResourceDaoR4TerminologyTest extends BaseJpaR4Test {
|
|||
codeSystem.setContent(CodeSystemContentMode.NOTPRESENT);
|
||||
IIdType id = myCodeSystemDao.create(codeSystem, mySrd).getId().toUnqualified();
|
||||
|
||||
ResourceTable table = myResourceTableDao.findOne(id.getIdPartAsLong());
|
||||
ResourceTable table = myResourceTableDao.findById(id.getIdPartAsLong()).orElseThrow(IllegalStateException::new);
|
||||
|
||||
TermCodeSystemVersion cs = new TermCodeSystemVersion();
|
||||
cs.setResource(table);
|
||||
|
@ -143,7 +143,7 @@ public class FhirResourceDaoR4TerminologyTest extends BaseJpaR4Test {
|
|||
codeSystem.setContent(CodeSystemContentMode.NOTPRESENT);
|
||||
IIdType id = myCodeSystemDao.create(codeSystem, mySrd).getId().toUnqualified();
|
||||
|
||||
ResourceTable table = myResourceTableDao.findOne(id.getIdPartAsLong());
|
||||
ResourceTable table = myResourceTableDao.findById(id.getIdPartAsLong()).orElseThrow(IllegalStateException::new);
|
||||
|
||||
TermCodeSystemVersion cs = new TermCodeSystemVersion();
|
||||
cs.setResource(table);
|
||||
|
@ -707,7 +707,7 @@ public class FhirResourceDaoR4TerminologyTest extends BaseJpaR4Test {
|
|||
codeSystem.setContent(CodeSystemContentMode.NOTPRESENT);
|
||||
IIdType id = myCodeSystemDao.create(codeSystem, mySrd).getId().toUnqualified();
|
||||
|
||||
ResourceTable table = myResourceTableDao.findOne(id.getIdPartAsLong());
|
||||
ResourceTable table = myResourceTableDao.findById(id.getIdPartAsLong()).orElseThrow(IllegalStateException::new);
|
||||
|
||||
TermCodeSystemVersion cs = new TermCodeSystemVersion();
|
||||
cs.setResource(table);
|
||||
|
|
|
@ -3140,6 +3140,8 @@ public class FhirResourceDaoR4Test extends BaseJpaR4Test {
|
|||
assertThat(actual, contains(toValues(id3, id2, id1)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testSortByQuantity() {
|
||||
Observation res;
|
||||
|
||||
|
@ -3405,6 +3407,8 @@ public class FhirResourceDaoR4Test extends BaseJpaR4Test {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testSortByUri() {
|
||||
ConceptMap res = new ConceptMap();
|
||||
res.addGroup().setSource("http://foo2");
|
||||
|
|
|
@ -46,12 +46,13 @@ public class FhirResourceDaoR4UniqueSearchParamTest extends BaseJpaR4Test {
|
|||
public void after() {
|
||||
myDaoConfig.setDefaultSearchParamsCanBeOverridden(new DaoConfig().isDefaultSearchParamsCanBeOverridden());
|
||||
myDaoConfig.setUniqueIndexesCheckedBeforeSave(new DaoConfig().isUniqueIndexesCheckedBeforeSave());
|
||||
myDaoConfig.setSchedulingDisabled(new DaoConfig().isSchedulingDisabled());
|
||||
}
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
myDaoConfig.setDefaultSearchParamsCanBeOverridden(true);
|
||||
myDaoConfig.setSchedulingDisabled(new DaoConfig().isSchedulingDisabled());
|
||||
myDaoConfig.setSchedulingDisabled(true);
|
||||
}
|
||||
|
||||
private void createUniqueBirthdateAndGenderSps() {
|
||||
|
@ -751,7 +752,7 @@ public class FhirResourceDaoR4UniqueSearchParamTest extends BaseJpaR4Test {
|
|||
params.add("birthdate", new DateParam("2011-01-01"));
|
||||
IBundleProvider results = myPatientDao.search(params);
|
||||
assertThat(toUnqualifiedVersionlessIdValues(results), containsInAnyOrder(id1.getValue()));
|
||||
assertEquals(SearchBuilder.HandlerTypeEnum.UNIQUE_INDEX, SearchBuilder.getLastHandlerMechanismForUnitTest());
|
||||
assertEquals(SearchBuilder.getLastHandlerParamsForUnitTest().toString(), SearchBuilder.HandlerTypeEnum.UNIQUE_INDEX, SearchBuilder.getLastHandlerMechanismForUnitTest());
|
||||
}
|
||||
|
||||
|
||||
|
@ -776,7 +777,7 @@ public class FhirResourceDaoR4UniqueSearchParamTest extends BaseJpaR4Test {
|
|||
IBundleProvider results = myPatientDao.search(params);
|
||||
String searchId = results.getUuid();
|
||||
assertThat(toUnqualifiedVersionlessIdValues(results), containsInAnyOrder(id1));
|
||||
assertEquals(SearchBuilder.HandlerTypeEnum.UNIQUE_INDEX, SearchBuilder.getLastHandlerMechanismForUnitTest());
|
||||
assertEquals(SearchBuilder.getLastHandlerParamsForUnitTest().toString(), SearchBuilder.HandlerTypeEnum.UNIQUE_INDEX, SearchBuilder.getLastHandlerMechanismForUnitTest());
|
||||
|
||||
// Other order
|
||||
SearchBuilder.resetLastHandlerMechanismForUnitTest();
|
||||
|
@ -795,14 +796,14 @@ public class FhirResourceDaoR4UniqueSearchParamTest extends BaseJpaR4Test {
|
|||
params.add("birthdate", new DateParam("2011-01-03"));
|
||||
results = myPatientDao.search(params);
|
||||
assertThat(toUnqualifiedVersionlessIdValues(results), empty());
|
||||
assertEquals(SearchBuilder.HandlerTypeEnum.UNIQUE_INDEX, SearchBuilder.getLastHandlerMechanismForUnitTest());
|
||||
assertEquals(SearchBuilder.getLastHandlerParamsForUnitTest().toString(), SearchBuilder.HandlerTypeEnum.UNIQUE_INDEX, SearchBuilder.getLastHandlerMechanismForUnitTest());
|
||||
|
||||
SearchBuilder.resetLastHandlerMechanismForUnitTest();
|
||||
params = new SearchParameterMap();
|
||||
params.add("birthdate", new DateParam("2011-01-03"));
|
||||
results = myPatientDao.search(params);
|
||||
assertThat(toUnqualifiedVersionlessIdValues(results), empty());
|
||||
assertEquals(SearchBuilder.HandlerTypeEnum.STANDARD_QUERY, SearchBuilder.getLastHandlerMechanismForUnitTest());
|
||||
assertEquals(SearchBuilder.getLastHandlerParamsForUnitTest().toString(), SearchBuilder.HandlerTypeEnum.STANDARD_QUERY, SearchBuilder.getLastHandlerMechanismForUnitTest());
|
||||
|
||||
}
|
||||
|
||||
|
@ -868,7 +869,7 @@ public class FhirResourceDaoR4UniqueSearchParamTest extends BaseJpaR4Test {
|
|||
|
||||
SearchBuilder.resetLastHandlerMechanismForUnitTest();
|
||||
IIdType id1 = myPatientDao.update(pt1, "Patient?name=FAMILY1&organization:Organization=ORG").getId().toUnqualifiedVersionless();
|
||||
assertEquals(SearchBuilder.HandlerTypeEnum.UNIQUE_INDEX, SearchBuilder.getLastHandlerMechanismForUnitTest());
|
||||
assertEquals(SearchBuilder.getLastHandlerParamsForUnitTest().toString(), SearchBuilder.HandlerTypeEnum.UNIQUE_INDEX, SearchBuilder.getLastHandlerMechanismForUnitTest());
|
||||
uniques = myResourceIndexedCompositeStringUniqueDao.findAll();
|
||||
assertEquals(1, uniques.size());
|
||||
assertEquals("Patient/" + id1.getIdPart(), uniques.get(0).getResource().getIdDt().toUnqualifiedVersionless().getValue());
|
||||
|
@ -882,7 +883,7 @@ public class FhirResourceDaoR4UniqueSearchParamTest extends BaseJpaR4Test {
|
|||
|
||||
SearchBuilder.resetLastHandlerMechanismForUnitTest();
|
||||
id1 = myPatientDao.update(pt1, "Patient?name=FAMILY1&organization:Organization=ORG").getId().toUnqualifiedVersionless();
|
||||
assertEquals(SearchBuilder.HandlerTypeEnum.UNIQUE_INDEX, SearchBuilder.getLastHandlerMechanismForUnitTest());
|
||||
assertEquals(SearchBuilder.getLastHandlerParamsForUnitTest().toString(), SearchBuilder.HandlerTypeEnum.UNIQUE_INDEX, SearchBuilder.getLastHandlerMechanismForUnitTest());
|
||||
uniques = myResourceIndexedCompositeStringUniqueDao.findAll();
|
||||
assertEquals(1, uniques.size());
|
||||
assertEquals("Patient/" + id1.getIdPart(), uniques.get(0).getResource().getIdDt().toUnqualifiedVersionless().getValue());
|
||||
|
|
|
@ -512,7 +512,7 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest {
|
|||
}
|
||||
myResourceHistoryTableDao.save(resourceHistoryTable);
|
||||
|
||||
ResourceTable table = myResourceTableDao.findOne(id.getIdPartAsLong());
|
||||
ResourceTable table = myResourceTableDao.findById(id.getIdPartAsLong()).orElseThrow(IllegalStateException::new);
|
||||
table.setIndexStatus(null);
|
||||
myResourceTableDao.save(table);
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
|||
client.create().resource(resBody).execute().getId();
|
||||
fail();
|
||||
} catch (UnprocessableEntityException e) {
|
||||
assertThat(e.getMessage(), containsString("Unable to store a Bundle resource on this server with a Bundle.type of: transaction"));
|
||||
assertThat(e.getMessage(), containsString("Unable to store a Bundle resource on this server with a Bundle.type value of: transaction"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.hl7.fhir.instance.model.api.IIdType;
|
|||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
@ -316,7 +317,8 @@ public class SystemProviderDstu2Test extends BaseJpaDstu2Test {
|
|||
/**
|
||||
* This is Gramahe's test transaction - it requires some set up in order to work
|
||||
*/
|
||||
// @Test
|
||||
@Test
|
||||
@Ignore
|
||||
public void testTransactionFromBundle3() throws Exception {
|
||||
|
||||
InputStream bundleRes = SystemProviderDstu2Test.class.getResourceAsStream("/grahame-transaction.xml");
|
||||
|
|
|
@ -221,9 +221,9 @@ public class ResourceProviderCustomSearchParamDstu3Test extends BaseResourceProv
|
|||
obs2.setStatus(ObservationStatus.FINAL);
|
||||
IIdType obsId = myObservationDao.create(obs2, mySrd).getId().toUnqualifiedVersionless();
|
||||
|
||||
ResourceTable res = myResourceTableDao.findOne(patId.getIdPartAsLong());
|
||||
ResourceTable res = myResourceTableDao.findById(patId.getIdPartAsLong()).orElseThrow(IllegalStateException::new);
|
||||
assertEquals(BaseHapiFhirDao.INDEX_STATUS_INDEXED, res.getIndexStatus().longValue());
|
||||
res = myResourceTableDao.findOne(obsId.getIdPartAsLong());
|
||||
res = myResourceTableDao.findById(obsId.getIdPartAsLong()).orElseThrow(IllegalStateException::new);
|
||||
assertEquals(BaseHapiFhirDao.INDEX_STATUS_INDEXED, res.getIndexStatus().longValue());
|
||||
|
||||
SearchParameter fooSp = new SearchParameter();
|
||||
|
@ -236,9 +236,9 @@ public class ResourceProviderCustomSearchParamDstu3Test extends BaseResourceProv
|
|||
fooSp.setStatus(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.ACTIVE);
|
||||
mySearchParameterDao.create(fooSp, mySrd);
|
||||
|
||||
res = myResourceTableDao.findOne(patId.getIdPartAsLong());
|
||||
res = myResourceTableDao.findById(patId.getIdPartAsLong()).orElseThrow(IllegalStateException::new);
|
||||
assertEquals(null, res.getIndexStatus());
|
||||
res = myResourceTableDao.findOne(obsId.getIdPartAsLong());
|
||||
res = myResourceTableDao.findById(obsId.getIdPartAsLong()).orElseThrow(IllegalStateException::new);
|
||||
assertEquals(BaseHapiFhirDao.INDEX_STATUS_INDEXED, res.getIndexStatus().longValue());
|
||||
|
||||
}
|
||||
|
|
|
@ -547,7 +547,7 @@ public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3
|
|||
codeSystem.setContent(CodeSystemContentMode.NOTPRESENT);
|
||||
IIdType id = theCodeSystemDao.create(codeSystem, theRequestDetails).getId().toUnqualified();
|
||||
|
||||
ResourceTable table = theResourceTableDao.findOne(id.getIdPartAsLong());
|
||||
ResourceTable table = theResourceTableDao.findById(id.getIdPartAsLong()).orElseThrow(IllegalStateException::new);
|
||||
|
||||
TermCodeSystemVersion cs = new TermCodeSystemVersion();
|
||||
cs.setResource(table);
|
||||
|
|
|
@ -519,7 +519,8 @@ public class SystemProviderDstu3Test extends BaseJpaDstu3Test {
|
|||
/**
|
||||
* This is Gramahe's test transaction - it requires some set up in order to work
|
||||
*/
|
||||
// @Test
|
||||
@Test
|
||||
@Ignore
|
||||
public void testTransactionFromBundle3() throws Exception {
|
||||
|
||||
InputStream bundleRes = SystemProviderDstu3Test.class.getResourceAsStream("/grahame-transaction.xml");
|
||||
|
|
|
@ -221,9 +221,9 @@ public class ResourceProviderCustomSearchParamR4Test extends BaseResourceProvide
|
|||
obs2.setStatus(ObservationStatus.FINAL);
|
||||
IIdType obsId = myObservationDao.create(obs2, mySrd).getId().toUnqualifiedVersionless();
|
||||
|
||||
ResourceTable res = myResourceTableDao.findOne(patId.getIdPartAsLong());
|
||||
ResourceTable res = myResourceTableDao.findById(patId.getIdPartAsLong()).orElseThrow(IllegalStateException::new);
|
||||
assertEquals(BaseHapiFhirDao.INDEX_STATUS_INDEXED, res.getIndexStatus().longValue());
|
||||
res = myResourceTableDao.findOne(obsId.getIdPartAsLong());
|
||||
res = myResourceTableDao.findById(obsId.getIdPartAsLong()).orElseThrow(IllegalStateException::new);
|
||||
assertEquals(BaseHapiFhirDao.INDEX_STATUS_INDEXED, res.getIndexStatus().longValue());
|
||||
|
||||
SearchParameter fooSp = new SearchParameter();
|
||||
|
@ -236,9 +236,9 @@ public class ResourceProviderCustomSearchParamR4Test extends BaseResourceProvide
|
|||
fooSp.setStatus(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE);
|
||||
mySearchParameterDao.create(fooSp, mySrd);
|
||||
|
||||
res = myResourceTableDao.findOne(patId.getIdPartAsLong());
|
||||
res = myResourceTableDao.findById(patId.getIdPartAsLong()).orElseThrow(IllegalStateException::new);
|
||||
assertEquals(null, res.getIndexStatus());
|
||||
res = myResourceTableDao.findOne(obsId.getIdPartAsLong());
|
||||
res = myResourceTableDao.findById(obsId.getIdPartAsLong()).orElseThrow(IllegalStateException::new);
|
||||
assertEquals(BaseHapiFhirDao.INDEX_STATUS_INDEXED, res.getIndexStatus().longValue());
|
||||
|
||||
}
|
||||
|
|
|
@ -488,7 +488,7 @@ public class ResourceProviderR4ValueSetTest extends BaseResourceProviderR4Test {
|
|||
codeSystem.setContent(CodeSystemContentMode.NOTPRESENT);
|
||||
IIdType id = theCodeSystemDao.create(codeSystem, theRequestDetails).getId().toUnqualified();
|
||||
|
||||
ResourceTable table = theResourceTableDao.findOne(id.getIdPartAsLong());
|
||||
ResourceTable table = theResourceTableDao.findById(id.getIdPartAsLong()).orElseThrow(IllegalStateException::new);
|
||||
|
||||
TermCodeSystemVersion cs = new TermCodeSystemVersion();
|
||||
cs.setResource(table);
|
||||
|
|
|
@ -476,7 +476,8 @@ public class SystemProviderR4Test extends BaseJpaR4Test {
|
|||
/**
|
||||
* This is Gramahe's test transaction - it requires some set up in order to work
|
||||
*/
|
||||
// @Test
|
||||
@Test
|
||||
@Ignore
|
||||
public void testTransactionFromBundle3() throws Exception {
|
||||
|
||||
InputStream bundleRes = SystemProviderR4Test.class.getResourceAsStream("/grahame-transaction.xml");
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.mockito.Captor;
|
|||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.stubbing.Answer;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
|
@ -143,8 +143,6 @@ public class SearchCoordinatorSvcImplTest {
|
|||
Iterator<Long> iter = new FailAfterNIterator<Long>(new SlowIterator<Long>(pids.iterator(), 2), 300);
|
||||
when(mySearchBuider.createQuery(Mockito.same(params), any(String.class))).thenReturn(iter);
|
||||
|
||||
doAnswer(loadPids()).when(mySearchBuider).loadResourcesByPid(any(List.class), any(List.class), any(Set.class), anyBoolean(), any(EntityManager.class), any(FhirContext.class), same(myCallingDao));
|
||||
|
||||
IBundleProvider result = mySvc.registerSearch(myCallingDao, params, "Patient", new CacheControlDirective());
|
||||
assertNotNull(result.getUuid());
|
||||
assertEquals(null, result.size());
|
||||
|
@ -182,7 +180,7 @@ public class SearchCoordinatorSvcImplTest {
|
|||
ArgumentCaptor<Search> searchCaptor = ArgumentCaptor.forClass(Search.class);
|
||||
verify(mySearchDao, atLeastOnce()).save(searchCaptor.capture());
|
||||
|
||||
verify(mySearchResultDao, atLeastOnce()).save(mySearchResultIterCaptor.capture());
|
||||
verify(mySearchResultDao, atLeastOnce()).saveAll(mySearchResultIterCaptor.capture());
|
||||
List<SearchResult> allResults = new ArrayList<SearchResult>();
|
||||
for (Iterable<SearchResult> next : mySearchResultIterCaptor.getAllValues()) {
|
||||
allResults.addAll(Lists.newArrayList(next));
|
||||
|
@ -330,7 +328,7 @@ public class SearchCoordinatorSvcImplTest {
|
|||
|
||||
ArrayList<SearchResult> results = new ArrayList<SearchResult>();
|
||||
int max = (page.getPageNumber() * page.getPageSize()) + page.getPageSize();
|
||||
for (int i = page.getOffset(); i < max; i++) {
|
||||
for (long i = page.getOffset(); i < max; i++) {
|
||||
results.add(new SearchResult().setResourcePid(i + 10L));
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ public class TerminologySvcImplDstu3Test extends BaseJpaDstu3Test {
|
|||
codeSystem.setContent(CodeSystemContentMode.NOTPRESENT);
|
||||
IIdType id = myCodeSystemDao.create(codeSystem, mySrd).getId().toUnqualified();
|
||||
|
||||
ResourceTable table = myResourceTableDao.findOne(id.getIdPartAsLong());
|
||||
ResourceTable table = myResourceTableDao.findById(id.getIdPartAsLong()).orElseThrow(IllegalArgumentException::new);
|
||||
|
||||
TermCodeSystemVersion cs = new TermCodeSystemVersion();
|
||||
cs.setResource(table);
|
||||
|
@ -91,7 +91,7 @@ public class TerminologySvcImplDstu3Test extends BaseJpaDstu3Test {
|
|||
codeSystem.setContent(CodeSystemContentMode.NOTPRESENT);
|
||||
IIdType id = myCodeSystemDao.create(codeSystem, mySrd).getId().toUnqualified();
|
||||
|
||||
ResourceTable table = myResourceTableDao.findOne(id.getIdPartAsLong());
|
||||
ResourceTable table = myResourceTableDao.findById(id.getIdPartAsLong()).orElseThrow(IllegalArgumentException::new);
|
||||
|
||||
TermCodeSystemVersion cs = new TermCodeSystemVersion();
|
||||
cs.setResource(table);
|
||||
|
@ -111,7 +111,7 @@ public class TerminologySvcImplDstu3Test extends BaseJpaDstu3Test {
|
|||
codeSystem.setContent(CodeSystemContentMode.NOTPRESENT);
|
||||
IIdType id = myCodeSystemDao.create(codeSystem, mySrd).getId().toUnqualified();
|
||||
|
||||
ResourceTable table = myResourceTableDao.findOne(id.getIdPartAsLong());
|
||||
ResourceTable table = myResourceTableDao.findById(id.getIdPartAsLong()).orElseThrow(IllegalArgumentException::new);
|
||||
|
||||
TermCodeSystemVersion cs = new TermCodeSystemVersion();
|
||||
cs.setResource(table);
|
||||
|
@ -123,7 +123,7 @@ public class TerminologySvcImplDstu3Test extends BaseJpaDstu3Test {
|
|||
TermConcept parentA = new TermConcept(cs, "ParentA");
|
||||
cs.getConcepts().add(parentA);
|
||||
id = myCodeSystemDao.update(codeSystem, null, true, true, mySrd).getId().toUnqualified();
|
||||
table = myResourceTableDao.findOne(id.getIdPartAsLong());
|
||||
table = myResourceTableDao.findById(id.getIdPartAsLong()).orElseThrow(IllegalArgumentException::new);
|
||||
cs.setResource(table);
|
||||
myTermSvc.storeNewCodeSystemVersion(table.getId(), CS_URL, "SYSTEM NAME", cs);
|
||||
|
||||
|
@ -132,7 +132,7 @@ public class TerminologySvcImplDstu3Test extends BaseJpaDstu3Test {
|
|||
codeSystem.setUrl(CS_URL);
|
||||
codeSystem.setContent(CodeSystemContentMode.NOTPRESENT);
|
||||
id = myCodeSystemDao.create(codeSystem, mySrd).getId().toUnqualified();
|
||||
table = myResourceTableDao.findOne(id.getIdPartAsLong());
|
||||
table = myResourceTableDao.findById(id.getIdPartAsLong()).orElseThrow(IllegalArgumentException::new);
|
||||
cs.setResource(table);
|
||||
try {
|
||||
myTermSvc.storeNewCodeSystemVersion(table.getId(), CS_URL, "SYSTEM NAME", cs);
|
||||
|
@ -393,7 +393,7 @@ public class TerminologySvcImplDstu3Test extends BaseJpaDstu3Test {
|
|||
codeSystem.setContent(CodeSystemContentMode.NOTPRESENT);
|
||||
IIdType id = myCodeSystemDao.create(codeSystem, mySrd).getId().toUnqualified();
|
||||
|
||||
ResourceTable table = myResourceTableDao.findOne(id.getIdPartAsLong());
|
||||
ResourceTable table = myResourceTableDao.findById(id.getIdPartAsLong()).orElseThrow(IllegalArgumentException::new);
|
||||
|
||||
TermCodeSystemVersion cs = new TermCodeSystemVersion();
|
||||
cs.setResource(table);
|
||||
|
|
|
@ -21,7 +21,7 @@ package ca.uhn.fhir.jpa.search;
|
|||
*/
|
||||
|
||||
import org.hibernate.search.elasticsearch.analyzer.definition.ElasticsearchAnalysisDefinitionRegistryBuilder;
|
||||
import org.hibernate.search.elasticsearch.analyzer.definition.spi.ElasticsearchAnalysisDefinitionProvider;
|
||||
import org.hibernate.search.elasticsearch.analyzer.definition.ElasticsearchAnalysisDefinitionProvider;
|
||||
|
||||
public class ElasticsearchMappingProvider implements ElasticsearchAnalysisDefinitionProvider {
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ public class FhirServerConfig extends BaseJavaConfigDstu3 {
|
|||
extraProperties.put("hibernate.cache.use_minimal_puts", "false");
|
||||
|
||||
// the belowing properties are used for ElasticSearch integration
|
||||
extraProperties.put(ElasticsearchEnvironment.ANALYZER_DEFINITION_PROVIDER, ElasticsearchMappingProvider.class.getName());
|
||||
extraProperties.put(ElasticsearchEnvironment.ANALYSIS_DEFINITION_PROVIDER, ElasticsearchMappingProvider.class.getName());
|
||||
extraProperties.put("hibernate.search.default.indexmanager", "elasticsearch");
|
||||
extraProperties.put("hibernate.search.default.elasticsearch.host", "http://127.0.0.1:9200");
|
||||
extraProperties.put("hibernate.search.default.elasticsearch.index_schema_management_strategy", "CREATE");
|
||||
|
|
|
@ -27,6 +27,8 @@ import ca.uhn.fhir.context.FhirContext;
|
|||
import ca.uhn.fhir.rest.server.method.BaseMethodBinding;
|
||||
import ca.uhn.fhir.util.VersionUtil;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
|
||||
public class RestulfulServerConfiguration {
|
||||
|
||||
private Collection<ResourceBinding> resourceBindings;
|
||||
|
@ -84,6 +86,9 @@ public class RestulfulServerConfiguration {
|
|||
* @return the implementationDescription
|
||||
*/
|
||||
public String getImplementationDescription() {
|
||||
if (isBlank(implementationDescription)) {
|
||||
return "HAPI FHIR";
|
||||
}
|
||||
return implementationDescription;
|
||||
}
|
||||
|
||||
|
|
|
@ -116,4 +116,16 @@
|
|||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -18,4 +18,16 @@
|
|||
<module>hapi-fhir-spring-boot-sample-server-jpa</module>
|
||||
</modules>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
</project>
|
|
@ -1,4 +1,4 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -25,4 +25,16 @@
|
|||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -18,6 +18,18 @@
|
|||
<module>hapi-fhir-spring-boot-samples</module>
|
||||
</modules>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
|
|
@ -14,6 +14,14 @@
|
|||
<name>HAPI FHIR Structures - DSTU1 (FHIR v0.80)</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-base</artifactId>
|
||||
|
|
|
@ -192,6 +192,8 @@
|
|||
<artifactId>spring-web</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Dependencies for Schematron -->
|
||||
<dependency>
|
||||
<groupId>com.helger</groupId>
|
||||
<artifactId>ph-schematron</artifactId>
|
||||
|
@ -202,6 +204,27 @@
|
|||
<artifactId>ph-commons</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.activation</groupId>
|
||||
<artifactId>javax.activation-api</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-impl</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<reporting>
|
||||
|
|
|
@ -24,10 +24,12 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
|||
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.dstu2016may.model.*;
|
||||
import org.hl7.fhir.dstu2016may.model.Conformance.*;
|
||||
|
@ -64,21 +66,27 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
private IdentityHashMap<OperationMethodBinding, String> myOperationBindingToName;
|
||||
private HashMap<String, List<OperationMethodBinding>> myOperationNameToBindings;
|
||||
private String myPublisher = "Not provided";
|
||||
private RestulfulServerConfiguration myServerConfiguration;
|
||||
private Callable<RestulfulServerConfiguration> myServerConfiguration;
|
||||
|
||||
/*
|
||||
* Add a no-arg constructor and seetter so that the ServerConfirmanceProvider can be Spring-wired with the RestfulService avoiding the potential reference cycle that would happen.
|
||||
/**
|
||||
* No-arg constructor and seetter so that the ServerConfirmanceProvider can be Spring-wired with the RestfulService avoiding the potential reference cycle that would happen.
|
||||
*/
|
||||
public ServerConformanceProvider() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public ServerConformanceProvider(RestfulServer theRestfulServer) {
|
||||
this.myServerConfiguration = theRestfulServer.createConfiguration();
|
||||
this.myServerConfiguration = theRestfulServer::createConfiguration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public ServerConformanceProvider(RestulfulServerConfiguration theServerConfiguration) {
|
||||
this.myServerConfiguration = theServerConfiguration;
|
||||
this.myServerConfiguration = () -> theServerConfiguration;
|
||||
}
|
||||
|
||||
private void checkBindingForSystemOps(ConformanceRestComponent rest, Set<SystemRestfulInteraction> systemOps, BaseMethodBinding<?> nextMethodBinding) {
|
||||
|
@ -103,20 +111,20 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
}
|
||||
|
||||
private Map<String, List<BaseMethodBinding<?>>> collectMethodBindings() {
|
||||
Map<String, List<BaseMethodBinding<?>>> resourceToMethods = new TreeMap<String, List<BaseMethodBinding<?>>>();
|
||||
for (ResourceBinding next : myServerConfiguration.getResourceBindings()) {
|
||||
Map<String, List<BaseMethodBinding<?>>> resourceToMethods = new TreeMap<>();
|
||||
for (ResourceBinding next : getServerConfiguration().getResourceBindings()) {
|
||||
String resourceName = next.getResourceName();
|
||||
for (BaseMethodBinding<?> nextMethodBinding : next.getMethodBindings()) {
|
||||
if (resourceToMethods.containsKey(resourceName) == false) {
|
||||
resourceToMethods.put(resourceName, new ArrayList<BaseMethodBinding<?>>());
|
||||
resourceToMethods.put(resourceName, new ArrayList<>());
|
||||
}
|
||||
resourceToMethods.get(resourceName).add(nextMethodBinding);
|
||||
}
|
||||
}
|
||||
for (BaseMethodBinding<?> nextMethodBinding : myServerConfiguration.getServerBindings()) {
|
||||
for (BaseMethodBinding<?> nextMethodBinding : getServerConfiguration().getServerBindings()) {
|
||||
String resourceName = "";
|
||||
if (resourceToMethods.containsKey(resourceName) == false) {
|
||||
resourceToMethods.put(resourceName, new ArrayList<BaseMethodBinding<?>>());
|
||||
resourceToMethods.put(resourceName, new ArrayList<>());
|
||||
}
|
||||
resourceToMethods.get(resourceName).add(nextMethodBinding);
|
||||
}
|
||||
|
@ -124,7 +132,7 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
}
|
||||
|
||||
private DateTimeType conformanceDate() {
|
||||
String buildDate = myServerConfiguration.getConformanceDate();
|
||||
String buildDate = getServerConfiguration().getConformanceDate();
|
||||
if (buildDate != null) {
|
||||
try {
|
||||
return new DateTimeType(buildDate);
|
||||
|
@ -180,10 +188,16 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
// effort since the parser
|
||||
// needs to be modified to actually allow it
|
||||
|
||||
retVal.getImplementation().setDescription(myServerConfiguration.getImplementationDescription());
|
||||
ServletContext servletContext = (ServletContext) (theRequest == null ? null : theRequest.getAttribute(RestfulServer.SERVLET_CONTEXT_ATTRIBUTE));
|
||||
String serverBase = getServerConfiguration().getServerAddressStrategy().determineServerBase(servletContext, theRequest);
|
||||
retVal
|
||||
.getImplementation()
|
||||
.setUrl(serverBase)
|
||||
.setDescription(getServerConfiguration().getImplementationDescription());
|
||||
|
||||
retVal.setKind(ConformanceStatementKind.INSTANCE);
|
||||
retVal.getSoftware().setName(myServerConfiguration.getServerName());
|
||||
retVal.getSoftware().setVersion(myServerConfiguration.getServerVersion());
|
||||
retVal.getSoftware().setName(getServerConfiguration().getServerName());
|
||||
retVal.getSoftware().setVersion(getServerConfiguration().getServerVersion());
|
||||
retVal.addFormat(Constants.CT_FHIR_XML);
|
||||
retVal.addFormat(Constants.CT_FHIR_JSON);
|
||||
retVal.setStatus(ConformanceResourceStatus.ACTIVE);
|
||||
|
@ -191,23 +205,21 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
ConformanceRestComponent rest = retVal.addRest();
|
||||
rest.setMode(RestfulConformanceMode.SERVER);
|
||||
|
||||
Set<SystemRestfulInteraction> systemOps = new HashSet<SystemRestfulInteraction>();
|
||||
Set<String> operationNames = new HashSet<String>();
|
||||
Set<SystemRestfulInteraction> systemOps = new HashSet<>();
|
||||
Set<String> operationNames = new HashSet<>();
|
||||
|
||||
Map<String, List<BaseMethodBinding<?>>> resourceToMethods = collectMethodBindings();
|
||||
for (Entry<String, List<BaseMethodBinding<?>>> nextEntry : resourceToMethods.entrySet()) {
|
||||
|
||||
if (nextEntry.getKey().isEmpty() == false) {
|
||||
Set<TypeRestfulInteraction> resourceOps = new HashSet<TypeRestfulInteraction>();
|
||||
Set<TypeRestfulInteraction> resourceOps = new HashSet<>();
|
||||
ConformanceRestResourceComponent resource = rest.addResource();
|
||||
String resourceName = nextEntry.getKey();
|
||||
RuntimeResourceDefinition def = myServerConfiguration.getFhirContext().getResourceDefinition(resourceName);
|
||||
RuntimeResourceDefinition def = getServerConfiguration().getFhirContext().getResourceDefinition(resourceName);
|
||||
resource.getTypeElement().setValue(def.getName());
|
||||
ServletContext servletContext = (ServletContext) (theRequest == null ? null : theRequest.getAttribute(RestfulServer.SERVLET_CONTEXT_ATTRIBUTE));
|
||||
String serverBase = myServerConfiguration.getServerAddressStrategy().determineServerBase(servletContext, theRequest);
|
||||
resource.getProfile().setReference((def.getResourceProfile(serverBase)));
|
||||
|
||||
TreeSet<String> includes = new TreeSet<String>();
|
||||
TreeSet<String> includes = new TreeSet<>();
|
||||
|
||||
// Map<String, Conformance.RestResourceSearchParam> nameToSearchParam = new HashMap<String,
|
||||
// Conformance.RestResourceSearchParam>();
|
||||
|
@ -273,7 +285,7 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
}
|
||||
}
|
||||
|
||||
Collections.sort(resource.getInteraction(), new Comparator<ResourceInteractionComponent>() {
|
||||
resource.getInteraction().sort(new Comparator<ResourceInteractionComponent>() {
|
||||
@Override
|
||||
public int compare(ResourceInteractionComponent theO1, ResourceInteractionComponent theO2) {
|
||||
TypeRestfulInteraction o1 = theO1.getCode();
|
||||
|
@ -428,7 +440,7 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
param.getTypeElement().setValueAsString(nextParameter.getParamType().getCode());
|
||||
}
|
||||
for (Class<? extends IBaseResource> nextTarget : nextParameter.getDeclaredTypes()) {
|
||||
RuntimeResourceDefinition targetDef = myServerConfiguration.getFhirContext().getResourceDefinition(nextTarget);
|
||||
RuntimeResourceDefinition targetDef = getServerConfiguration().getFhirContext().getResourceDefinition(nextTarget);
|
||||
if (targetDef != null) {
|
||||
ResourceType code;
|
||||
try {
|
||||
|
@ -590,11 +602,15 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
|
||||
@Override
|
||||
public void setRestfulServer(RestfulServer theRestfulServer) {
|
||||
myServerConfiguration = theRestfulServer.createConfiguration();
|
||||
myServerConfiguration = theRestfulServer::createConfiguration;
|
||||
}
|
||||
|
||||
RestulfulServerConfiguration getServerConfiguration() {
|
||||
return myServerConfiguration;
|
||||
try {
|
||||
return myServerConfiguration.call();
|
||||
} catch (Exception e) {
|
||||
throw new InternalErrorException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void sortRuntimeSearchParameters(List<RuntimeSearchParam> searchParameters) {
|
||||
|
|
|
@ -2440,7 +2440,7 @@ public class XmlParserDstu2_1Test {
|
|||
assertThat(patient.getIdentifier().get(0).getType().getCoding(), IsEmptyCollection.empty());
|
||||
|
||||
ArgumentCaptor<String> capt = ArgumentCaptor.forClass(String.class);
|
||||
verify(errorHandler, times(1)).unknownAttribute(any(IParseLocation.class), capt.capture());
|
||||
verify(errorHandler, times(1)).unknownAttribute(nullable(IParseLocation.class), capt.capture());
|
||||
|
||||
assertEquals("value", capt.getValue());
|
||||
}
|
||||
|
|
|
@ -470,7 +470,7 @@ public class GenericClientDstu2_1Test {
|
|||
when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
|
||||
when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
|
||||
when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||
when(myHttpResponse.getEntity().getContent()).thenThrow(IllegalStateException.class, RuntimeException.class, Exception.class);
|
||||
when(myHttpResponse.getEntity().getContent()).thenThrow(IllegalStateException.class, RuntimeException.class, IOException.class);
|
||||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://example.com/fhir");
|
||||
|
||||
|
@ -492,7 +492,7 @@ public class GenericClientDstu2_1Test {
|
|||
client.read().resource(Patient.class).withId("1").execute();
|
||||
fail();
|
||||
} catch (FhirClientConnectionException e) {
|
||||
assertEquals("java.lang.Exception", e.getMessage());
|
||||
assertThat(e.getMessage(), containsString("java.io.IOException"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package ca.uhn.fhir.rest.client;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.ArgumentMatchers.nullable;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
@ -45,10 +46,10 @@ public class RestfulClientFactoryTest {
|
|||
when(ctx.getVersion()).thenReturn(FhirVersionEnum.DSTU2_1.getVersionImplementation());
|
||||
when(ctx.getRestfulClientFactory()).thenReturn(restfulClientFactory);
|
||||
|
||||
when(restfulClientFactory.getHttpClient(any(StringBuilder.class), (Map<String, List<String>>)any(Map.class), any(String.class), any(RequestTypeEnum.class), any(List.class))).thenReturn(httpClient);
|
||||
when(restfulClientFactory.getHttpClient(any(StringBuilder.class), (Map<String, List<String>>)nullable(Map.class), nullable(String.class), any(RequestTypeEnum.class), any(List.class))).thenReturn(httpClient);
|
||||
|
||||
IHttpRequest httpRequest = mock(IHttpRequest.class);
|
||||
when(httpClient.createGetRequest(any(FhirContext.class), any(EncodingEnum.class))).thenReturn(httpRequest);
|
||||
when(httpClient.createGetRequest(any(FhirContext.class), nullable(EncodingEnum.class))).thenReturn(httpRequest);
|
||||
|
||||
IHttpResponse httpResponse = mock(IHttpResponse.class);
|
||||
when(httpRequest.execute()).thenReturn(httpResponse);
|
||||
|
|
|
@ -2,12 +2,9 @@ package ca.uhn.fhir.rest.server;
|
|||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.mockito.ArgumentMatchers.nullable;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.inOrder;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@ -27,6 +24,7 @@ import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
|||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.servlet.ServletHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.hl7.fhir.dstu2016may.model.OperationOutcome;
|
||||
import org.hl7.fhir.dstu2016may.model.Patient;
|
||||
import org.junit.*;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
@ -43,9 +41,11 @@ import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor.ActionRequestDetai
|
|||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.PortUtil;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class InterceptorDstu2_1Test {
|
||||
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(InterceptorDstu2_1Test.class);
|
||||
private static CloseableHttpClient ourClient;
|
||||
private static FhirContext ourCtx = FhirContext.forDstu2_1();
|
||||
private static int ourPort;
|
||||
|
@ -56,22 +56,22 @@ public class InterceptorDstu2_1Test {
|
|||
|
||||
@Before
|
||||
public void before() {
|
||||
myInterceptor1 = mock(IServerInterceptor.class);
|
||||
myInterceptor2 = mock(IServerInterceptor.class);
|
||||
myInterceptor1 = mock(IServerInterceptor.class, withSettings().verboseLogging());
|
||||
myInterceptor2 = mock(IServerInterceptor.class, withSettings().verboseLogging());
|
||||
ourServlet.setInterceptors(myInterceptor1, myInterceptor2);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testValidate() throws Exception {
|
||||
when(myInterceptor1.incomingRequestPreProcessed(any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
|
||||
when(myInterceptor1.incomingRequestPostProcessed(any(RequestDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
|
||||
when(myInterceptor1.outgoingResponse(any(RequestDetails.class), any(IResource.class))).thenReturn(true);
|
||||
when(myInterceptor1.outgoingResponse(any(RequestDetails.class), any(ResponseDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
|
||||
when(myInterceptor1.incomingRequestPreProcessed(nullable(HttpServletRequest.class), nullable(HttpServletResponse.class))).thenReturn(true);
|
||||
when(myInterceptor1.incomingRequestPostProcessed(nullable(ServletRequestDetails.class), nullable(HttpServletRequest.class), nullable(HttpServletResponse.class))).thenReturn(true);
|
||||
when(myInterceptor1.outgoingResponse(any(ServletRequestDetails.class), any(OperationOutcome.class))).thenReturn(true);
|
||||
when(myInterceptor1.outgoingResponse(nullable(ServletRequestDetails.class), nullable(ResponseDetails.class), nullable(HttpServletRequest.class), nullable(HttpServletResponse.class))).thenReturn(true);
|
||||
when(myInterceptor2.incomingRequestPreProcessed(any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
|
||||
when(myInterceptor2.incomingRequestPostProcessed(any(RequestDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
|
||||
when(myInterceptor2.outgoingResponse(any(RequestDetails.class), any(IResource.class))).thenReturn(true);
|
||||
when(myInterceptor2.outgoingResponse(any(RequestDetails.class), any(ResponseDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
|
||||
when(myInterceptor2.incomingRequestPostProcessed(nullable(ServletRequestDetails.class), nullable(HttpServletRequest.class), nullable(HttpServletResponse.class))).thenReturn(true);
|
||||
when(myInterceptor2.outgoingResponse(nullable(ServletRequestDetails.class), nullable(OperationOutcome.class))).thenReturn(true);
|
||||
when(myInterceptor2.outgoingResponse(nullable(ServletRequestDetails.class), nullable(ResponseDetails.class), nullable(HttpServletRequest.class), nullable(HttpServletResponse.class))).thenReturn(true);
|
||||
|
||||
//@formatter:off
|
||||
String input =
|
||||
|
@ -95,30 +95,32 @@ public class InterceptorDstu2_1Test {
|
|||
"}";
|
||||
//@formatter:on
|
||||
|
||||
ourLog.info("Starting call");
|
||||
|
||||
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/$validate");
|
||||
httpPost.setEntity(new StringEntity(input, ContentType.create(Constants.CT_FHIR_JSON, "UTF-8")));
|
||||
HttpResponse status = ourClient.execute(httpPost);
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
InOrder order = inOrder(myInterceptor1, myInterceptor2);
|
||||
order.verify(myInterceptor1, times(1)).incomingRequestPreProcessed(any(HttpServletRequest.class), any(HttpServletResponse.class));
|
||||
order.verify(myInterceptor2, times(1)).incomingRequestPreProcessed(any(HttpServletRequest.class), any(HttpServletResponse.class));
|
||||
order.verify(myInterceptor1, times(1)).incomingRequestPostProcessed(any(RequestDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class));
|
||||
order.verify(myInterceptor2, times(1)).incomingRequestPostProcessed(any(RequestDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class));
|
||||
order.verify(myInterceptor1, times(1)).incomingRequestPreProcessed(nullable(HttpServletRequest.class), nullable(HttpServletResponse.class));
|
||||
order.verify(myInterceptor2, times(1)).incomingRequestPreProcessed(nullable(HttpServletRequest.class), nullable(HttpServletResponse.class));
|
||||
order.verify(myInterceptor1, times(1)).incomingRequestPostProcessed(nullable(ServletRequestDetails.class), nullable(HttpServletRequest.class), nullable(HttpServletResponse.class));
|
||||
order.verify(myInterceptor2, times(1)).incomingRequestPostProcessed(nullable(ServletRequestDetails.class), nullable(HttpServletRequest.class), nullable(HttpServletResponse.class));
|
||||
ArgumentCaptor<RestOperationTypeEnum> opTypeCapt = ArgumentCaptor.forClass(RestOperationTypeEnum.class);
|
||||
ArgumentCaptor<ActionRequestDetails> arTypeCapt = ArgumentCaptor.forClass(ActionRequestDetails.class);
|
||||
order.verify(myInterceptor1, times(1)).incomingRequestPreHandled(opTypeCapt.capture(), arTypeCapt.capture());
|
||||
order.verify(myInterceptor2, times(1)).incomingRequestPreHandled(any(RestOperationTypeEnum.class), any(ActionRequestDetails.class));
|
||||
order.verify(myInterceptor2, times(1)).outgoingResponse(any(RequestDetails.class), any(IResource.class));
|
||||
order.verify(myInterceptor2, times(1)).outgoingResponse(any(RequestDetails.class), any(ResponseDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class));
|
||||
order.verify(myInterceptor1, times(1)).outgoingResponse(any(RequestDetails.class), any(IResource.class));
|
||||
order.verify(myInterceptor1, times(1)).outgoingResponse(any(RequestDetails.class), any(ResponseDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class));
|
||||
order.verify(myInterceptor2, times(1)).incomingRequestPreHandled(nullable(RestOperationTypeEnum.class), nullable(ActionRequestDetails.class));
|
||||
order.verify(myInterceptor2, times(1)).outgoingResponse(nullable(ServletRequestDetails.class), nullable(OperationOutcome.class));
|
||||
order.verify(myInterceptor2, times(1)).outgoingResponse(nullable(ServletRequestDetails.class), nullable(ResponseDetails.class), nullable(HttpServletRequest.class), nullable(HttpServletResponse.class));
|
||||
order.verify(myInterceptor1, times(1)).outgoingResponse(nullable(ServletRequestDetails.class), nullable(OperationOutcome.class));
|
||||
order.verify(myInterceptor1, times(1)).outgoingResponse(nullable(ServletRequestDetails.class), nullable(ResponseDetails.class), nullable(HttpServletRequest.class), nullable(HttpServletResponse.class));
|
||||
|
||||
// Avoid concurrency issues
|
||||
Thread.sleep(500);
|
||||
|
||||
order.verify(myInterceptor2, times(1)).processingCompletedNormally(any(ServletRequestDetails.class));
|
||||
order.verify(myInterceptor1, times(1)).processingCompletedNormally(any(ServletRequestDetails.class));
|
||||
order.verify(myInterceptor2, times(1)).processingCompletedNormally(nullable(ServletRequestDetails.class));
|
||||
order.verify(myInterceptor1, times(1)).processingCompletedNormally(nullable(ServletRequestDetails.class));
|
||||
verifyNoMoreInteractions(myInterceptor1);
|
||||
verifyNoMoreInteractions(myInterceptor2);
|
||||
|
||||
|
|
|
@ -102,14 +102,31 @@
|
|||
<artifactId>thymeleaf</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Dependencies for Schematron -->
|
||||
<dependency>
|
||||
<groupId>com.helger</groupId>
|
||||
<artifactId>ph-schematron</artifactId>
|
||||
<scope>test</scope><!-- <exclusions> <exclusion> <artifactId>Saxon-HE</artifactId> <groupId>net.sf.saxon</groupId> </exclusion> </exclusions> -->
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.helger</groupId>
|
||||
<artifactId>ph-commons</artifactId>
|
||||
<groupId>javax.activation</groupId>
|
||||
<artifactId>javax.activation-api</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-impl</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
|
|
@ -1,6 +1,45 @@
|
|||
package ca.uhn.fhir.rest.server.provider.dstu2;
|
||||
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||
import ca.uhn.fhir.context.RuntimeSearchParam;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Conformance;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Conformance.Rest;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Conformance.RestResource;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Conformance.RestResourceInteraction;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Conformance.RestResourceSearchParam;
|
||||
import ca.uhn.fhir.model.dstu2.resource.OperationDefinition;
|
||||
import ca.uhn.fhir.model.dstu2.resource.OperationDefinition.Parameter;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.*;
|
||||
import ca.uhn.fhir.model.primitive.DateTimeDt;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
import ca.uhn.fhir.rest.annotation.Initialize;
|
||||
import ca.uhn.fhir.rest.annotation.Metadata;
|
||||
import ca.uhn.fhir.rest.annotation.Read;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.RestSearchParameterTypeEnum;
|
||||
import ca.uhn.fhir.rest.server.IServerConformanceProvider;
|
||||
import ca.uhn.fhir.rest.server.ResourceBinding;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
import ca.uhn.fhir.rest.server.RestulfulServerConfiguration;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import ca.uhn.fhir.rest.server.method.*;
|
||||
import ca.uhn.fhir.rest.server.method.OperationMethodBinding.ReturnType;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR Structures - DSTU2 (FHIR v1.0.0)
|
||||
|
@ -20,35 +59,6 @@ import static org.apache.commons.lang3.StringUtils.isBlank;
|
|||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||
import ca.uhn.fhir.context.RuntimeSearchParam;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Conformance;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Conformance.*;
|
||||
import ca.uhn.fhir.model.dstu2.resource.OperationDefinition;
|
||||
import ca.uhn.fhir.model.dstu2.resource.OperationDefinition.Parameter;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.*;
|
||||
import ca.uhn.fhir.model.primitive.DateTimeDt;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
import ca.uhn.fhir.rest.annotation.*;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.RestSearchParameterTypeEnum;
|
||||
import ca.uhn.fhir.rest.server.*;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import ca.uhn.fhir.rest.server.method.*;
|
||||
import ca.uhn.fhir.rest.server.method.OperationMethodBinding.ReturnType;
|
||||
|
||||
/**
|
||||
* Server FHIR Provider which serves the conformance statement for a RESTful server implementation
|
||||
|
@ -65,25 +75,27 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
private IdentityHashMap<OperationMethodBinding, String> myOperationBindingToName;
|
||||
private HashMap<String, List<OperationMethodBinding>> myOperationNameToBindings;
|
||||
private String myPublisher = "Not provided";
|
||||
private RestulfulServerConfiguration myServerConfiguration;
|
||||
private Callable<RestulfulServerConfiguration> myServerConfiguration;
|
||||
|
||||
public ServerConformanceProvider(RestfulServer theRestfulServer) {
|
||||
this.myServerConfiguration = theRestfulServer.createConfiguration();
|
||||
}
|
||||
|
||||
public ServerConformanceProvider(RestulfulServerConfiguration theServerConfiguration) {
|
||||
this.myServerConfiguration = theServerConfiguration;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add a no-arg constructor and seetter so that the ServerConfirmanceProvider can be Spring-wired with the RestfulService avoiding the potential reference cycle that would happen.
|
||||
/**
|
||||
* No-arg constructor and seetter so that the ServerConfirmanceProvider can be Spring-wired with the RestfulService avoiding the potential reference cycle that would happen.
|
||||
*/
|
||||
public ServerConformanceProvider() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void setRestfulServer(RestfulServer theRestfulServer) {
|
||||
myServerConfiguration = theRestfulServer.createConfiguration();
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public ServerConformanceProvider(RestfulServer theRestfulServer) {
|
||||
this.myServerConfiguration = theRestfulServer::createConfiguration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public ServerConformanceProvider(RestulfulServerConfiguration theServerConfiguration) {
|
||||
this.myServerConfiguration = () -> theServerConfiguration;
|
||||
}
|
||||
|
||||
private void checkBindingForSystemOps(Rest rest, Set<SystemRestfulInteractionEnum> systemOps, BaseMethodBinding<?> nextMethodBinding) {
|
||||
|
@ -104,7 +116,7 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
|
||||
private Map<String, List<BaseMethodBinding<?>>> collectMethodBindings() {
|
||||
Map<String, List<BaseMethodBinding<?>>> resourceToMethods = new TreeMap<String, List<BaseMethodBinding<?>>>();
|
||||
for (ResourceBinding next : myServerConfiguration.getResourceBindings()) {
|
||||
for (ResourceBinding next : getServerConfiguration().getResourceBindings()) {
|
||||
String resourceName = next.getResourceName();
|
||||
for (BaseMethodBinding<?> nextMethodBinding : next.getMethodBindings()) {
|
||||
if (resourceToMethods.containsKey(resourceName) == false) {
|
||||
|
@ -113,7 +125,7 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
resourceToMethods.get(resourceName).add(nextMethodBinding);
|
||||
}
|
||||
}
|
||||
for (BaseMethodBinding<?> nextMethodBinding : myServerConfiguration.getServerBindings()) {
|
||||
for (BaseMethodBinding<?> nextMethodBinding : getServerConfiguration().getServerBindings()) {
|
||||
String resourceName = "";
|
||||
if (resourceToMethods.containsKey(resourceName) == false) {
|
||||
resourceToMethods.put(resourceName, new ArrayList<BaseMethodBinding<?>>());
|
||||
|
@ -123,6 +135,18 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
return resourceToMethods;
|
||||
}
|
||||
|
||||
private DateTimeDt conformanceDate() {
|
||||
String buildDate = getServerConfiguration().getConformanceDate();
|
||||
if (buildDate != null) {
|
||||
try {
|
||||
return new DateTimeDt(buildDate);
|
||||
} catch (DataFormatException e) {
|
||||
// fall through
|
||||
}
|
||||
}
|
||||
return DateTimeDt.withCurrentTime();
|
||||
}
|
||||
|
||||
private String createOperationName(OperationMethodBinding theMethodBinding) {
|
||||
StringBuilder retVal = new StringBuilder();
|
||||
if (theMethodBinding.getResourceName() != null) {
|
||||
|
@ -152,6 +176,22 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
return myPublisher;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the "publisher" that will be placed in the generated conformance statement. As this is a mandatory element, the value should not be null (although this is not enforced). The
|
||||
* value defaults to "Not provided" but may be set to null, which will cause this element to be omitted.
|
||||
*/
|
||||
public void setPublisher(String thePublisher) {
|
||||
myPublisher = thePublisher;
|
||||
}
|
||||
|
||||
RestulfulServerConfiguration getServerConfiguration() {
|
||||
try {
|
||||
return myServerConfiguration.call();
|
||||
} catch (Exception e) {
|
||||
throw new InternalErrorException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Metadata
|
||||
public Conformance getServerConformance(HttpServletRequest theRequest) {
|
||||
|
@ -167,33 +207,37 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
retVal.setAcceptUnknown(UnknownContentCodeEnum.UNKNOWN_EXTENSIONS); // TODO: make this configurable - this is a fairly big effort since the parser
|
||||
// needs to be modified to actually allow it
|
||||
|
||||
retVal.getImplementation().setDescription(myServerConfiguration.getImplementationDescription());
|
||||
ServletContext servletContext = (ServletContext) (theRequest == null ? null : theRequest.getAttribute(RestfulServer.SERVLET_CONTEXT_ATTRIBUTE));
|
||||
String serverBase = getServerConfiguration().getServerAddressStrategy().determineServerBase(servletContext, theRequest);
|
||||
retVal
|
||||
.getImplementation()
|
||||
.setUrl(serverBase)
|
||||
.setDescription(getServerConfiguration().getImplementationDescription());
|
||||
|
||||
retVal.setKind(ConformanceStatementKindEnum.INSTANCE);
|
||||
retVal.getSoftware().setName(myServerConfiguration.getServerName());
|
||||
retVal.getSoftware().setVersion(myServerConfiguration.getServerVersion());
|
||||
retVal.getSoftware().setName(getServerConfiguration().getServerName());
|
||||
retVal.getSoftware().setVersion(getServerConfiguration().getServerVersion());
|
||||
retVal.addFormat(Constants.CT_FHIR_XML);
|
||||
retVal.addFormat(Constants.CT_FHIR_JSON);
|
||||
|
||||
Rest rest = retVal.addRest();
|
||||
rest.setMode(RestfulConformanceModeEnum.SERVER);
|
||||
|
||||
Set<SystemRestfulInteractionEnum> systemOps = new HashSet<SystemRestfulInteractionEnum>();
|
||||
Set<String> operationNames = new HashSet<String>();
|
||||
Set<SystemRestfulInteractionEnum> systemOps = new HashSet<>();
|
||||
Set<String> operationNames = new HashSet<>();
|
||||
|
||||
Map<String, List<BaseMethodBinding<?>>> resourceToMethods = collectMethodBindings();
|
||||
for (Entry<String, List<BaseMethodBinding<?>>> nextEntry : resourceToMethods.entrySet()) {
|
||||
|
||||
if (nextEntry.getKey().isEmpty() == false) {
|
||||
Set<TypeRestfulInteractionEnum> resourceOps = new HashSet<TypeRestfulInteractionEnum>();
|
||||
Set<TypeRestfulInteractionEnum> resourceOps = new HashSet<>();
|
||||
RestResource resource = rest.addResource();
|
||||
String resourceName = nextEntry.getKey();
|
||||
RuntimeResourceDefinition def = myServerConfiguration.getFhirContext().getResourceDefinition(resourceName);
|
||||
RuntimeResourceDefinition def = getServerConfiguration().getFhirContext().getResourceDefinition(resourceName);
|
||||
resource.getTypeElement().setValue(def.getName());
|
||||
ServletContext servletContext = (ServletContext) (theRequest == null ? null : theRequest.getAttribute(RestfulServer.SERVLET_CONTEXT_ATTRIBUTE));
|
||||
String serverBase = myServerConfiguration.getServerAddressStrategy().determineServerBase(servletContext, theRequest);
|
||||
resource.getProfile().setReference(new IdDt(def.getResourceProfile(serverBase)));
|
||||
|
||||
TreeSet<String> includes = new TreeSet<String>();
|
||||
TreeSet<String> includes = new TreeSet<>();
|
||||
|
||||
// Map<String, Conformance.RestResourceSearchParam> nameToSearchParam = new HashMap<String,
|
||||
// Conformance.RestResourceSearchParam>();
|
||||
|
@ -295,18 +339,6 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
return retVal;
|
||||
}
|
||||
|
||||
private DateTimeDt conformanceDate() {
|
||||
String buildDate = myServerConfiguration.getConformanceDate();
|
||||
if (buildDate != null) {
|
||||
try {
|
||||
return new DateTimeDt(buildDate);
|
||||
} catch (DataFormatException e) {
|
||||
// fall through
|
||||
}
|
||||
}
|
||||
return DateTimeDt.withCurrentTime();
|
||||
}
|
||||
|
||||
private void handleDynamicSearchMethodBinding(RestResource resource, RuntimeResourceDefinition def, TreeSet<String> includes, DynamicSearchMethodBinding searchMethodBinding) {
|
||||
includes.addAll(searchMethodBinding.getIncludes());
|
||||
|
||||
|
@ -420,7 +452,7 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
param.getTypeElement().setValueAsString(nextParameter.getParamType().getCode());
|
||||
}
|
||||
for (Class<? extends IBaseResource> nextTarget : nextParameter.getDeclaredTypes()) {
|
||||
RuntimeResourceDefinition targetDef = myServerConfiguration.getFhirContext().getResourceDefinition(nextTarget);
|
||||
RuntimeResourceDefinition targetDef = getServerConfiguration().getFhirContext().getResourceDefinition(nextTarget);
|
||||
if (targetDef != null) {
|
||||
ResourceTypeEnum code = ResourceTypeEnum.VALUESET_BINDER.fromCodeString(targetDef.getName());
|
||||
if (code != null) {
|
||||
|
@ -554,12 +586,9 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
myCache = theCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the "publisher" that will be placed in the generated conformance statement. As this is a mandatory element, the value should not be null (although this is not enforced). The
|
||||
* value defaults to "Not provided" but may be set to null, which will cause this element to be omitted.
|
||||
*/
|
||||
public void setPublisher(String thePublisher) {
|
||||
myPublisher = thePublisher;
|
||||
@Override
|
||||
public void setRestfulServer(RestfulServer theRestfulServer) {
|
||||
myServerConfiguration = theRestfulServer::createConfiguration;
|
||||
}
|
||||
|
||||
private void sortRuntimeSearchParameters(List<RuntimeSearchParam> searchParameters) {
|
||||
|
@ -585,4 +614,5 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,6 +21,8 @@ import org.junit.Assert;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.ArgumentMatchers;
|
||||
import org.mockito.Matchers;
|
||||
import org.mockito.internal.stubbing.answers.ThrowsException;
|
||||
import org.xmlunit.builder.DiffBuilder;
|
||||
import org.xmlunit.builder.Input;
|
||||
|
@ -2551,7 +2553,7 @@ public class XmlParserDstu2Test {
|
|||
assertThat(patient.getIdentifier().get(0).getType().getValueAsEnum(), IsEmptyCollection.empty());
|
||||
|
||||
ArgumentCaptor<String> capt = ArgumentCaptor.forClass(String.class);
|
||||
verify(errorHandler, times(1)).unknownAttribute(any(IParseLocation.class), capt.capture());
|
||||
verify(errorHandler, times(1)).unknownAttribute(ArgumentMatchers.nullable(IParseLocation.class), capt.capture());
|
||||
|
||||
assertEquals("value", capt.getValue());
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package ca.uhn.fhir.rest.client;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.ArgumentMatchers.nullable;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
@ -44,10 +45,10 @@ public class RestfulClientFactoryDstu2Test {
|
|||
when(ctx.getVersion()).thenReturn(FhirVersionEnum.DSTU2.getVersionImplementation());
|
||||
when(ctx.getRestfulClientFactory()).thenReturn(restfulClientFactory);
|
||||
|
||||
when(restfulClientFactory.getHttpClient(any(StringBuilder.class), (Map<String, List<String>>)any(Map.class), any(String.class), any(RequestTypeEnum.class), any(List.class))).thenReturn(httpClient);
|
||||
when(restfulClientFactory.getHttpClient(nullable(StringBuilder.class), (Map<String, List<String>>)nullable(Map.class), nullable(String.class), nullable(RequestTypeEnum.class), nullable(List.class))).thenReturn(httpClient);
|
||||
|
||||
IHttpRequest httpRequest = mock(IHttpRequest.class);
|
||||
when(httpClient.createGetRequest(any(FhirContext.class), any(EncodingEnum.class))).thenReturn(httpRequest);
|
||||
when(httpClient.createGetRequest(any(FhirContext.class), nullable(EncodingEnum.class))).thenReturn(httpRequest);
|
||||
|
||||
IHttpResponse httpResponse = mock(IHttpResponse.class);
|
||||
when(httpRequest.execute()).thenReturn(httpResponse);
|
||||
|
|
|
@ -110,6 +110,7 @@ public class BinaryDstu2Test {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateWrongType() throws Exception {
|
||||
Binary res = new Binary();
|
||||
res.setContent(new byte[] { 1, 2, 3, 4 });
|
||||
|
@ -122,8 +123,7 @@ public class BinaryDstu2Test {
|
|||
HttpResponse status = ourClient.execute(http);
|
||||
assertEquals(201, status.getStatusLine().getStatusCode());
|
||||
|
||||
assertEquals("text/plain", ourLast.getContentType());
|
||||
assertArrayEquals(new byte[] { 1, 2, 3, 4 }, ourLast.getContent());
|
||||
assertEquals("application/json+fhir;charset=utf-8", ourLast.getContentType().replace(" ","").toLowerCase());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.eclipse.jetty.servlet.ServletHolder;
|
|||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.*;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.api.BundleInclusionRule;
|
||||
|
@ -159,7 +160,8 @@ public class IncludeDstu2Test {
|
|||
|
||||
}
|
||||
|
||||
// @Test
|
||||
@Test
|
||||
@Ignore
|
||||
public void testMixedContainedAndNonContained() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/DiagnosticReport?_query=stitchedInclude&_pretty=true");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
|
|
|
@ -1,21 +1,31 @@
|
|||
package ca.uhn.fhir.rest.server;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.hamcrest.Matchers.stringContainsInOrder;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.dstu2.composite.IdentifierDt;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Bundle;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Bundle.Link;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||
import ca.uhn.fhir.rest.annotation.Create;
|
||||
import ca.uhn.fhir.rest.annotation.RequiredParam;
|
||||
import ca.uhn.fhir.rest.annotation.ResourceParam;
|
||||
import ca.uhn.fhir.rest.annotation.Search;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
||||
import ca.uhn.fhir.rest.param.*;
|
||||
import ca.uhn.fhir.util.PortUtil;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import com.google.common.base.Charsets;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
import org.apache.http.client.methods.*;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.methods.HttpPut;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
|
@ -26,21 +36,18 @@ import org.eclipse.jetty.server.Server;
|
|||
import org.eclipse.jetty.servlet.ServletHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.junit.*;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.dstu2.composite.IdentifierDt;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Bundle;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Bundle.Link;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||
import ca.uhn.fhir.rest.annotation.*;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
||||
import ca.uhn.fhir.rest.param.*;
|
||||
import ca.uhn.fhir.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class SearchDstu2Test {
|
||||
|
||||
|
@ -142,14 +149,14 @@ public class SearchDstu2Test {
|
|||
ourLog.info(responseContent);
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
assertThat(responseContent, PatternMatcher.pattern("id value..[0-9a-f-]+\\\""));
|
||||
assertThat(responseContent, matchesPattern(".*id value..[0-9a-f-]+\\\".*"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchBlacklist01Failing() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=searchBlacklist01&ref.black1=value");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent(), Charsets.UTF_8);
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
ourLog.info(responseContent);
|
||||
assertEquals(400, status.getStatusLine().getStatusCode());
|
||||
|
@ -159,7 +166,7 @@ public class SearchDstu2Test {
|
|||
public void testSearchBlacklist01Passing() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=searchBlacklist01&ref.white1=value");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent(), Charsets.UTF_8);
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
ourLog.info(responseContent);
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
package ca.uhn.fhir.util;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.hamcrest.Factory;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.TypeSafeMatcher;
|
||||
|
||||
/**
|
||||
* Tests if the argument is a {@link CharSequence} that matches a regular expression.
|
||||
*/
|
||||
public class PatternMatcher extends TypeSafeMatcher<CharSequence> {
|
||||
|
||||
/**
|
||||
* Creates a matcher that matches if the examined {@link CharSequence} matches the specified regular expression.
|
||||
* <p/>
|
||||
* For example:
|
||||
*
|
||||
* <pre>
|
||||
* assertThat("myStringOfNote", pattern("[0-9]+"))
|
||||
* </pre>
|
||||
*
|
||||
* @param regex
|
||||
* the regular expression that the returned matcher will use to match any examined {@link CharSequence}
|
||||
*/
|
||||
@Factory
|
||||
public static Matcher<CharSequence> pattern(String regex) {
|
||||
return pattern(Pattern.compile(regex));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a matcher that matches if the examined {@link CharSequence} matches the specified {@link Pattern}.
|
||||
* <p/>
|
||||
* For example:
|
||||
*
|
||||
* <pre>
|
||||
* assertThat("myStringOfNote", Pattern.compile("[0-9]+"))
|
||||
* </pre>
|
||||
*
|
||||
* @param pattern
|
||||
* the pattern that the returned matcher will use to match any examined {@link CharSequence}
|
||||
*/
|
||||
@Factory
|
||||
public static Matcher<CharSequence> pattern(Pattern pattern) {
|
||||
return new PatternMatcher(pattern);
|
||||
}
|
||||
|
||||
private final Pattern pattern;
|
||||
|
||||
public PatternMatcher(Pattern pattern) {
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesSafely(CharSequence item) {
|
||||
return pattern.matcher(item).find();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeMismatchSafely(CharSequence item, org.hamcrest.Description mismatchDescription) {
|
||||
mismatchDescription.appendText("was \"").appendText(String.valueOf(item)).appendText("\"");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeTo(org.hamcrest.Description description) {
|
||||
description.appendText("a string with pattern \"").appendText(String.valueOf(pattern)).appendText("\"");
|
||||
}
|
||||
}
|
|
@ -216,6 +216,8 @@
|
|||
<artifactId>thymeleaf</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Dependencies for Schematron -->
|
||||
<dependency>
|
||||
<groupId>com.helger</groupId>
|
||||
<artifactId>ph-schematron</artifactId>
|
||||
|
@ -226,6 +228,26 @@
|
|||
<artifactId>ph-commons</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.activation</groupId>
|
||||
<artifactId>javax.activation-api</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-impl</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- UNIT TEST DEPENDENCIES -->
|
||||
|
|
|
@ -1,6 +1,42 @@
|
|||
package org.hl7.fhir.dstu3.hapi.rest.server;
|
||||
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||
import ca.uhn.fhir.context.RuntimeSearchParam;
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
import ca.uhn.fhir.rest.annotation.Initialize;
|
||||
import ca.uhn.fhir.rest.annotation.Metadata;
|
||||
import ca.uhn.fhir.rest.annotation.Read;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.IServerConformanceProvider;
|
||||
import ca.uhn.fhir.rest.server.ResourceBinding;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
import ca.uhn.fhir.rest.server.RestulfulServerConfiguration;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import ca.uhn.fhir.rest.server.method.*;
|
||||
import ca.uhn.fhir.rest.server.method.OperationMethodBinding.ReturnType;
|
||||
import ca.uhn.fhir.rest.server.method.SearchParameter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.dstu3.model.*;
|
||||
import org.hl7.fhir.dstu3.model.CapabilityStatement.*;
|
||||
import org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus;
|
||||
import org.hl7.fhir.dstu3.model.OperationDefinition.OperationDefinitionParameterComponent;
|
||||
import org.hl7.fhir.dstu3.model.OperationDefinition.OperationKind;
|
||||
import org.hl7.fhir.dstu3.model.OperationDefinition.OperationParameterUse;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR Structures - DSTU2 (FHIR v1.0.0)
|
||||
|
@ -20,31 +56,6 @@ import static org.apache.commons.lang3.StringUtils.isBlank;
|
|||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.dstu3.model.*;
|
||||
import org.hl7.fhir.dstu3.model.CapabilityStatement.*;
|
||||
import org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus;
|
||||
import org.hl7.fhir.dstu3.model.OperationDefinition.*;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.*;
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
import ca.uhn.fhir.rest.annotation.*;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.*;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import ca.uhn.fhir.rest.server.method.*;
|
||||
import ca.uhn.fhir.rest.server.method.OperationMethodBinding.ReturnType;
|
||||
import ca.uhn.fhir.rest.server.method.SearchParameter;
|
||||
|
||||
/**
|
||||
* Server FHIR Provider which serves the conformance statement for a RESTful server implementation
|
||||
|
@ -62,21 +73,27 @@ public class ServerCapabilityStatementProvider implements IServerConformanceProv
|
|||
private IdentityHashMap<OperationMethodBinding, String> myOperationBindingToName;
|
||||
private HashMap<String, List<OperationMethodBinding>> myOperationNameToBindings;
|
||||
private String myPublisher = "Not provided";
|
||||
private RestulfulServerConfiguration myServerConfiguration;
|
||||
private Callable<RestulfulServerConfiguration> myServerConfiguration;
|
||||
|
||||
/*
|
||||
* Add a no-arg constructor and seetter so that the ServerConfirmanceProvider can be Spring-wired with the RestfulService avoiding the potential reference cycle that would happen.
|
||||
/**
|
||||
* No-arg constructor and seetter so that the ServerConfirmanceProvider can be Spring-wired with the RestfulService avoiding the potential reference cycle that would happen.
|
||||
*/
|
||||
public ServerCapabilityStatementProvider() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public ServerCapabilityStatementProvider(RestfulServer theRestfulServer) {
|
||||
this.myServerConfiguration = theRestfulServer.createConfiguration();
|
||||
this.myServerConfiguration = theRestfulServer::createConfiguration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public ServerCapabilityStatementProvider(RestulfulServerConfiguration theServerConfiguration) {
|
||||
this.myServerConfiguration = theServerConfiguration;
|
||||
this.myServerConfiguration = () -> theServerConfiguration;
|
||||
}
|
||||
|
||||
private void checkBindingForSystemOps(CapabilityStatementRestComponent rest, Set<SystemRestfulInteraction> systemOps, BaseMethodBinding<?> nextMethodBinding) {
|
||||
|
@ -102,7 +119,7 @@ public class ServerCapabilityStatementProvider implements IServerConformanceProv
|
|||
|
||||
private Map<String, List<BaseMethodBinding<?>>> collectMethodBindings() {
|
||||
Map<String, List<BaseMethodBinding<?>>> resourceToMethods = new TreeMap<String, List<BaseMethodBinding<?>>>();
|
||||
for (ResourceBinding next : myServerConfiguration.getResourceBindings()) {
|
||||
for (ResourceBinding next : getServerConfiguration().getResourceBindings()) {
|
||||
String resourceName = next.getResourceName();
|
||||
for (BaseMethodBinding<?> nextMethodBinding : next.getMethodBindings()) {
|
||||
if (resourceToMethods.containsKey(resourceName) == false) {
|
||||
|
@ -111,10 +128,10 @@ public class ServerCapabilityStatementProvider implements IServerConformanceProv
|
|||
resourceToMethods.get(resourceName).add(nextMethodBinding);
|
||||
}
|
||||
}
|
||||
for (BaseMethodBinding<?> nextMethodBinding : myServerConfiguration.getServerBindings()) {
|
||||
for (BaseMethodBinding<?> nextMethodBinding : getServerConfiguration().getServerBindings()) {
|
||||
String resourceName = "";
|
||||
if (resourceToMethods.containsKey(resourceName) == false) {
|
||||
resourceToMethods.put(resourceName, new ArrayList<BaseMethodBinding<?>>());
|
||||
resourceToMethods.put(resourceName, new ArrayList<>());
|
||||
}
|
||||
resourceToMethods.get(resourceName).add(nextMethodBinding);
|
||||
}
|
||||
|
@ -122,7 +139,7 @@ public class ServerCapabilityStatementProvider implements IServerConformanceProv
|
|||
}
|
||||
|
||||
private DateTimeType conformanceDate() {
|
||||
String buildDate = myServerConfiguration.getConformanceDate();
|
||||
String buildDate = getServerConfiguration().getConformanceDate();
|
||||
if (buildDate != null) {
|
||||
try {
|
||||
return new DateTimeType(buildDate);
|
||||
|
@ -162,6 +179,22 @@ public class ServerCapabilityStatementProvider implements IServerConformanceProv
|
|||
return myPublisher;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the "publisher" that will be placed in the generated conformance statement. As this is a mandatory element, the value should not be null (although this is not enforced). The
|
||||
* value defaults to "Not provided" but may be set to null, which will cause this element to be omitted.
|
||||
*/
|
||||
public void setPublisher(String thePublisher) {
|
||||
myPublisher = thePublisher;
|
||||
}
|
||||
|
||||
RestulfulServerConfiguration getServerConfiguration() {
|
||||
try {
|
||||
return myServerConfiguration.call();
|
||||
} catch (Exception e) {
|
||||
throw new InternalErrorException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Metadata
|
||||
public CapabilityStatement getServerConformance(HttpServletRequest theRequest) {
|
||||
|
@ -178,10 +211,16 @@ public class ServerCapabilityStatementProvider implements IServerConformanceProv
|
|||
// effort since the parser
|
||||
// needs to be modified to actually allow it
|
||||
|
||||
retVal.getImplementation().setDescription(myServerConfiguration.getImplementationDescription());
|
||||
ServletContext servletContext = (ServletContext) (theRequest == null ? null : theRequest.getAttribute(RestfulServer.SERVLET_CONTEXT_ATTRIBUTE));
|
||||
String serverBase = getServerConfiguration().getServerAddressStrategy().determineServerBase(servletContext, theRequest);
|
||||
retVal
|
||||
.getImplementation()
|
||||
.setUrl(serverBase)
|
||||
.setDescription(getServerConfiguration().getImplementationDescription());
|
||||
|
||||
retVal.setKind(CapabilityStatementKind.INSTANCE);
|
||||
retVal.getSoftware().setName(myServerConfiguration.getServerName());
|
||||
retVal.getSoftware().setVersion(myServerConfiguration.getServerVersion());
|
||||
retVal.getSoftware().setName(getServerConfiguration().getServerName());
|
||||
retVal.getSoftware().setVersion(getServerConfiguration().getServerVersion());
|
||||
retVal.addFormat(Constants.CT_FHIR_XML_NEW);
|
||||
retVal.addFormat(Constants.CT_FHIR_JSON_NEW);
|
||||
retVal.setStatus(PublicationStatus.ACTIVE);
|
||||
|
@ -189,23 +228,21 @@ public class ServerCapabilityStatementProvider implements IServerConformanceProv
|
|||
CapabilityStatementRestComponent rest = retVal.addRest();
|
||||
rest.setMode(RestfulCapabilityMode.SERVER);
|
||||
|
||||
Set<SystemRestfulInteraction> systemOps = new HashSet<SystemRestfulInteraction>();
|
||||
Set<String> operationNames = new HashSet<String>();
|
||||
Set<SystemRestfulInteraction> systemOps = new HashSet<>();
|
||||
Set<String> operationNames = new HashSet<>();
|
||||
|
||||
Map<String, List<BaseMethodBinding<?>>> resourceToMethods = collectMethodBindings();
|
||||
for (Entry<String, List<BaseMethodBinding<?>>> nextEntry : resourceToMethods.entrySet()) {
|
||||
|
||||
if (nextEntry.getKey().isEmpty() == false) {
|
||||
Set<TypeRestfulInteraction> resourceOps = new HashSet<TypeRestfulInteraction>();
|
||||
Set<TypeRestfulInteraction> resourceOps = new HashSet<>();
|
||||
CapabilityStatementRestResourceComponent resource = rest.addResource();
|
||||
String resourceName = nextEntry.getKey();
|
||||
RuntimeResourceDefinition def = myServerConfiguration.getFhirContext().getResourceDefinition(resourceName);
|
||||
RuntimeResourceDefinition def = getServerConfiguration().getFhirContext().getResourceDefinition(resourceName);
|
||||
resource.getTypeElement().setValue(def.getName());
|
||||
ServletContext servletContext = (ServletContext) (theRequest == null ? null : theRequest.getAttribute(RestfulServer.SERVLET_CONTEXT_ATTRIBUTE));
|
||||
String serverBase = myServerConfiguration.getServerAddressStrategy().determineServerBase(servletContext, theRequest);
|
||||
resource.getProfile().setReference((def.getResourceProfile(serverBase)));
|
||||
|
||||
TreeSet<String> includes = new TreeSet<String>();
|
||||
TreeSet<String> includes = new TreeSet<>();
|
||||
|
||||
// Map<String, CapabilityStatement.RestResourceSearchParam> nameToSearchParam = new HashMap<String,
|
||||
// CapabilityStatement.RestResourceSearchParam>();
|
||||
|
@ -271,7 +308,7 @@ public class ServerCapabilityStatementProvider implements IServerConformanceProv
|
|||
}
|
||||
}
|
||||
|
||||
Collections.sort(resource.getInteraction(), new Comparator<ResourceInteractionComponent>() {
|
||||
resource.getInteraction().sort(new Comparator<ResourceInteractionComponent>() {
|
||||
@Override
|
||||
public int compare(ResourceInteractionComponent theO1, ResourceInteractionComponent theO2) {
|
||||
TypeRestfulInteraction o1 = theO1.getCode();
|
||||
|
@ -316,7 +353,7 @@ public class ServerCapabilityStatementProvider implements IServerConformanceProv
|
|||
private void handleDynamicSearchMethodBinding(CapabilityStatementRestResourceComponent resource, RuntimeResourceDefinition def, TreeSet<String> includes, DynamicSearchMethodBinding searchMethodBinding) {
|
||||
includes.addAll(searchMethodBinding.getIncludes());
|
||||
|
||||
List<RuntimeSearchParam> searchParameters = new ArrayList<RuntimeSearchParam>();
|
||||
List<RuntimeSearchParam> searchParameters = new ArrayList<>();
|
||||
searchParameters.addAll(searchMethodBinding.getSearchParams());
|
||||
sortRuntimeSearchParameters(searchParameters);
|
||||
|
||||
|
@ -427,7 +464,7 @@ public class ServerCapabilityStatementProvider implements IServerConformanceProv
|
|||
param.getTypeElement().setValueAsString(nextParameter.getParamType().getCode());
|
||||
}
|
||||
for (Class<? extends IBaseResource> nextTarget : nextParameter.getDeclaredTypes()) {
|
||||
RuntimeResourceDefinition targetDef = myServerConfiguration.getFhirContext().getResourceDefinition(nextTarget);
|
||||
RuntimeResourceDefinition targetDef = getServerConfiguration().getFhirContext().getResourceDefinition(nextTarget);
|
||||
if (targetDef != null) {
|
||||
ResourceType code;
|
||||
try {
|
||||
|
@ -581,25 +618,14 @@ public class ServerCapabilityStatementProvider implements IServerConformanceProv
|
|||
* See the class documentation for an important note if you are extending this class
|
||||
* </p>
|
||||
*/
|
||||
public void setCache(boolean theCache) {
|
||||
public ServerCapabilityStatementProvider setCache(boolean theCache) {
|
||||
myCache = theCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the "publisher" that will be placed in the generated conformance statement. As this is a mandatory element, the value should not be null (although this is not enforced). The
|
||||
* value defaults to "Not provided" but may be set to null, which will cause this element to be omitted.
|
||||
*/
|
||||
public void setPublisher(String thePublisher) {
|
||||
myPublisher = thePublisher;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRestfulServer(RestfulServer theRestfulServer) {
|
||||
myServerConfiguration = theRestfulServer.createConfiguration();
|
||||
}
|
||||
|
||||
RestulfulServerConfiguration getServerConfiguration() {
|
||||
return myServerConfiguration;
|
||||
myServerConfiguration = theRestfulServer::createConfiguration;
|
||||
}
|
||||
|
||||
private void sortRuntimeSearchParameters(List<RuntimeSearchParam> searchParameters) {
|
||||
|
|
|
@ -1361,7 +1361,7 @@ public class JsonParserDstu3Test {
|
|||
ArgumentCaptor<ValueType> expected = ArgumentCaptor.forClass(ValueType.class);
|
||||
ArgumentCaptor<ScalarType> expectedScalarType = ArgumentCaptor.forClass(ScalarType.class);
|
||||
ArgumentCaptor<ScalarType> foundScalarType = ArgumentCaptor.forClass(ScalarType.class);
|
||||
verify(errorHandler, times(2)).incorrectJsonType(any(IParseLocation.class), elementName.capture(), expected.capture(), expectedScalarType.capture(), found.capture(), foundScalarType.capture());
|
||||
verify(errorHandler, times(2)).incorrectJsonType(nullable(IParseLocation.class), elementName.capture(), expected.capture(), expectedScalarType.capture(), found.capture(), foundScalarType.capture());
|
||||
|
||||
assertEquals(ValueType.SCALAR, found.getAllValues().get(0));
|
||||
assertEquals(ValueType.SCALAR, expected.getAllValues().get(0));
|
||||
|
@ -2344,13 +2344,13 @@ public class JsonParserDstu3Test {
|
|||
ArgumentCaptor<ValueType> actual = ArgumentCaptor.forClass(ValueType.class);
|
||||
ArgumentCaptor<ScalarType> expectedScalar = ArgumentCaptor.forClass(ScalarType.class);
|
||||
ArgumentCaptor<ScalarType> actualScalar = ArgumentCaptor.forClass(ScalarType.class);
|
||||
verify(errorHandler, atLeastOnce()).incorrectJsonType(Mockito.any(IParseLocation.class), elementName.capture(), expected.capture(), expectedScalar.capture(), actual.capture(),
|
||||
verify(errorHandler, atLeastOnce()).incorrectJsonType(Mockito.nullable(IParseLocation.class), elementName.capture(), expected.capture(), expectedScalar.capture(), actual.capture(),
|
||||
actualScalar.capture());
|
||||
verify(errorHandler, atLeastOnce()).incorrectJsonType(Mockito.any(IParseLocation.class), Mockito.eq("_id"), Mockito.eq(ValueType.OBJECT), expectedScalar.capture(), Mockito.eq(ValueType.SCALAR),
|
||||
verify(errorHandler, atLeastOnce()).incorrectJsonType(Mockito.nullable(IParseLocation.class), Mockito.eq("_id"), Mockito.eq(ValueType.OBJECT), expectedScalar.capture(), Mockito.eq(ValueType.SCALAR),
|
||||
actualScalar.capture());
|
||||
verify(errorHandler, atLeastOnce()).incorrectJsonType(Mockito.any(IParseLocation.class), Mockito.eq("__v"), Mockito.eq(ValueType.OBJECT), expectedScalar.capture(), Mockito.eq(ValueType.SCALAR),
|
||||
verify(errorHandler, atLeastOnce()).incorrectJsonType(Mockito.nullable(IParseLocation.class), Mockito.eq("__v"), Mockito.eq(ValueType.OBJECT), expectedScalar.capture(), Mockito.eq(ValueType.SCALAR),
|
||||
actualScalar.capture());
|
||||
verify(errorHandler, atLeastOnce()).incorrectJsonType(Mockito.any(IParseLocation.class), Mockito.eq("_status"), Mockito.eq(ValueType.OBJECT), expectedScalar.capture(),
|
||||
verify(errorHandler, atLeastOnce()).incorrectJsonType(Mockito.nullable(IParseLocation.class), Mockito.eq("_status"), Mockito.eq(ValueType.OBJECT), expectedScalar.capture(),
|
||||
Mockito.eq(ValueType.SCALAR), actualScalar.capture());
|
||||
|
||||
assertEquals("_id", elementName.getAllValues().get(0));
|
||||
|
|
|
@ -1,97 +0,0 @@
|
|||
package ca.uhn.fhir.parser;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
import javax.xml.stream.*;
|
||||
import javax.xml.stream.events.XMLEvent;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import ca.uhn.fhir.util.XmlUtil;
|
||||
|
||||
public class RoundTripDstu3Test {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(RoundTripDstu3Test.class);
|
||||
private static FhirContext ourCtx = FhirContext.forDstu3();
|
||||
|
||||
@Test
|
||||
public void testIt() {
|
||||
// Just so this doesn't complain until we enable roundtrip test
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
// @Test
|
||||
public void testRoundTrip() throws Exception {
|
||||
ZipInputStream is = new ZipInputStream(new FileInputStream("src/test/resources/examples.zip"));
|
||||
try {
|
||||
while (true) {
|
||||
ZipEntry nextEntry = is.getNextEntry();
|
||||
if (nextEntry == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
ByteArrayOutputStream oos = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[2048];
|
||||
int len = 0;
|
||||
while ((len = is.read(buffer)) > 0) {
|
||||
oos.write(buffer, 0, len);
|
||||
}
|
||||
|
||||
String exampleText = oos.toString("UTF-8");
|
||||
ourLog.info("Next file: {} - Size: {} bytes", nextEntry.getName(), exampleText.length());
|
||||
if (!nextEntry.getName().contains("diagnosticreport-examples-lab")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
IBaseResource parsed = ourCtx.newXmlParser().parseResource(exampleText);
|
||||
String encodedXml = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(parsed);
|
||||
|
||||
exampleText = cleanXml(exampleText);
|
||||
encodedXml = cleanXml(encodedXml);
|
||||
|
||||
XmlParserDstu3Test.compareXml(exampleText, encodedXml);
|
||||
// DetailedDiff d = new DetailedDiff(new Diff(new StringReader(exampleText), new StringReader(encodedXml)));
|
||||
//
|
||||
// boolean similar = d.similar();
|
||||
// if (!similar) {
|
||||
// exampleText = exampleText.replace(" xmlns=\"http://hl7.org/fhir\"", "");
|
||||
// encodedXml = encodedXml.replace(" xmlns=\"http://hl7.org/fhir\"", "");
|
||||
// if (exampleText.length() != encodedXml.length()) {
|
||||
// assertTrue(d.toString(), similar);
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
} finally {
|
||||
is.close();
|
||||
}
|
||||
}
|
||||
|
||||
private String cleanXml(String exampleText) throws Error, Exception {
|
||||
XMLEventReader read = XmlUtil.createXmlReader(new StringReader(exampleText));
|
||||
StringWriter sw = new StringWriter();
|
||||
XMLEventWriter write = XmlUtil.createXmlWriter(sw);
|
||||
while (read.hasNext()) {
|
||||
XMLEvent nextEvent = read.nextEvent();
|
||||
if (nextEvent.getEventType() == XMLStreamConstants.COMMENT) {
|
||||
continue;
|
||||
}
|
||||
write.add(nextEvent);
|
||||
}
|
||||
write.add(read);
|
||||
sw.close();
|
||||
return sw.toString().replaceAll("<!--.*-->", "").replace("\n", " ").replace("\r", " ").replaceAll(">\\s+<", "><").replaceAll("<\\?.*\\?>", "").replaceAll("\\s+", " ");
|
||||
}
|
||||
|
||||
}
|
|
@ -2960,7 +2960,7 @@ public class XmlParserDstu3Test {
|
|||
assertThat(patient.getIdentifier().get(0).getType().getCoding(), IsEmptyCollection.empty());
|
||||
|
||||
ArgumentCaptor<String> capt = ArgumentCaptor.forClass(String.class);
|
||||
verify(errorHandler, times(1)).unknownAttribute(any(IParseLocation.class), capt.capture());
|
||||
verify(errorHandler, times(1)).unknownAttribute(nullable(IParseLocation.class), capt.capture());
|
||||
|
||||
assertEquals("value", capt.getValue());
|
||||
}
|
||||
|
|
|
@ -496,7 +496,7 @@ public class GenericClientDstu3Test {
|
|||
when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
|
||||
when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
|
||||
when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||
when(myHttpResponse.getEntity().getContent()).thenThrow(IllegalStateException.class, RuntimeException.class, Exception.class);
|
||||
when(myHttpResponse.getEntity().getContent()).thenThrow(IllegalStateException.class, RuntimeException.class, IOException.class);
|
||||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://example.com/fhir");
|
||||
|
||||
|
@ -518,7 +518,7 @@ public class GenericClientDstu3Test {
|
|||
client.read().resource(Patient.class).withId("1").execute();
|
||||
fail();
|
||||
} catch (FhirClientConnectionException e) {
|
||||
assertEquals("java.lang.Exception", e.getMessage());
|
||||
assertThat(e.getMessage(), containsString("java.io.IOException"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package ca.uhn.fhir.rest.server;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.rest.annotation.*;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
|
@ -32,7 +31,6 @@ import org.eclipse.jetty.servlet.ServletHolder;
|
|||
import org.hl7.fhir.dstu3.model.IdType;
|
||||
import org.hl7.fhir.dstu3.model.OperationOutcome;
|
||||
import org.hl7.fhir.dstu3.model.Patient;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.junit.*;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.InOrder;
|
||||
|
@ -45,7 +43,6 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
public class InterceptorDstu3Test {
|
||||
|
@ -117,14 +114,14 @@ public class InterceptorDstu3Test {
|
|||
public void testResourceResponseIncluded() throws Exception {
|
||||
ourServlet.setInterceptors(myInterceptor1, myInterceptor2);
|
||||
|
||||
when(myInterceptor1.incomingRequestPreProcessed(any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
|
||||
when(myInterceptor1.incomingRequestPostProcessed(any(RequestDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
|
||||
when(myInterceptor1.outgoingResponse(any(RequestDetails.class), any(IResource.class))).thenReturn(true);
|
||||
when(myInterceptor1.outgoingResponse(any(RequestDetails.class), any(ResponseDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
|
||||
when(myInterceptor2.incomingRequestPreProcessed(any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
|
||||
when(myInterceptor2.incomingRequestPostProcessed(any(RequestDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
|
||||
when(myInterceptor2.outgoingResponse(any(RequestDetails.class), any(IResource.class))).thenReturn(true);
|
||||
when(myInterceptor2.outgoingResponse(any(RequestDetails.class), any(ResponseDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
|
||||
when(myInterceptor1.incomingRequestPreProcessed(nullable(HttpServletRequest.class), nullable(HttpServletResponse.class))).thenReturn(true);
|
||||
when(myInterceptor1.incomingRequestPostProcessed(nullable(ServletRequestDetails.class), nullable(HttpServletRequest.class), nullable(HttpServletResponse.class))).thenReturn(true);
|
||||
when(myInterceptor1.outgoingResponse(nullable(ServletRequestDetails.class), nullable(OperationOutcome.class))).thenReturn(true);
|
||||
when(myInterceptor1.outgoingResponse(nullable(ServletRequestDetails.class), nullable(ResponseDetails.class), nullable(HttpServletRequest.class), nullable(HttpServletResponse.class))).thenReturn(true);
|
||||
when(myInterceptor2.incomingRequestPreProcessed(nullable(HttpServletRequest.class), nullable(HttpServletResponse.class))).thenReturn(true);
|
||||
when(myInterceptor2.incomingRequestPostProcessed(nullable(ServletRequestDetails.class), nullable(HttpServletRequest.class), nullable(HttpServletResponse.class))).thenReturn(true);
|
||||
when(myInterceptor2.outgoingResponse(nullable(ServletRequestDetails.class), nullable(OperationOutcome.class))).thenReturn(true);
|
||||
when(myInterceptor2.outgoingResponse(nullable(ServletRequestDetails.class), nullable(ResponseDetails.class), nullable(HttpServletRequest.class), nullable(HttpServletResponse.class))).thenReturn(true);
|
||||
|
||||
String input = createInput();
|
||||
|
||||
|
@ -134,24 +131,24 @@ public class InterceptorDstu3Test {
|
|||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
InOrder order = inOrder(myInterceptor1, myInterceptor2);
|
||||
order.verify(myInterceptor1, times(1)).incomingRequestPreProcessed(any(HttpServletRequest.class), any(HttpServletResponse.class));
|
||||
order.verify(myInterceptor2, times(1)).incomingRequestPreProcessed(any(HttpServletRequest.class), any(HttpServletResponse.class));
|
||||
order.verify(myInterceptor1, times(1)).incomingRequestPostProcessed(any(RequestDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class));
|
||||
order.verify(myInterceptor2, times(1)).incomingRequestPostProcessed(any(RequestDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class));
|
||||
order.verify(myInterceptor1, times(1)).incomingRequestPreProcessed(nullable(HttpServletRequest.class), nullable(HttpServletResponse.class));
|
||||
order.verify(myInterceptor2, times(1)).incomingRequestPreProcessed(nullable(HttpServletRequest.class), nullable(HttpServletResponse.class));
|
||||
order.verify(myInterceptor1, times(1)).incomingRequestPostProcessed(nullable(ServletRequestDetails.class), nullable(HttpServletRequest.class), nullable(HttpServletResponse.class));
|
||||
order.verify(myInterceptor2, times(1)).incomingRequestPostProcessed(nullable(ServletRequestDetails.class), nullable(HttpServletRequest.class), nullable(HttpServletResponse.class));
|
||||
ArgumentCaptor<RestOperationTypeEnum> opTypeCapt = ArgumentCaptor.forClass(RestOperationTypeEnum.class);
|
||||
ArgumentCaptor<ActionRequestDetails> arTypeCapt = ArgumentCaptor.forClass(ActionRequestDetails.class);
|
||||
order.verify(myInterceptor1, times(1)).incomingRequestPreHandled(opTypeCapt.capture(), arTypeCapt.capture());
|
||||
order.verify(myInterceptor2, times(1)).incomingRequestPreHandled(any(RestOperationTypeEnum.class), any(ActionRequestDetails.class));
|
||||
order.verify(myInterceptor2, times(1)).outgoingResponse(any(RequestDetails.class), any(IBaseResource.class));
|
||||
order.verify(myInterceptor2, times(1)).outgoingResponse(any(RequestDetails.class), any(ResponseDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class));
|
||||
order.verify(myInterceptor1, times(1)).outgoingResponse(any(RequestDetails.class), any(IBaseResource.class));
|
||||
order.verify(myInterceptor1, times(1)).outgoingResponse(any(RequestDetails.class), any(ResponseDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class));
|
||||
order.verify(myInterceptor2, times(1)).incomingRequestPreHandled(nullable(RestOperationTypeEnum.class), nullable(ActionRequestDetails.class));
|
||||
order.verify(myInterceptor2, times(1)).outgoingResponse(nullable(ServletRequestDetails.class), nullable(OperationOutcome.class));
|
||||
order.verify(myInterceptor2, times(1)).outgoingResponse(nullable(ServletRequestDetails.class), nullable(ResponseDetails.class), nullable(HttpServletRequest.class), nullable(HttpServletResponse.class));
|
||||
order.verify(myInterceptor1, times(1)).outgoingResponse(nullable(ServletRequestDetails.class), nullable(OperationOutcome.class));
|
||||
order.verify(myInterceptor1, times(1)).outgoingResponse(nullable(ServletRequestDetails.class), nullable(ResponseDetails.class), nullable(HttpServletRequest.class), nullable(HttpServletResponse.class));
|
||||
|
||||
// Avoid concurrency issues
|
||||
Thread.sleep(500);
|
||||
|
||||
order.verify(myInterceptor2, times(1)).processingCompletedNormally(any(ServletRequestDetails.class));
|
||||
order.verify(myInterceptor1, times(1)).processingCompletedNormally(any(ServletRequestDetails.class));
|
||||
order.verify(myInterceptor2, times(1)).processingCompletedNormally(nullable(ServletRequestDetails.class));
|
||||
order.verify(myInterceptor1, times(1)).processingCompletedNormally(nullable(ServletRequestDetails.class));
|
||||
verifyNoMoreInteractions(myInterceptor1);
|
||||
verifyNoMoreInteractions(myInterceptor2);
|
||||
|
||||
|
@ -163,10 +160,10 @@ public class InterceptorDstu3Test {
|
|||
public void testResponseWithNothing() throws Exception {
|
||||
ourServlet.setInterceptors(myInterceptor1);
|
||||
|
||||
when(myInterceptor1.incomingRequestPreProcessed(any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
|
||||
when(myInterceptor1.incomingRequestPostProcessed(any(RequestDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
|
||||
when(myInterceptor1.outgoingResponse(any(RequestDetails.class), any(IResource.class))).thenReturn(true);
|
||||
when(myInterceptor1.outgoingResponse(any(RequestDetails.class), any(ResponseDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
|
||||
when(myInterceptor1.incomingRequestPreProcessed(nullable(HttpServletRequest.class), nullable(HttpServletResponse.class))).thenReturn(true);
|
||||
when(myInterceptor1.incomingRequestPostProcessed(nullable(ServletRequestDetails.class), nullable(HttpServletRequest.class), nullable(HttpServletResponse.class))).thenReturn(true);
|
||||
when(myInterceptor1.outgoingResponse(nullable(ServletRequestDetails.class), nullable(OperationOutcome.class))).thenReturn(true);
|
||||
when(myInterceptor1.outgoingResponse(nullable(ServletRequestDetails.class), nullable(ResponseDetails.class), nullable(HttpServletRequest.class), nullable(HttpServletResponse.class))).thenReturn(true);
|
||||
|
||||
String input = createInput();
|
||||
|
||||
|
@ -180,14 +177,14 @@ public class InterceptorDstu3Test {
|
|||
}
|
||||
|
||||
InOrder order = inOrder(myInterceptor1);
|
||||
verify(myInterceptor1, times(1)).incomingRequestPreProcessed(any(HttpServletRequest.class), any(HttpServletResponse.class));
|
||||
verify(myInterceptor1, times(1)).incomingRequestPostProcessed(any(RequestDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class));
|
||||
verify(myInterceptor1, times(1)).incomingRequestPreProcessed(nullable(HttpServletRequest.class), nullable(HttpServletResponse.class));
|
||||
verify(myInterceptor1, times(1)).incomingRequestPostProcessed(nullable(ServletRequestDetails.class), nullable(HttpServletRequest.class), nullable(HttpServletResponse.class));
|
||||
ArgumentCaptor<RestOperationTypeEnum> opTypeCapt = ArgumentCaptor.forClass(RestOperationTypeEnum.class);
|
||||
ArgumentCaptor<ActionRequestDetails> arTypeCapt = ArgumentCaptor.forClass(ActionRequestDetails.class);
|
||||
ArgumentCaptor<RequestDetails> rdCapt = ArgumentCaptor.forClass(RequestDetails.class);
|
||||
ArgumentCaptor<IBaseResource> resourceCapt = ArgumentCaptor.forClass(IBaseResource.class);
|
||||
ArgumentCaptor<ServletRequestDetails> rdCapt = ArgumentCaptor.forClass(ServletRequestDetails.class);
|
||||
ArgumentCaptor<OperationOutcome> resourceCapt = ArgumentCaptor.forClass(OperationOutcome.class);
|
||||
verify(myInterceptor1, times(1)).incomingRequestPreHandled(opTypeCapt.capture(), arTypeCapt.capture());
|
||||
verify(myInterceptor1, times(1)).outgoingResponse(any(RequestDetails.class), resourceCapt.capture());
|
||||
verify(myInterceptor1, times(1)).outgoingResponse(nullable(ServletRequestDetails.class), resourceCapt.capture());
|
||||
|
||||
assertEquals(1, resourceCapt.getAllValues().size());
|
||||
assertEquals(null, resourceCapt.getAllValues().get(0));
|
||||
|
@ -198,9 +195,9 @@ public class InterceptorDstu3Test {
|
|||
public void testResponseWithOperationOutcome() throws Exception {
|
||||
ourServlet.setInterceptors(myInterceptor1);
|
||||
|
||||
when(myInterceptor1.incomingRequestPreProcessed(any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
|
||||
when(myInterceptor1.incomingRequestPostProcessed(any(RequestDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
|
||||
when(myInterceptor1.outgoingResponse(any(RequestDetails.class), any(IResource.class))).thenReturn(true);
|
||||
when(myInterceptor1.incomingRequestPreProcessed(nullable(HttpServletRequest.class), nullable(HttpServletResponse.class))).thenReturn(true);
|
||||
when(myInterceptor1.incomingRequestPostProcessed(nullable(ServletRequestDetails.class), nullable(HttpServletRequest.class), nullable(HttpServletResponse.class))).thenReturn(true);
|
||||
when(myInterceptor1.outgoingResponse(nullable(ServletRequestDetails.class), nullable(OperationOutcome.class))).thenReturn(true);
|
||||
|
||||
String input = createInput();
|
||||
|
||||
|
@ -210,13 +207,13 @@ public class InterceptorDstu3Test {
|
|||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
InOrder order = inOrder(myInterceptor1);
|
||||
order.verify(myInterceptor1, times(1)).incomingRequestPreProcessed(any(HttpServletRequest.class), any(HttpServletResponse.class));
|
||||
order.verify(myInterceptor1, times(1)).incomingRequestPostProcessed(any(RequestDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class));
|
||||
order.verify(myInterceptor1, times(1)).incomingRequestPreProcessed(nullable(HttpServletRequest.class), nullable(HttpServletResponse.class));
|
||||
order.verify(myInterceptor1, times(1)).incomingRequestPostProcessed(nullable(ServletRequestDetails.class), nullable(HttpServletRequest.class), nullable(HttpServletResponse.class));
|
||||
ArgumentCaptor<RestOperationTypeEnum> opTypeCapt = ArgumentCaptor.forClass(RestOperationTypeEnum.class);
|
||||
ArgumentCaptor<ActionRequestDetails> arTypeCapt = ArgumentCaptor.forClass(ActionRequestDetails.class);
|
||||
ArgumentCaptor<IBaseResource> resourceCapt = ArgumentCaptor.forClass(IBaseResource.class);
|
||||
ArgumentCaptor<OperationOutcome> resourceCapt = ArgumentCaptor.forClass(OperationOutcome.class);
|
||||
order.verify(myInterceptor1, times(1)).incomingRequestPreHandled(opTypeCapt.capture(), arTypeCapt.capture());
|
||||
order.verify(myInterceptor1, times(1)).outgoingResponse(any(RequestDetails.class), resourceCapt.capture());
|
||||
order.verify(myInterceptor1, times(1)).outgoingResponse(nullable(ServletRequestDetails.class), resourceCapt.capture());
|
||||
|
||||
assertEquals(1, resourceCapt.getAllValues().size());
|
||||
assertEquals(OperationOutcome.class, resourceCapt.getAllValues().get(0).getClass());
|
||||
|
|
|
@ -1,32 +1,5 @@
|
|||
package ca.uhn.fhir.rest.server;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.Matchers.stringContainsInOrder;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.methods.HttpRequestBase;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.servlet.ServletHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.hl7.fhir.dstu3.hapi.rest.server.ServerCapabilityStatementProvider;
|
||||
import org.hl7.fhir.dstu3.model.Patient;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.rest.annotation.OptionalParam;
|
||||
|
@ -38,47 +11,44 @@ import ca.uhn.fhir.rest.param.StringParam;
|
|||
import ca.uhn.fhir.util.PortUtil;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import ca.uhn.fhir.util.VersionUtil;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.methods.HttpRequestBase;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.servlet.ServletHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.hl7.fhir.dstu3.hapi.rest.server.ServerCapabilityStatementProvider;
|
||||
import org.hl7.fhir.dstu3.model.CapabilityStatement;
|
||||
import org.hl7.fhir.dstu3.model.Patient;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class MetadataCapabilityStatementDstu3Test {
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(MetadataCapabilityStatementDstu3Test.class);
|
||||
private static CloseableHttpClient ourClient;
|
||||
private static FhirContext ourCtx = FhirContext.forDstu3();
|
||||
private static int ourPort;
|
||||
private static Server ourServer;
|
||||
private static RestfulServer ourServlet;
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(MetadataCapabilityStatementDstu3Test.class);
|
||||
|
||||
@Test
|
||||
public void testSummary() throws Exception {
|
||||
String output;
|
||||
|
||||
// With
|
||||
HttpRequestBase httpPost = new HttpGet("http://localhost:" + ourPort + "/metadata?_summary=true&_pretty=true");
|
||||
CloseableHttpResponse status = ourClient.execute(httpPost);
|
||||
try {
|
||||
output = IOUtils.toString(status.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
ourLog.info(output);
|
||||
assertThat(output, containsString("<CapabilityStatement"));
|
||||
assertThat(output, stringContainsInOrder("<meta>", "SUBSETTED", "</meta>"));
|
||||
assertThat(output, not(stringContainsInOrder("searchParam")));
|
||||
} finally {
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
}
|
||||
|
||||
// Without
|
||||
httpPost = new HttpGet("http://localhost:" + ourPort + "/metadata?_pretty=true");
|
||||
status = ourClient.execute(httpPost);
|
||||
try {
|
||||
output = IOUtils.toString(status.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
ourLog.info(output);
|
||||
assertThat(output, containsString("<CapabilityStatement"));
|
||||
assertThat(output, not(stringContainsInOrder("<meta>", "SUBSETTED", "</meta>")));
|
||||
assertThat(output, stringContainsInOrder("searchParam"));
|
||||
} finally {
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
}
|
||||
@After
|
||||
public void after() {
|
||||
ourServlet.setServerAddressStrategy(new IncomingRequestAddressStrategy());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -140,6 +110,77 @@ public class MetadataCapabilityStatementDstu3Test {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResponseContainsBaseUrl() throws Exception {
|
||||
String output;
|
||||
|
||||
HttpRequestBase httpPost = new HttpGet("http://localhost:" + ourPort + "/metadata?_format=json");
|
||||
CloseableHttpResponse status = ourClient.execute(httpPost);
|
||||
try {
|
||||
output = IOUtils.toString(status.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
ourLog.info(output);
|
||||
CapabilityStatement cs = ourCtx.newJsonParser().parseResource(CapabilityStatement.class, output);
|
||||
|
||||
assertEquals("http://localhost:" + ourPort + "/", cs.getImplementation().getUrl());
|
||||
} finally {
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResponseContainsBaseUrlFixed() throws Exception {
|
||||
ourServlet.setServerAddressStrategy(new HardcodedServerAddressStrategy("http://foo/bar"));
|
||||
|
||||
String output;
|
||||
|
||||
HttpRequestBase httpPost = new HttpGet("http://localhost:" + ourPort + "/metadata?_format=json");
|
||||
CloseableHttpResponse status = ourClient.execute(httpPost);
|
||||
try {
|
||||
output = IOUtils.toString(status.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
ourLog.info(output);
|
||||
CapabilityStatement cs = ourCtx.newJsonParser().parseResource(CapabilityStatement.class, output);
|
||||
|
||||
assertEquals("http://foo/bar", cs.getImplementation().getUrl());
|
||||
} finally {
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSummary() throws Exception {
|
||||
String output;
|
||||
|
||||
// With
|
||||
HttpRequestBase httpPost = new HttpGet("http://localhost:" + ourPort + "/metadata?_summary=true&_pretty=true");
|
||||
CloseableHttpResponse status = ourClient.execute(httpPost);
|
||||
try {
|
||||
output = IOUtils.toString(status.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
ourLog.info(output);
|
||||
assertThat(output, containsString("<CapabilityStatement"));
|
||||
assertThat(output, stringContainsInOrder("<meta>", "SUBSETTED", "</meta>"));
|
||||
assertThat(output, not(stringContainsInOrder("searchParam")));
|
||||
} finally {
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
}
|
||||
|
||||
// Without
|
||||
httpPost = new HttpGet("http://localhost:" + ourPort + "/metadata?_pretty=true");
|
||||
status = ourClient.execute(httpPost);
|
||||
try {
|
||||
output = IOUtils.toString(status.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
ourLog.info(output);
|
||||
assertThat(output, containsString("<CapabilityStatement"));
|
||||
assertThat(output, not(stringContainsInOrder("<meta>", "SUBSETTED", "</meta>")));
|
||||
assertThat(output, stringContainsInOrder("searchParam"));
|
||||
} finally {
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
}
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() throws Exception {
|
||||
ourServer.stop();
|
||||
|
@ -157,7 +198,7 @@ public class MetadataCapabilityStatementDstu3Test {
|
|||
ourServlet = new RestfulServer(ourCtx);
|
||||
ourServlet.setResourceProviders(patientProvider);
|
||||
|
||||
ourServlet.setServerConformanceProvider(new ServerCapabilityStatementProvider(ourServlet));
|
||||
ourServlet.setServerConformanceProvider(new ServerCapabilityStatementProvider(ourServlet).setCache(false));
|
||||
|
||||
ServletHolder servletHolder = new ServletHolder(ourServlet);
|
||||
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
||||
|
|
|
@ -2,7 +2,7 @@ package ca.uhn.fhir.util;
|
|||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import javax.xml.parsers.FactoryConfigurationError;
|
||||
import javax.xml.stream.FactoryConfigurationError;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
|
||||
import org.hl7.fhir.dstu3.model.Patient;
|
||||
|
@ -38,6 +38,7 @@ public class XmlUtilDstu3Test {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testXmlFactoryThrowsXmlStreamException() {
|
||||
XmlUtil.setThrowExceptionForUnitTest(new XMLStreamException("FOO"));
|
||||
|
||||
|
@ -55,18 +56,13 @@ public class XmlUtilDstu3Test {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testXmlFactoryThrowsFactoryConfigurationError() {
|
||||
XmlUtil.setThrowExceptionForUnitTest(new FactoryConfigurationError("FOO"));
|
||||
|
||||
try {
|
||||
ourCtx.newXmlParser().parseResource("AAAAA");
|
||||
fail();
|
||||
} catch (DataFormatException e) {
|
||||
// good
|
||||
}
|
||||
try {
|
||||
ourCtx.newXmlParser().encodeResourceToString(myPatient);
|
||||
fail();
|
||||
} catch (ConfigurationException e) {
|
||||
// good
|
||||
}
|
||||
|
|
|
@ -121,23 +121,38 @@
|
|||
<artifactId>thymeleaf</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Dependencies for Schematron -->
|
||||
<dependency>
|
||||
<groupId>com.helger</groupId>
|
||||
<artifactId>ph-schematron</artifactId>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>Saxon-HE</artifactId>
|
||||
<groupId>net.sf.saxon</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.helger</groupId>
|
||||
<artifactId>ph-commons</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.activation</groupId>
|
||||
<artifactId>javax.activation-api</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-impl</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- UNIT TEST DEPENDENCIES -->
|
||||
<dependency>
|
||||
|
|
|
@ -24,12 +24,14 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
|||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.instance.model.*;
|
||||
import org.hl7.fhir.instance.model.Conformance.*;
|
||||
|
@ -69,33 +71,40 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
private IdentityHashMap<OperationMethodBinding, String> myOperationBindingToName;
|
||||
private HashMap<String, List<OperationMethodBinding>> myOperationNameToBindings;
|
||||
private String myPublisher = "Not provided";
|
||||
private RestulfulServerConfiguration myServerConfiguration;
|
||||
private Callable<RestulfulServerConfiguration> myServerConfiguration;
|
||||
|
||||
public ServerConformanceProvider(RestfulServer theRestfulServer) {
|
||||
this.myServerConfiguration = theRestfulServer.createConfiguration();
|
||||
}
|
||||
|
||||
public ServerConformanceProvider(RestulfulServerConfiguration theServerConfiguration) {
|
||||
this.myServerConfiguration = theServerConfiguration;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add a no-arg constructor and seetter so that the
|
||||
* ServerConfirmanceProvider can be Spring-wired with
|
||||
* the RestfulService avoiding the potential reference
|
||||
* cycle that would happen.
|
||||
/**
|
||||
* No-arg constructor and seetter so that the ServerConfirmanceProvider can be Spring-wired with the RestfulService avoiding the potential reference cycle that would happen.
|
||||
*/
|
||||
public ServerConformanceProvider() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public ServerConformanceProvider(RestfulServer theRestfulServer) {
|
||||
this.myServerConfiguration = theRestfulServer::createConfiguration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public ServerConformanceProvider(RestulfulServerConfiguration theServerConfiguration) {
|
||||
this.myServerConfiguration = () -> theServerConfiguration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRestfulServer (RestfulServer theRestfulServer) {
|
||||
myServerConfiguration = theRestfulServer.createConfiguration();
|
||||
myServerConfiguration = theRestfulServer::createConfiguration;
|
||||
}
|
||||
|
||||
RestulfulServerConfiguration getServerConfiguration() {
|
||||
return myServerConfiguration;
|
||||
try {
|
||||
return myServerConfiguration.call();
|
||||
} catch (Exception e) {
|
||||
throw new InternalErrorException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkBindingForSystemOps(ConformanceRestComponent rest, Set<SystemRestfulInteraction> systemOps,
|
||||
|
@ -122,7 +131,7 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
|
||||
private Map<String, List<BaseMethodBinding<?>>> collectMethodBindings() {
|
||||
Map<String, List<BaseMethodBinding<?>>> resourceToMethods = new TreeMap<String, List<BaseMethodBinding<?>>>();
|
||||
for (ResourceBinding next : myServerConfiguration.getResourceBindings()) {
|
||||
for (ResourceBinding next : getServerConfiguration().getResourceBindings()) {
|
||||
String resourceName = next.getResourceName();
|
||||
for (BaseMethodBinding<?> nextMethodBinding : next.getMethodBindings()) {
|
||||
if (resourceToMethods.containsKey(resourceName) == false) {
|
||||
|
@ -131,7 +140,7 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
resourceToMethods.get(resourceName).add(nextMethodBinding);
|
||||
}
|
||||
}
|
||||
for (BaseMethodBinding<?> nextMethodBinding : myServerConfiguration.getServerBindings()) {
|
||||
for (BaseMethodBinding<?> nextMethodBinding : getServerConfiguration().getServerBindings()) {
|
||||
String resourceName = "";
|
||||
if (resourceToMethods.containsKey(resourceName) == false) {
|
||||
resourceToMethods.put(resourceName, new ArrayList<BaseMethodBinding<?>>());
|
||||
|
@ -171,10 +180,10 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
retVal.setAcceptUnknown(UnknownContentCode.EXTENSIONS); // TODO: make this configurable - this is a fairly big effort since the parser
|
||||
// needs to be modified to actually allow it
|
||||
|
||||
retVal.getImplementation().setDescription(myServerConfiguration.getImplementationDescription());
|
||||
retVal.getImplementation().setDescription(getServerConfiguration().getImplementationDescription());
|
||||
retVal.setKind(ConformanceStatementKind.INSTANCE);
|
||||
retVal.getSoftware().setName(myServerConfiguration.getServerName());
|
||||
retVal.getSoftware().setVersion(myServerConfiguration.getServerVersion());
|
||||
retVal.getSoftware().setName(getServerConfiguration().getServerName());
|
||||
retVal.getSoftware().setVersion(getServerConfiguration().getServerVersion());
|
||||
retVal.addFormat(Constants.CT_FHIR_XML);
|
||||
retVal.addFormat(Constants.CT_FHIR_JSON);
|
||||
|
||||
|
@ -191,13 +200,13 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
Set<TypeRestfulInteraction> resourceOps = new HashSet<TypeRestfulInteraction>();
|
||||
ConformanceRestResourceComponent resource = rest.addResource();
|
||||
String resourceName = nextEntry.getKey();
|
||||
RuntimeResourceDefinition def = myServerConfiguration.getFhirContext().getResourceDefinition(resourceName);
|
||||
RuntimeResourceDefinition def = getServerConfiguration().getFhirContext().getResourceDefinition(resourceName);
|
||||
resource.getTypeElement().setValue(def.getName());
|
||||
ServletContext servletContext = (ServletContext) (theRequest == null ? null : theRequest.getAttribute(RestfulServer.SERVLET_CONTEXT_ATTRIBUTE));
|
||||
String serverBase = myServerConfiguration.getServerAddressStrategy().determineServerBase(servletContext, theRequest);
|
||||
String serverBase = getServerConfiguration().getServerAddressStrategy().determineServerBase(servletContext, theRequest);
|
||||
resource.getProfile().setReference((def.getResourceProfile(serverBase)));
|
||||
|
||||
TreeSet<String> includes = new TreeSet<String>();
|
||||
TreeSet<String> includes = new TreeSet<>();
|
||||
|
||||
// Map<String, Conformance.RestResourceSearchParam> nameToSearchParam =
|
||||
// new HashMap<String,
|
||||
|
@ -305,7 +314,7 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
}
|
||||
|
||||
private DateTimeType conformanceDate() {
|
||||
String buildDate = myServerConfiguration.getConformanceDate();
|
||||
String buildDate = getServerConfiguration().getConformanceDate();
|
||||
if (buildDate != null) {
|
||||
try {
|
||||
return new DateTimeType(buildDate);
|
||||
|
@ -426,7 +435,7 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
param.getTypeElement().setValueAsString(nextParameter.getParamType().getCode());
|
||||
}
|
||||
for (Class<? extends IBaseResource> nextTarget : nextParameter.getDeclaredTypes()) {
|
||||
RuntimeResourceDefinition targetDef = myServerConfiguration.getFhirContext().getResourceDefinition(nextTarget);
|
||||
RuntimeResourceDefinition targetDef = getServerConfiguration().getFhirContext().getResourceDefinition(nextTarget);
|
||||
if (targetDef != null) {
|
||||
ResourceType code;
|
||||
try {
|
||||
|
@ -445,8 +454,8 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
|
||||
@Initialize
|
||||
public void initializeOperations() {
|
||||
myOperationBindingToName = new IdentityHashMap<OperationMethodBinding, String>();
|
||||
myOperationNameToBindings = new HashMap<String, List<OperationMethodBinding>>();
|
||||
myOperationBindingToName = new IdentityHashMap<>();
|
||||
myOperationNameToBindings = new HashMap<>();
|
||||
|
||||
Map<String, List<BaseMethodBinding<?>>> resourceToMethods = collectMethodBindings();
|
||||
for (Entry<String, List<BaseMethodBinding<?>>> nextEntry : resourceToMethods.entrySet()) {
|
||||
|
@ -461,7 +470,7 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
String name = createOperationName(methodBinding);
|
||||
myOperationBindingToName.put(methodBinding, name);
|
||||
if (myOperationNameToBindings.containsKey(name) == false) {
|
||||
myOperationNameToBindings.put(name, new ArrayList<OperationMethodBinding>());
|
||||
myOperationNameToBindings.put(name, new ArrayList<>());
|
||||
}
|
||||
myOperationNameToBindings.get(name).add(methodBinding);
|
||||
}
|
||||
|
@ -483,8 +492,8 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
op.setStatus(ConformanceResourceStatus.ACTIVE);
|
||||
op.setIdempotent(true);
|
||||
|
||||
Set<String> inParams = new HashSet<String>();
|
||||
Set<String> outParams = new HashSet<String>();
|
||||
Set<String> inParams = new HashSet<>();
|
||||
Set<String> outParams = new HashSet<>();
|
||||
|
||||
for (OperationMethodBinding sharedDescription : sharedDescriptions) {
|
||||
if (isNotBlank(sharedDescription.getDescription())) {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue