Add unit tests and update healthconnex server
This commit is contained in:
parent
70d4abdf06
commit
fed9f4d61e
|
@ -3,7 +3,7 @@ sudo: false
|
||||||
|
|
||||||
language: java
|
language: java
|
||||||
jdk:
|
jdk:
|
||||||
- oraclejdk7
|
- oraclejdk8
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
- MAVEN_OPTS="-XX:MaxPermSize=512m -Xmx4g"
|
- MAVEN_OPTS="-XX:MaxPermSize=512m -Xmx4g"
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package ca.uhn.fhir.rest.method;
|
package ca.uhn.fhir.rest.method;
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
import static org.apache.commons.lang3.StringUtils.*;
|
||||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PushbackReader;
|
import java.io.PushbackReader;
|
||||||
|
|
|
@ -309,7 +309,6 @@
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
<runOrder>alphabetical</runOrder>
|
<runOrder>alphabetical</runOrder>
|
||||||
<reuseForks>false</reuseForks>
|
|
||||||
<argLine>-Xms512m -Xmx1024m</argLine>
|
<argLine>-Xms512m -Xmx1024m</argLine>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
@ -392,20 +391,38 @@
|
||||||
<skip>true</skip>
|
<skip>true</skip>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
<reportSets>
|
<reportSets>
|
||||||
<reportSet>
|
<reportSet>
|
||||||
<reports>
|
<reports>
|
||||||
<report>checkstyle</report>
|
<report>checkstyle</report>
|
||||||
</reports>
|
</reports>
|
||||||
</reportSet>
|
</reportSet>
|
||||||
</reportSets>
|
</reportSets>
|
||||||
<configuration>
|
<configuration>
|
||||||
<linkXRef>false</linkXRef>
|
<linkXRef>false</linkXRef>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</reporting>
|
</reporting>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>TRAVIS</id>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<!-- Travis build seems to run out of memory unless we don't reuse JVMs -->
|
||||||
|
<reuseForks>false</reuseForks>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
<value>hi , DSTU1 , Health Intersections (DSTU1 FHIR) , http://fhir.healthintersections.com.au/open</value>
|
<value>hi , DSTU1 , Health Intersections (DSTU1 FHIR) , http://fhir.healthintersections.com.au/open</value>
|
||||||
<value>furored2 , DSTU2 , Spark - Furore (DSTU2 FHIR) , http://spark-dstu2.furore.com/fhir</value>
|
<value>furored2 , DSTU2 , Spark - Furore (DSTU2 FHIR) , http://spark-dstu2.furore.com/fhir</value>
|
||||||
<value>furore , DSTU1 , Spark - Furore (DSTU1 FHIR) , http://spark.furore.com/fhir</value>
|
<value>furore , DSTU1 , Spark - Furore (DSTU1 FHIR) , http://spark.furore.com/fhir</value>
|
||||||
<value>sof , DSTU2 , SQL on FHIR - HealthConnex (DSTU2 FHIR) , http://sqlonfhir.azurewebsites.net/api</value>
|
<value>sof , DSTU2 , SQL on FHIR - HealthConnex (DSTU2 FHIR) , http://sqlonfhir.azurewebsites.net/fhir</value>
|
||||||
<!--
|
<!--
|
||||||
<value>blaze , DSTU1 , Blaze (Orion Health) , https://fhir.orionhealth.com/blaze/fhir</value>
|
<value>blaze , DSTU1 , Blaze (Orion Health) , https://fhir.orionhealth.com/blaze/fhir</value>
|
||||||
<value>oridashi , DSTU1 , Oridashi , http://demo.oridashi.com.au:8190</value>
|
<value>oridashi , DSTU1 , Oridashi , http://demo.oridashi.com.au:8190</value>
|
||||||
|
|
|
@ -164,6 +164,14 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
||||||
resourceOps.add(resOp);
|
resourceOps.add(resOp);
|
||||||
resource.addInteraction().setCode(resOp);
|
resource.addInteraction().setCode(resOp);
|
||||||
}
|
}
|
||||||
|
if ("vread".equals(resOpCode)) {
|
||||||
|
// vread implies read
|
||||||
|
resOp = TypeRestfulInteractionEnum.READ;
|
||||||
|
if (resourceOps.contains(resOp) == false) {
|
||||||
|
resourceOps.add(resOp);
|
||||||
|
resource.addInteraction().setCode(resOp);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package ca.uhn.fhir.rest.server;
|
package ca.uhn.fhir.rest.server;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.containsString;
|
import static org.hamcrest.Matchers.*;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
@ -27,12 +27,14 @@ import ca.uhn.fhir.model.dstu2.resource.Conformance.RestResource;
|
||||||
import ca.uhn.fhir.model.dstu2.resource.DiagnosticReport;
|
import ca.uhn.fhir.model.dstu2.resource.DiagnosticReport;
|
||||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||||
import ca.uhn.fhir.model.primitive.DateDt;
|
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.StringDt;
|
||||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||||
import ca.uhn.fhir.rest.annotation.IncludeParam;
|
import ca.uhn.fhir.rest.annotation.IncludeParam;
|
||||||
import ca.uhn.fhir.rest.annotation.Operation;
|
import ca.uhn.fhir.rest.annotation.Operation;
|
||||||
import ca.uhn.fhir.rest.annotation.OperationParam;
|
import ca.uhn.fhir.rest.annotation.OperationParam;
|
||||||
import ca.uhn.fhir.rest.annotation.OptionalParam;
|
import ca.uhn.fhir.rest.annotation.OptionalParam;
|
||||||
|
import ca.uhn.fhir.rest.annotation.Read;
|
||||||
import ca.uhn.fhir.rest.annotation.RequiredParam;
|
import ca.uhn.fhir.rest.annotation.RequiredParam;
|
||||||
import ca.uhn.fhir.rest.annotation.Search;
|
import ca.uhn.fhir.rest.annotation.Search;
|
||||||
import ca.uhn.fhir.rest.method.BaseMethodBinding;
|
import ca.uhn.fhir.rest.method.BaseMethodBinding;
|
||||||
|
@ -184,6 +186,45 @@ public class ServerConformanceProviderDstu2Test {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
public void testReadAndVReadSupported() throws Exception {
|
||||||
|
|
||||||
|
RestfulServer rs = new RestfulServer(ourCtx);
|
||||||
|
rs.setProviders(new VreadProvider());
|
||||||
|
|
||||||
|
ServerConformanceProvider sc = new ServerConformanceProvider(rs);
|
||||||
|
rs.setServerConformanceProvider(sc);
|
||||||
|
|
||||||
|
rs.init(createServletConfig());
|
||||||
|
|
||||||
|
Conformance conformance = sc.getServerConformance(createHttpServletRequest());
|
||||||
|
String conf = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance);
|
||||||
|
ourLog.info(conf);
|
||||||
|
|
||||||
|
conf = ourCtx.newXmlParser().setPrettyPrint(false).encodeResourceToString(conformance);
|
||||||
|
assertThat(conf, containsString("<interaction><code value=\"vread\"/></interaction>"));
|
||||||
|
assertThat(conf, containsString("<interaction><code value=\"read\"/></interaction>"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testReadSupported() throws Exception {
|
||||||
|
|
||||||
|
RestfulServer rs = new RestfulServer(ourCtx);
|
||||||
|
rs.setProviders(new ReadProvider());
|
||||||
|
|
||||||
|
ServerConformanceProvider sc = new ServerConformanceProvider(rs);
|
||||||
|
rs.setServerConformanceProvider(sc);
|
||||||
|
|
||||||
|
rs.init(createServletConfig());
|
||||||
|
|
||||||
|
Conformance conformance = sc.getServerConformance(createHttpServletRequest());
|
||||||
|
String conf = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance);
|
||||||
|
ourLog.info(conf);
|
||||||
|
|
||||||
|
conf = ourCtx.newXmlParser().setPrettyPrint(false).encodeResourceToString(conformance);
|
||||||
|
assertThat(conf, not(containsString("<interaction><code value=\"vread\"/></interaction>")));
|
||||||
|
assertThat(conf, containsString("<interaction><code value=\"read\"/></interaction>"));
|
||||||
|
}
|
||||||
|
@Test
|
||||||
public void testProviderWithRequiredAndOptional() throws Exception {
|
public void testProviderWithRequiredAndOptional() throws Exception {
|
||||||
|
|
||||||
RestfulServer rs = new RestfulServer(ourCtx);
|
RestfulServer rs = new RestfulServer(ourCtx);
|
||||||
|
@ -219,6 +260,7 @@ public class ServerConformanceProviderDstu2Test {
|
||||||
*/
|
*/
|
||||||
public static class SearchProvider {
|
public static class SearchProvider {
|
||||||
|
|
||||||
|
|
||||||
@Search(type = Patient.class)
|
@Search(type = Patient.class)
|
||||||
public Patient findPatient(
|
public Patient findPatient(
|
||||||
@Description(shortDefinition = "The patient's identifier (MRN or other card number)")
|
@Description(shortDefinition = "The patient's identifier (MRN or other card number)")
|
||||||
|
@ -228,6 +270,45 @@ public class ServerConformanceProviderDstu2Test {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by dsotnikov on 2/25/2014.
|
||||||
|
*/
|
||||||
|
public static class VreadProvider {
|
||||||
|
|
||||||
|
@Read(version=true)
|
||||||
|
public Patient readPatient(
|
||||||
|
@IdParam IdDt theId) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Search(type = Patient.class)
|
||||||
|
public Patient findPatient(
|
||||||
|
@Description(shortDefinition = "The patient's identifier (MRN or other card number)")
|
||||||
|
@RequiredParam(name = Patient.SP_IDENTIFIER) IdentifierDt theIdentifier) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by dsotnikov on 2/25/2014.
|
||||||
|
*/
|
||||||
|
public static class ReadProvider {
|
||||||
|
|
||||||
|
@Read(version=false)
|
||||||
|
public Patient readPatient(
|
||||||
|
@IdParam IdDt theId) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Search(type = Patient.class)
|
||||||
|
public Patient findPatient(
|
||||||
|
@Description(shortDefinition = "The patient's identifier (MRN or other card number)")
|
||||||
|
@RequiredParam(name = Patient.SP_IDENTIFIER) IdentifierDt theIdentifier) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by dsotnikov on 2/25/2014.
|
* Created by dsotnikov on 2/25/2014.
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package ca.uhn.fhir.rest.server.interceptor;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class ResponseHighlightingInterceptorTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testHighlight() {
|
||||||
|
ResponseHighlighterInterceptor ic = new ResponseHighlighterInterceptor();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -267,7 +267,7 @@ patient.addIdentifier().setUse(SECONDARY).setSystem("urn:fake:otherids").setValu
|
||||||
|
|
||||||
patient.addName().addFamily("Smith").addGiven("John").addGiven("Q").addSuffix("Junior");
|
patient.addName().addFamily("Smith").addGiven("John").addGiven("Q").addSuffix("Junior");
|
||||||
|
|
||||||
patient.setGender(AdministrativeGenderCodesEnum.M);]]></source>
|
patient.setGender(AdministrativeGenderEnum.MALE);]]></source>
|
||||||
|
|
||||||
</subsection>
|
</subsection>
|
||||||
<subsection name="Encoding Support">
|
<subsection name="Encoding Support">
|
||||||
|
@ -280,7 +280,7 @@ patient.setGender(AdministrativeGenderCodesEnum.M);]]></source>
|
||||||
<a href="https://jcp.org/en/jsr/detail?id=353">javax.json/JSR-353</a> API.
|
<a href="https://jcp.org/en/jsr/detail?id=353">javax.json/JSR-353</a> API.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<source><![CDATA[FhirContext ctx = new FhirContext();
|
<source><![CDATA[FhirContext ctx = FhirContext.forDstu2();
|
||||||
String xmlEncoded = ctx.newXmlParser().encodeResourceToString(patient);
|
String xmlEncoded = ctx.newXmlParser().encodeResourceToString(patient);
|
||||||
String jsonEncoded = ctx.newJsonParser().encodeResourceToString(patient);
|
String jsonEncoded = ctx.newJsonParser().encodeResourceToString(patient);
|
||||||
]]></source>
|
]]></source>
|
||||||
|
|
Loading…
Reference in New Issue