Add unit tests and update healthconnex server

This commit is contained in:
jamesagnew 2015-06-23 08:29:13 -04:00
parent 70d4abdf06
commit fed9f4d61e
8 changed files with 140 additions and 23 deletions

View File

@ -3,7 +3,7 @@ sudo: false
language: java
jdk:
- oraclejdk7
- oraclejdk8
env:
global:
- MAVEN_OPTS="-XX:MaxPermSize=512m -Xmx4g"

View File

@ -1,7 +1,6 @@
package ca.uhn.fhir.rest.method;
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import static org.apache.commons.lang3.StringUtils.*;
import java.io.IOException;
import java.io.PushbackReader;

View File

@ -309,7 +309,6 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<runOrder>alphabetical</runOrder>
<reuseForks>false</reuseForks>
<argLine>-Xms512m -Xmx1024m</argLine>
</configuration>
</plugin>
@ -392,20 +391,38 @@
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<reportSets>
<reportSet>
<reports>
<report>checkstyle</report>
</reports>
</reportSet>
</reportSets>
<configuration>
<linkXRef>false</linkXRef>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<reportSets>
<reportSet>
<reports>
<report>checkstyle</report>
</reports>
</reportSet>
</reportSets>
<configuration>
<linkXRef>false</linkXRef>
</configuration>
</plugin>
</plugins>
</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>

View File

@ -18,7 +18,7 @@
<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>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>oridashi , DSTU1 , Oridashi , http://demo.oridashi.com.au:8190</value>

View File

@ -164,6 +164,14 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
resourceOps.add(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);
}
}
}
}

View File

@ -1,6 +1,6 @@
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.assertThat;
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.Patient;
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.rest.annotation.IdParam;
import ca.uhn.fhir.rest.annotation.IncludeParam;
import ca.uhn.fhir.rest.annotation.Operation;
import ca.uhn.fhir.rest.annotation.OperationParam;
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.Search;
import ca.uhn.fhir.rest.method.BaseMethodBinding;
@ -184,6 +186,45 @@ public class ServerConformanceProviderDstu2Test {
}
@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 {
RestfulServer rs = new RestfulServer(ourCtx);
@ -219,6 +260,7 @@ public class ServerConformanceProviderDstu2Test {
*/
public static class SearchProvider {
@Search(type = Patient.class)
public Patient findPatient(
@Description(shortDefinition = "The patient's identifier (MRN or other card number)")
@ -228,7 +270,46 @@ 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.
*/

View File

@ -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();
}
}

View File

@ -267,7 +267,7 @@ patient.addIdentifier().setUse(SECONDARY).setSystem("urn:fake:otherids").setValu
patient.addName().addFamily("Smith").addGiven("John").addGiven("Q").addSuffix("Junior");
patient.setGender(AdministrativeGenderCodesEnum.M);]]></source>
patient.setGender(AdministrativeGenderEnum.MALE);]]></source>
</subsection>
<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.
</p>
<source><![CDATA[FhirContext ctx = new FhirContext();
<source><![CDATA[FhirContext ctx = FhirContext.forDstu2();
String xmlEncoded = ctx.newXmlParser().encodeResourceToString(patient);
String jsonEncoded = ctx.newJsonParser().encodeResourceToString(patient);
]]></source>