Unit tests almost all passing

This commit is contained in:
James Agnew 2014-10-16 17:19:27 -04:00
parent 1d29b2b642
commit bb0b39627d
184 changed files with 19260 additions and 221 deletions

View File

@ -19,6 +19,11 @@
<artifactId>hapi-fhir-base</artifactId>
<version>0.7-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>0.7-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>

View File

@ -6,6 +6,8 @@ import java.util.List;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.Bundle;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.base.resource.BaseConformance;
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
import ca.uhn.fhir.model.dstu.resource.Conformance;
import ca.uhn.fhir.model.dstu.resource.Observation;
import ca.uhn.fhir.model.dstu.resource.OperationOutcome;
@ -70,7 +72,7 @@ public class GenericClientExample {
// START SNIPPET: conformance
// Retrieve the server's conformance statement and print its
// description
Conformance conf = client.conformance();
BaseConformance conf = client.conformance();
System.out.println(conf.getDescription().getValue());
// END SNIPPET: conformance
}
@ -78,7 +80,7 @@ public class GenericClientExample {
// START SNIPPET: delete
// Retrieve the server's conformance statement and print its
// description
OperationOutcome outcome = client.delete().resourceById(new IdDt("Patient", "1234")).execute();
BaseOperationOutcome outcome = client.delete().resourceById(new IdDt("Patient", "1234")).execute();
// outcome may be null if the server didn't return one
if (outcome != null) {

View File

@ -19,6 +19,7 @@ import ca.uhn.fhir.model.api.Tag;
import ca.uhn.fhir.model.api.TagList;
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
import ca.uhn.fhir.model.api.annotation.Description;
import ca.uhn.fhir.model.base.composite.BaseCodingDt;
import ca.uhn.fhir.rest.annotation.TagListParam;
import ca.uhn.fhir.model.dstu.composite.CodingDt;
import ca.uhn.fhir.model.dstu.resource.Conformance;
@ -430,7 +431,7 @@ public List<Observation> searchByObservationNames(
// The list here will contain 0..* codings, and any observations which match any of the
// given codings should be returned
List<CodingDt> wantedCodings = theCodings.getListAsCodings();
List<BaseCodingDt> wantedCodings = theCodings.getListAsCodings();
List<Observation> retVal = new ArrayList<Observation>();
// ...populate...

View File

@ -178,138 +178,10 @@
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<version>${servlet_api_version}</version>
<scope>provided</scope>
</dependency>
<!-- Testing -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit_version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
<version>1.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlets</artifactId>
<version>9.1.1.v20140108</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>9.1.1.v20140108</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>9.1.1.v20140108</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>9.1.1.v20140108</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>9.1.1.v20140108</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>9.1.1.v20140108</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-http</artifactId>
<version>9.1.1.v20140108</version>
<scope>test</scope>
</dependency>
<!-- UNIT TEST DEPENDENCIES -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15-sources</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>directory-naming</groupId>
<artifactId>naming-java</artifactId>
<version>0.8</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>${hamcrest_version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava_version}</version>
<scope>test</scope>
</dependency>
<!--
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>${spring_security_version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${spring_security_version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-jwt</artifactId>
<version>1.0.2.RELEASE</version>
<scope>test</scope>
</dependency>
-->
</dependencies>

View File

@ -34,6 +34,7 @@ import ca.uhn.fhir.i18n.HapiLocalizer;
import ca.uhn.fhir.model.api.IElement;
import ca.uhn.fhir.model.api.IFhirVersion;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.dstu.valueset.FHIRDefinedTypeEnum;
import ca.uhn.fhir.model.view.ViewGenerator;
import ca.uhn.fhir.narrative.INarrativeGenerator;
import ca.uhn.fhir.parser.DataFormatException;
@ -92,6 +93,13 @@ public class FhirContext {
public FhirContext(Collection<Class<? extends IResource>> theResourceTypes) {
scanResourceTypes(theResourceTypes);
if (FhirVersionEnum.DSTU1.isPresentOnClasspath()) {
myVersion = FhirVersionEnum.DSTU1.getVersionImplementation();
} else {
throw new IllegalStateException("Could not find any HAPI-FHIR structure JARs on the classpath. Note that as of HAPI version 0.7, a separate FHIR strcture JAR must be added to your classpath or project pom.xml");
}
}
/**

View File

@ -0,0 +1,50 @@
package ca.uhn.fhir.context;
import ca.uhn.fhir.model.api.IFhirVersion;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import ca.uhn.fhir.validation.FhirValidator;
public enum FhirVersionEnum {
DSTU1("ca.uhn.fhir.model.dstu.FhirDstu1");
private final String myVersionClass;
private volatile Boolean myPresentOnClasspath;
private volatile IFhirVersion myVersionImplementation;
FhirVersionEnum(String theVersionClass) {
myVersionClass = theVersionClass;
}
/**
* Returns true if the given version is present on the classpath
*/
public boolean isPresentOnClasspath() {
Boolean retVal = myPresentOnClasspath;
if (retVal==null) {
try {
Class.forName(myVersionClass);
retVal= true;
} catch (Exception e) {
retVal= false;
}
myPresentOnClasspath = retVal;
}
return retVal;
}
public IFhirVersion getVersionImplementation() {
if (!isPresentOnClasspath()) {
throw new IllegalStateException("Version " + name() + " is not present on classpath");
}
if (myVersionImplementation == null) {
try {
myVersionImplementation = (IFhirVersion) Class.forName(myVersionClass).newInstance();
} catch (Exception e) {
throw new InternalErrorException("Failed to instantiate FHIR version " + name(), e);
}
}
return myVersionImplementation;
}
}

View File

@ -1,7 +1,15 @@
package ca.uhn.fhir.model.base.resource;
import ca.uhn.fhir.model.api.BaseResource;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.annotation.ResourceDef;
import ca.uhn.fhir.model.primitive.StringDt;
public abstract class BaseConformance implements IResource {
//@ResourceDef(name="Conformance")
public abstract class BaseConformance extends BaseResource implements IResource {
public abstract StringDt getDescription();
public abstract StringDt getPublisher();
}

View File

@ -29,6 +29,10 @@ public abstract class BaseOperationOutcome extends BaseResource implements IReso
public abstract BaseIssue addLocation( String theString);
public abstract BaseIssue setSeverity(IssueSeverityEnum theSeverity);
public abstract BaseIssue setDetails(String theString);
}

View File

@ -448,8 +448,9 @@ public abstract class BaseMethodBinding<T> implements IClientResponseHandler<T>
if (!IResource.class.isAssignableFrom(theReturnType)) {
return false;
}
boolean retVal = Modifier.isAbstract(theReturnType.getModifiers()) == false;
return retVal;
return true;
// boolean retVal = Modifier.isAbstract(theReturnType.getModifiers()) == false;
// return retVal;
}
protected static IBundleProvider toResourceList(Object response) throws InternalErrorException {

View File

@ -23,6 +23,7 @@ package ca.uhn.fhir.rest.method;
import java.io.IOException;
import java.io.Reader;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@ -101,15 +102,20 @@ abstract class BaseResourceReturningMethodBinding extends BaseMethodBinding<Obje
if (theReturnResourceType != null) {
if (IResource.class.isAssignableFrom(theReturnResourceType)) {
myResourceType = (Class<? extends IResource>) theReturnResourceType;
ResourceDef resourceDefAnnotation = theReturnResourceType.getAnnotation(ResourceDef.class);
if (resourceDefAnnotation == null) {
if (Modifier.isAbstract(theReturnResourceType.getModifiers())) {
// If we're returning an abstract type, that's ok
}else {
throw new ConfigurationException(theReturnResourceType.getCanonicalName() + " has no @" + ResourceDef.class.getSimpleName() + " annotation");
}
} else {
myResourceType = (Class<? extends IResource>) theReturnResourceType;
myResourceName = resourceDefAnnotation.name();
}
}
}
}
public MethodReturnTypeEnum getMethodReturnType() {
return myMethodReturnType;

View File

@ -40,8 +40,11 @@ public class ConformanceMethodBinding extends BaseResourceReturningMethodBinding
public ConformanceMethodBinding(Method theMethod, FhirContext theContext, Object theProvider) {
super(theMethod.getReturnType(), theMethod, theContext, theProvider);
if (getMethodReturnType() != MethodReturnTypeEnum.RESOURCE || BaseConformance.class.isAssignableFrom(theMethod.getReturnType()) || Modifier.isAbstract(theMethod.getReturnType().getModifiers())) {
throw new ConfigurationException("Conformance resource provider method '" + theMethod.getName() + "' should return a Conformance resource class");
// if (Modifier.isAbstract(theMethod.getReturnType().getModifiers())) {
// throw new ConfigurationException("Conformance resource provider method '" + theMethod.getName() + "' must not be abstract");
// }
if (getMethodReturnType() != MethodReturnTypeEnum.RESOURCE || !BaseConformance.class.isAssignableFrom(theMethod.getReturnType())) {
throw new ConfigurationException("Conformance resource provider method '" + theMethod.getName() + "' should return a Conformance resource class, returns: " + theMethod.getReturnType());
}
}

View File

@ -41,7 +41,6 @@ import java.util.List;
import ca.uhn.fhir.model.api.ICompositeDatatype;
import ca.uhn.fhir.model.api.IElement;
import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
import ca.uhn.fhir.model.api.annotation.Description;
import ca.uhn.fhir.model.base.composite.BaseCodingDt;
import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt;
@ -58,7 +57,7 @@ public class InternalCodingDt
* Constructor
*/
public InternalCodingDt() {
// nothing
super();
}
/**

View File

@ -3,6 +3,7 @@ package ca.uhn.fhir.rest.param;
import java.util.ArrayList;
import java.util.List;
import ca.uhn.fhir.model.base.composite.BaseCodingDt;
import ca.uhn.fhir.model.base.composite.BaseIdentifierDt;
/*
@ -33,8 +34,8 @@ public class TokenOrListParam extends BaseOrListParam<TokenParam> {
return new TokenParam();
}
public List<InternalCodingDt> getListAsCodings() {
ArrayList<InternalCodingDt> retVal = new ArrayList<InternalCodingDt>();
public List<BaseCodingDt> getListAsCodings() {
ArrayList<BaseCodingDt> retVal = new ArrayList<BaseCodingDt>();
for (TokenParam next : getValuesAsQueryTokens()) {
InternalCodingDt nextCoding = next.getValueAsCoding();
if (!nextCoding.isEmpty()) {
@ -48,7 +49,7 @@ public class TokenOrListParam extends BaseOrListParam<TokenParam> {
* Convenience method which adds a token to this OR list
* using the system and code from a coding
*/
public void add(InternalCodingDt theCodingDt) {
public void add(BaseCodingDt theCodingDt) {
add(new TokenParam(theCodingDt));
}

View File

@ -42,7 +42,11 @@
<artifactId>hapi-fhir-base</artifactId>
<version>0.7-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>0.7-SNAPSHOT</version>
</dependency>
</dependencies>

View File

@ -52,6 +52,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>0.7-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>

View File

@ -12,6 +12,9 @@
<dependent-module archiveName="hapi-fhir-base-0.7-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/hapi-fhir-base/hapi-fhir-base">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="hapi-fhir-structures-dstu-0.7-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/hapi-fhir-structures-dstu/hapi-fhir-structures-dstu">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module deploy-path="/" handle="module:/overlay/var/M2_REPO/ca/uhn/hapi/fhir/hapi-fhir-testpage-overlay/0.7-SNAPSHOT/hapi-fhir-testpage-overlay-0.7-SNAPSHOT.war?unpackFolder=target/m2e-wtp/overlays&amp;includes=**/**&amp;excludes=META-INF/MANIFEST.MF">
<dependency-type>consumes</dependency-type>
</dependent-module>

View File

@ -19,6 +19,12 @@
<artifactId>hapi-fhir-base</artifactId>
<version>0.7-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>0.7-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<!-- Only required for OpenID Connect Support -->
<dependency>
@ -78,12 +84,6 @@
<version>${jetty_version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>${jetty_version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>

View File

@ -1,13 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="target/generated-sources/tinder"/>
<classpathentry combineaccessrules="false" kind="src" path="/hapi-fhir-base"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry including="**/*.java" kind="src" path="src/test/resources"/>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="target/generated-sources/tinder"/>
<classpathentry combineaccessrules="false" kind="src" path="/hapi-fhir-base"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<attributes>
<attribute name="maven.pomderived" value="true"/>
@ -16,12 +23,7 @@
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>

View File

@ -5,11 +5,21 @@
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
@ -17,7 +27,10 @@
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures>
</projectDescription>

View File

@ -1,2 +1,5 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="hapi-fhir-structures-dstu">
<wb-resource deploy-path="/" source-path="/target/generated-sources/tinder"/>
<wb-resource deploy-path="/" source-path="/src/main/java"/>
<wb-resource deploy-path="/" source-path="/src/test/resources"/>
</wb-module>
</project-modules>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<installed facet="java" version="1.6"/>
<installed facet="jst.utility" version="1.0"/>
</faceted-project>

View File

@ -0,0 +1,2 @@
disabled=06target
eclipse.preferences.version=1

View File

@ -20,6 +20,170 @@
<artifactId>hapi-fhir-base</artifactId>
<version>0.7-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${servlet_api_version}</version>
<scope>provided</scope>
</dependency>
<!-- Testing -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit_version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
<version>1.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlets</artifactId>
<version>${jetty_version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>${jetty_version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jetty_version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>${jetty_version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>${jetty_version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>${jetty_version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-http</artifactId>
<version>${jetty_version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback_version}</version>
<optional>true</optional>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ebaysf.web</groupId>
<artifactId>cors-filter</artifactId>
<version>${ebay_cors_filter_version}</version>
<scope>test</scope>
</dependency>
<!-- Only required for Schematron Validator Support -->
<dependency>
<groupId>com.phloc</groupId>
<artifactId>phloc-schematron</artifactId>
<version>${phloc_schematron_version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.phloc</groupId>
<artifactId>phloc-commons</artifactId>
<version>${phloc_commons_version}</version>
<scope>test</scope>
</dependency>
<!-- UNIT TEST DEPENDENCIES -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15-sources</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>directory-naming</groupId>
<artifactId>naming-java</artifactId>
<version>0.8</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>${hamcrest_version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava_version}</version>
<scope>test</scope>
</dependency>
<!--
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>${spring_security_version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${spring_security_version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-jwt</artifactId>
<version>1.0.2.RELEASE</version>
<scope>test</scope>
</dependency>
-->
</dependencies>
<build>

View File

@ -44,8 +44,10 @@ import ca.uhn.fhir.model.dstu.resource.Profile.StructureElementDefinitionType;
import ca.uhn.fhir.model.dstu.valueset.DataTypeEnum;
import ca.uhn.fhir.model.dstu.valueset.SlicingRulesEnum;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.rest.server.IResourceProvider;
import ca.uhn.fhir.rest.server.RestfulServer;
import ca.uhn.fhir.rest.server.provider.ServerConformanceProvider;
import ca.uhn.fhir.rest.server.provider.ServerProfileProvider;
public class FhirDstu1 implements IFhirVersion {
@ -303,4 +305,9 @@ public class FhirDstu1 implements IFhirVersion {
}
}
@Override
public IResourceProvider createServerProfilesProvider(RestfulServer theRestfulServer) {
return new ServerProfileProvider(theRestfulServer.getFhirContext());
}
}

View File

@ -39,8 +39,8 @@ public class ServerProfileProvider implements IResourceProvider {
private FhirContext myContext;
public ServerProfileProvider(FhirContext theContext) {
myContext = theContext;
public ServerProfileProvider(FhirContext theCtx) {
myContext = theCtx;
}
@Override

View File

@ -14,7 +14,7 @@ public class ModelScannerTest {
/** This failed at one point */
@Test
public void testCarePlan() throws DataFormatException {
new ModelScanner(CarePlan.class);
new ModelScanner(new FhirContext(), CarePlan.class);
}
@Test
@ -34,7 +34,7 @@ public class ModelScannerTest {
@Test
public void testScanExtensionTypes() throws DataFormatException {
ModelScanner scanner = new ModelScanner(ResourceWithExtensionsA.class);
ModelScanner scanner = new ModelScanner(new FhirContext(),ResourceWithExtensionsA.class);
RuntimeResourceDefinition def = (RuntimeResourceDefinition) scanner.getClassToElementDefinitions().get(ResourceWithExtensionsA.class);
assertEquals(RuntimeChildCompositeDatatypeDefinition.class, def.getChildByNameOrThrowDataFormatException("identifier").getClass());

View File

@ -22,7 +22,7 @@ public class RuntimeResourceDefinitionTest {
FhirContext ctx = new FhirContext(Patient.class, Profile.class);
RuntimeResourceDefinition def = ctx.getResourceDefinition(Patient.class);
Profile profile = def.toProfile();
Profile profile = (Profile) def.toProfile();
ourLog.info(ctx.newXmlParser().encodeResourceToString(profile));
@ -41,7 +41,7 @@ public class RuntimeResourceDefinitionTest {
FhirContext ctx = new FhirContext(ValueSet.class, Profile.class);
RuntimeResourceDefinition def = ctx.getResourceDefinition(ValueSet.class);
Profile profile = def.toProfile();
Profile profile = (Profile) def.toProfile();
String encoded = ctx.newXmlParser().setPrettyPrint(true).encodeResourceToString(profile);
ourLog.info(encoded);
@ -56,7 +56,7 @@ public class RuntimeResourceDefinitionTest {
FhirContext ctx = new FhirContext(ResourceWithExtensionsA.class, Profile.class);
RuntimeResourceDefinition def = ctx.getResourceDefinition(ResourceWithExtensionsA.class);
Profile profile = def.toProfile();
Profile profile = (Profile) def.toProfile();
ourLog.info(ctx.newXmlParser().encodeResourceToString(profile));

View File

@ -10,7 +10,7 @@ public class CodingDtTest {
@Test
public void testTokenNoSystem() {
InternalCodingDt dt = new InternalCodingDt();
CodingDt dt = new CodingDt();
dt.setValueAsQueryToken(null, "c");
assertEquals(null, dt.getSystem().getValueAsString());
@ -20,7 +20,7 @@ public class CodingDtTest {
@Test
public void testTokenWithPipeInValue() {
InternalCodingDt dt = new InternalCodingDt();
CodingDt dt = new CodingDt();
dt.setValueAsQueryToken(null, "a|b|c");
assertEquals("a", dt.getSystem().getValueAsString());
@ -30,7 +30,7 @@ public class CodingDtTest {
@Test
public void testTokenWithPipeInValueAndNoSystem() {
InternalCodingDt dt = new InternalCodingDt();
CodingDt dt = new CodingDt();
dt.setValueAsQueryToken(null, "|b\\|c");
assertEquals("", dt.getSystem().getValueAsString());
@ -44,7 +44,7 @@ public class CodingDtTest {
*/
@Test
public void testTokenWithPipeInValueAndNoSystemAndBeLenient() {
InternalCodingDt dt = new InternalCodingDt();
CodingDt dt = new CodingDt();
dt.setValueAsQueryToken(null, "|b|c");
assertEquals("", dt.getSystem().getValueAsString());

View File

@ -1,6 +1,7 @@
package ca.uhn.fhir.narrative;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import java.io.InputStreamReader;
import java.util.Date;
@ -169,8 +170,8 @@ public class DefaultThymeleafNarrativeGeneratorTest {
{
Observation obs = new Observation();
obs.getName().addCoding().setCode("1938HB").setDisplay("Hemoglobin");
obs.setValue(new InternalQuantityDt(null, 2.223, "mg/L"));
obs.addReferenceRange().setLow(new InternalQuantityDt(2.20)).setHigh(new InternalQuantityDt(2.99));
obs.setValue(new QuantityDt(null, 2.223, "mg/L"));
obs.addReferenceRange().setLow(new QuantityDt(2.20)).setHigh(new QuantityDt(2.99));
obs.setStatus(ObservationStatusEnum.FINAL);
obs.setComments("This is a result comment");

View File

@ -1,8 +1,12 @@
package ca.uhn.fhir.rest.client;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.io.InputStream;
import java.io.StringReader;
@ -41,6 +45,7 @@ import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
import ca.uhn.fhir.model.api.Tag;
import ca.uhn.fhir.model.api.TagList;
import ca.uhn.fhir.model.api.annotation.ResourceDef;
import ca.uhn.fhir.model.base.resource.BaseConformance;
import ca.uhn.fhir.model.dstu.composite.CodingDt;
import ca.uhn.fhir.model.dstu.resource.Conformance;
import ca.uhn.fhir.model.dstu.resource.Observation;
@ -275,7 +280,7 @@ public class ClientTest {
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
Conformance response = client.getServerConformanceStatement();
BaseConformance response = client.getServerConformanceStatement();
assertEquals("http://foo/metadata", capt.getValue().getURI().toString());
assertEquals("Health Intersections", response.getPublisher().getValue());
@ -822,8 +827,8 @@ public class ClientTest {
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
TokenOrListParam identifiers = new TokenOrListParam();
identifiers.add(new InternalCodingDt("foo", "bar"));
identifiers.add(new InternalCodingDt("baz", "boz"));
identifiers.add(new CodingDt("foo", "bar"));
identifiers.add(new CodingDt("baz", "boz"));
client.getPatientMultipleIdentifiers(identifiers);
assertEquals("http://foo/Patient?ids=foo%7Cbar%2Cbaz%7Cboz", capt.getValue().getURI().toString());

View File

@ -243,14 +243,14 @@ public class GenericClientTest {
IGenericClient client = myCtx.newRestfulGenericClient("http://example.com/fhir");
OperationOutcome outcome = client.delete().resourceById("Patient", "123").execute();
OperationOutcome outcome = (OperationOutcome) client.delete().resourceById("Patient", "123").execute();
assertEquals("http://example.com/fhir/Patient/123", capt.getValue().getURI().toString());
assertEquals("DELETE", capt.getValue().getMethod());
assertEquals("testDelete01", outcome.getIssueFirstRep().getLocationFirstRep().getValue());
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader("LKJHLKJGLKJKLL"), Charset.forName("UTF-8")));
outcome = client.delete().resourceById(new IdDt("Location", "123", "456")).prettyPrint().encodedJson().execute();
outcome = (OperationOutcome) client.delete().resourceById(new IdDt("Location", "123", "456")).prettyPrint().encodedJson().execute();
assertEquals("http://example.com/fhir/Location/123?_format=json&_pretty=true", capt.getAllValues().get(1).getURI().toString());
assertEquals("DELETE", capt.getValue().getMethod());

View File

@ -1,7 +1,10 @@
package ca.uhn.fhir.rest.server;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import java.util.ArrayList;
import java.util.Arrays;
@ -40,7 +43,7 @@ import ca.uhn.fhir.model.api.BundleEntry;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.Include;
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
import ca.uhn.fhir.model.dstu.composite.CodingDt;
import ca.uhn.fhir.model.base.composite.BaseCodingDt;
import ca.uhn.fhir.model.dstu.composite.HumanNameDt;
import ca.uhn.fhir.model.dstu.composite.IdentifierDt;
import ca.uhn.fhir.model.dstu.composite.QuantityDt;
@ -66,10 +69,9 @@ import ca.uhn.fhir.rest.annotation.ResourceParam;
import ca.uhn.fhir.rest.annotation.Search;
import ca.uhn.fhir.rest.annotation.Validate;
import ca.uhn.fhir.rest.api.MethodOutcome;
import ca.uhn.fhir.rest.param.CodingListParam;
import ca.uhn.fhir.rest.param.DateParam;
import ca.uhn.fhir.rest.param.DateRangeParam;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import ca.uhn.fhir.rest.param.TokenOrListParam;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
import ca.uhn.fhir.rest.server.provider.ServerProfileProvider;
@ -1096,7 +1098,7 @@ public class ResfulServerMethodTest {
}
public List<Patient> findDiagnosticReportsByPatient(@RequiredParam(name = "Patient.identifier") IdentifierDt thePatientId,
@RequiredParam(name = DiagnosticReport.SP_NAME) CodingListParam theNames, @OptionalParam(name = DiagnosticReport.SP_DATE) DateRangeParam theDateRange) throws Exception {
@RequiredParam(name = DiagnosticReport.SP_NAME) TokenOrListParam theNames, @OptionalParam(name = DiagnosticReport.SP_DATE) DateRangeParam theDateRange) throws Exception {
return Collections.emptyList();
}
@ -1198,11 +1200,11 @@ public class ResfulServerMethodTest {
}
@Search()
public List<Patient> getPatientMultipleIdentifiers(@RequiredParam(name = "ids") CodingListParam theIdentifiers) {
public List<Patient> getPatientMultipleIdentifiers(@RequiredParam(name = "ids") TokenOrListParam theIdentifiers) {
List<Patient> retVal = new ArrayList<Patient>();
Patient next = getIdToPatient().get("1");
for (InternalCodingDt nextId : theIdentifiers.getCodings()) {
for (BaseCodingDt nextId : theIdentifiers.getListAsCodings()) {
next.getIdentifier().add(new IdentifierDt(nextId.getSystem().getValueAsString(), nextId.getCode().getValue()));
}
@ -1227,7 +1229,7 @@ public class ResfulServerMethodTest {
}
@Search()
public Patient getPatientQuantityParam(@RequiredParam(name = "quantityParam") InternalQuantityDt theParam) {
public Patient getPatientQuantityParam(@RequiredParam(name = "quantityParam") QuantityDt theParam) {
Patient next = getIdToPatient().get("1");
next.addName().addFamily(theParam.getComparator().getValueAsString()).addFamily(theParam.getValue().getValueAsString()).addFamily(theParam.getSystem().getValueAsString())
.addFamily(theParam.getUnits().getValueAsString());
@ -1334,7 +1336,9 @@ public class ResfulServerMethodTest {
return methodOutcome;
}
if (thePatient.getNameFirstRep().getFamilyFirstRep().getValueNotNull().equals("BAR")) {
throw new UnprocessableEntityException("it failed");
OperationOutcome oo = new OperationOutcome();
oo.addIssue().setDetails("it failed");
throw new UnprocessableEntityException(oo);
}
return new MethodOutcome();
}

View File

@ -29,6 +29,7 @@ import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.Bundle;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
import ca.uhn.fhir.model.base.composite.BaseCodingDt;
import ca.uhn.fhir.model.dstu.composite.CodingDt;
import ca.uhn.fhir.model.dstu.resource.Observation;
import ca.uhn.fhir.model.dstu.resource.Patient;
@ -167,6 +168,7 @@ public class SearchTest {
HttpResponse status = ourClient.execute(httpGet);
String responseContent = IOUtils.toString(status.getEntity().getContent());
IOUtils.closeQuietly(status.getEntity().getContent());
assertEquals(200, status.getStatusLine().getStatusCode());
Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
assertEquals(1, bundle.getEntries().size());
@ -250,8 +252,8 @@ public class SearchTest {
o.setId("1");
o.getSubject().setReference(theSubject.getResourceType() + "/" + theSubject.getIdPart());
for (InternalCodingDt next : theName.getListAsCodings()) {
o.getName().getCoding().add(next);
for (BaseCodingDt next : theName.getListAsCodings()) {
o.getName().getCoding().add(new CodingDt(next));
}
return o;

View File

@ -1,7 +1,9 @@
package ca.uhn.fhir.rest.server;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Collection;
import java.util.List;
@ -27,8 +29,8 @@ import ca.uhn.fhir.rest.annotation.Search;
import ca.uhn.fhir.rest.method.BaseMethodBinding;
import ca.uhn.fhir.rest.method.SearchMethodBinding;
import ca.uhn.fhir.rest.method.SearchParameter;
import ca.uhn.fhir.rest.param.CodingListParam;
import ca.uhn.fhir.rest.param.DateRangeParam;
import ca.uhn.fhir.rest.param.TokenOrListParam;
import ca.uhn.fhir.rest.server.provider.ServerConformanceProvider;
public class ServerConformanceProviderTest {
@ -187,7 +189,7 @@ public class ServerConformanceProviderTest {
@Search
public List<DiagnosticReport> findDiagnosticReportsByPatient (
@RequiredParam(name=DiagnosticReport.SP_SUBJECT + '.' + Patient.SP_IDENTIFIER) IdentifierDt thePatientId,
@OptionalParam(name=DiagnosticReport.SP_NAME) CodingListParam theNames,
@OptionalParam(name=DiagnosticReport.SP_NAME) TokenOrListParam theNames,
@OptionalParam(name=DiagnosticReport.SP_DATE) DateRangeParam theDateRange,
@IncludeParam(allow= {"DiagnosticReport.result"}) Set<Include> theIncludes
) throws Exception {

Some files were not shown because too many files have changed in this diff Show More