Add consolidated test package and clean up tests for cobertura
This commit is contained in:
parent
cadf3eaa95
commit
71fbfe5214
|
@ -1,2 +1,7 @@
|
||||||
language: java
|
language: java
|
||||||
|
jdk:
|
||||||
|
- oraclejdk6
|
||||||
|
|
||||||
|
install: mvn clean install -Dcobertura.skip=true
|
||||||
|
script: mvn -P COBERTURA clean cobertura:cobertura
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class ClientExamples {
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public void createProxy() {
|
public void createProxy() {
|
||||||
// START SNIPPET: proxy
|
// START SNIPPET: proxy
|
||||||
FhirContext ctx = new FhirContext();
|
FhirContext ctx = FhirContext.forDstu2();
|
||||||
|
|
||||||
// Set connections to access the network via the HTTP proxy at
|
// Set connections to access the network via the HTTP proxy at
|
||||||
// example.com : 8888
|
// example.com : 8888
|
||||||
|
@ -36,7 +36,7 @@ public class ClientExamples {
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public void createTimeouts() {
|
public void createTimeouts() {
|
||||||
// START SNIPPET: timeouts
|
// START SNIPPET: timeouts
|
||||||
FhirContext ctx = new FhirContext();
|
FhirContext ctx = FhirContext.forDstu2();
|
||||||
|
|
||||||
// Set how long to try and establish the initial TCP connection (in ms)
|
// Set how long to try and establish the initial TCP connection (in ms)
|
||||||
ctx.getRestfulClientFactory().setConnectTimeout(20 * 1000);
|
ctx.getRestfulClientFactory().setConnectTimeout(20 * 1000);
|
||||||
|
@ -53,7 +53,7 @@ public class ClientExamples {
|
||||||
public void createSecurity() {
|
public void createSecurity() {
|
||||||
// START SNIPPET: security
|
// START SNIPPET: security
|
||||||
// Create a context and get the client factory so it can be configured
|
// Create a context and get the client factory so it can be configured
|
||||||
FhirContext ctx = new FhirContext();
|
FhirContext ctx = FhirContext.forDstu2();
|
||||||
IRestfulClientFactory clientFactory = ctx.getRestfulClientFactory();
|
IRestfulClientFactory clientFactory = ctx.getRestfulClientFactory();
|
||||||
|
|
||||||
// Create an HTTP basic auth interceptor
|
// Create an HTTP basic auth interceptor
|
||||||
|
@ -74,7 +74,7 @@ public class ClientExamples {
|
||||||
public void createCookie() {
|
public void createCookie() {
|
||||||
// START SNIPPET: cookie
|
// START SNIPPET: cookie
|
||||||
// Create a context and get the client factory so it can be configured
|
// Create a context and get the client factory so it can be configured
|
||||||
FhirContext ctx = new FhirContext();
|
FhirContext ctx = FhirContext.forDstu2();
|
||||||
IRestfulClientFactory clientFactory = ctx.getRestfulClientFactory();
|
IRestfulClientFactory clientFactory = ctx.getRestfulClientFactory();
|
||||||
|
|
||||||
// Create a cookie interceptor. This cookie will have the name "mycookie" and
|
// Create a cookie interceptor. This cookie will have the name "mycookie" and
|
||||||
|
@ -95,7 +95,7 @@ public class ClientExamples {
|
||||||
public void createSecurityBearer() {
|
public void createSecurityBearer() {
|
||||||
// START SNIPPET: securityBearer
|
// START SNIPPET: securityBearer
|
||||||
// Create a context and get the client factory so it can be configured
|
// Create a context and get the client factory so it can be configured
|
||||||
FhirContext ctx = new FhirContext();
|
FhirContext ctx = FhirContext.forDstu2();
|
||||||
IRestfulClientFactory clientFactory = ctx.getRestfulClientFactory();
|
IRestfulClientFactory clientFactory = ctx.getRestfulClientFactory();
|
||||||
|
|
||||||
// In reality the token would have come from an authorization server
|
// In reality the token would have come from an authorization server
|
||||||
|
@ -117,7 +117,7 @@ public class ClientExamples {
|
||||||
{
|
{
|
||||||
// START SNIPPET: logging
|
// START SNIPPET: logging
|
||||||
// Create a context and get the client factory so it can be configured
|
// Create a context and get the client factory so it can be configured
|
||||||
FhirContext ctx = new FhirContext();
|
FhirContext ctx = FhirContext.forDstu2();
|
||||||
IRestfulClientFactory clientFactory = ctx.getRestfulClientFactory();
|
IRestfulClientFactory clientFactory = ctx.getRestfulClientFactory();
|
||||||
|
|
||||||
// Create a logging interceptor
|
// Create a logging interceptor
|
||||||
|
@ -141,7 +141,7 @@ public class ClientExamples {
|
||||||
{
|
{
|
||||||
// START SNIPPET: clientConfig
|
// START SNIPPET: clientConfig
|
||||||
// Create a client
|
// Create a client
|
||||||
FhirContext ctx = new FhirContext();
|
FhirContext ctx = FhirContext.forDstu2();
|
||||||
IPatientClient client = ctx.newRestfulClient(IPatientClient.class, "http://localhost:9999/");
|
IPatientClient client = ctx.newRestfulClient(IPatientClient.class, "http://localhost:9999/");
|
||||||
|
|
||||||
// Request JSON encoding from the server (_format=json)
|
// Request JSON encoding from the server (_format=json)
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class CompleteExampleClient {
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
|
|
||||||
// Create a client factory
|
// Create a client factory
|
||||||
FhirContext ctx = new FhirContext();
|
FhirContext ctx = FhirContext.forDstu2();
|
||||||
|
|
||||||
// Create the client
|
// Create the client
|
||||||
String serverBase = "http://fhir.healthintersections.com.au/open";
|
String serverBase = "http://fhir.healthintersections.com.au/open";
|
||||||
|
|
|
@ -11,7 +11,7 @@ public class ExampleRestfulClient {
|
||||||
|
|
||||||
//START SNIPPET: client
|
//START SNIPPET: client
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
FhirContext ctx = new FhirContext();
|
FhirContext ctx = FhirContext.forDstu2();
|
||||||
String serverBase = "http://foo.com/fhirServerBase";
|
String serverBase = "http://foo.com/fhirServerBase";
|
||||||
|
|
||||||
// Create the client
|
// Create the client
|
||||||
|
|
|
@ -49,7 +49,8 @@ ExtensionDt givenExt = new ExtensionDt(false, "http://examples.com#moreext", new
|
||||||
given.addUndeclaredExtension(givenExt);
|
given.addUndeclaredExtension(givenExt);
|
||||||
//END SNIPPET: resourceStringExtension
|
//END SNIPPET: resourceStringExtension
|
||||||
|
|
||||||
String output = new FhirContext().newXmlParser().setPrettyPrint(true).encodeResourceToString(patient);
|
FhirContext ctx = FhirContext.forDstu2();
|
||||||
|
String output = ctx.newXmlParser().setPrettyPrint(true).encodeResourceToString(patient);
|
||||||
System.out.println(output);
|
System.out.println(output);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class HttpProxy {
|
||||||
.disableCookieManagement();
|
.disableCookieManagement();
|
||||||
CloseableHttpClient httpClient = clientBuilder.build();
|
CloseableHttpClient httpClient = clientBuilder.build();
|
||||||
|
|
||||||
FhirContext ctx = new FhirContext();
|
FhirContext ctx = FhirContext.forDstu2();
|
||||||
String serverBase = "http://spark.furore.com/fhir/";
|
String serverBase = "http://spark.furore.com/fhir/";
|
||||||
ctx.getRestfulClientFactory().setHttpClient(httpClient);
|
ctx.getRestfulClientFactory().setHttpClient(httpClient);
|
||||||
IGenericClient client = ctx.newRestfulGenericClient(serverBase);
|
IGenericClient client = ctx.newRestfulGenericClient(serverBase);
|
||||||
|
|
|
@ -65,19 +65,19 @@ patient.getImportantDates().add(new DateTimeDt("2014-01-26T11:11:11"));
|
||||||
|
|
||||||
patient.addName().addFamily("Smith").addGiven("John").addGiven("Quincy").addSuffix("Jr");
|
patient.addName().addFamily("Smith").addGiven("John").addGiven("Quincy").addSuffix("Jr");
|
||||||
|
|
||||||
IParser p = new FhirContext().newXmlParser().setPrettyPrint(true);
|
IParser p = FhirContext.forDstu2().newXmlParser().setPrettyPrint(true);
|
||||||
String messageString = p.encodeResourceToString(patient);
|
String messageString = p.encodeResourceToString(patient);
|
||||||
|
|
||||||
System.out.println(messageString);
|
System.out.println(messageString);
|
||||||
//END SNIPPET: patientUse
|
//END SNIPPET: patientUse
|
||||||
|
|
||||||
//START SNIPPET: patientParse
|
//START SNIPPET: patientParse
|
||||||
IParser parser = new FhirContext().newXmlParser();
|
IParser parser = FhirContext.forDstu2().newXmlParser();
|
||||||
MyPatient newPatient = parser.parseResource(MyPatient.class, messageString);
|
MyPatient newPatient = parser.parseResource(MyPatient.class, messageString);
|
||||||
//END SNIPPET: patientParse
|
//END SNIPPET: patientParse
|
||||||
|
|
||||||
{
|
{
|
||||||
FhirContext ctx2 = new FhirContext();
|
FhirContext ctx2 = FhirContext.forDstu2();
|
||||||
RuntimeResourceDefinition def = ctx2.getResourceDefinition(patient);
|
RuntimeResourceDefinition def = ctx2.getResourceDefinition(patient);
|
||||||
System.out.println(ctx2.newXmlParser().setPrettyPrint(true).encodeResourceToString(def.toProfile()));
|
System.out.println(ctx2.newXmlParser().setPrettyPrint(true).encodeResourceToString(def.toProfile()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ patient.addIdentifier().setSystem("urn:foo").setValue("7000135");
|
||||||
patient.addName().addFamily("Smith").addGiven("John").addGiven("Edward");
|
patient.addName().addFamily("Smith").addGiven("John").addGiven("Edward");
|
||||||
patient.addAddress().addLine("742 Evergreen Terrace").setCity("Springfield").setState("ZZ");
|
patient.addAddress().addLine("742 Evergreen Terrace").setCity("Springfield").setState("ZZ");
|
||||||
|
|
||||||
FhirContext ctx = new FhirContext();
|
FhirContext ctx = FhirContext.forDstu2();
|
||||||
|
|
||||||
// Use the narrative generator
|
// Use the narrative generator
|
||||||
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
|
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
|
||||||
|
|
|
@ -16,7 +16,7 @@ public class NarrativeGenerator {
|
||||||
String propFile = "classpath:/com/foo/customnarrative.properties";
|
String propFile = "classpath:/com/foo/customnarrative.properties";
|
||||||
CustomThymeleafNarrativeGenerator gen = new CustomThymeleafNarrativeGenerator(propFile);
|
CustomThymeleafNarrativeGenerator gen = new CustomThymeleafNarrativeGenerator(propFile);
|
||||||
|
|
||||||
FhirContext ctx = new FhirContext();
|
FhirContext ctx = FhirContext.forDstu2();
|
||||||
ctx.setNarrativeGenerator(gen);
|
ctx.setNarrativeGenerator(gen);
|
||||||
//END SNIPPET: gen
|
//END SNIPPET: gen
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ patient.addName().addFamily("Smith").addGiven("John").addGiven("Q").addSuffix("J
|
||||||
patient.setGender(AdministrativeGenderEnum.MALE);
|
patient.setGender(AdministrativeGenderEnum.MALE);
|
||||||
|
|
||||||
|
|
||||||
FhirContext ctx = new FhirContext();
|
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);
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||||
|
|
||||||
public class ResourceRefs {
|
public class ResourceRefs {
|
||||||
|
|
||||||
private static FhirContext ourCtx = new FhirContext();
|
private static FhirContext ourCtx = FhirContext.forDstu2();
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
manualContained();
|
manualContained();
|
||||||
|
|
|
@ -933,7 +933,7 @@ public interface HistoryClient extends IBasicClient {
|
||||||
|
|
||||||
public void bbbbb() throws DataFormatException, IOException {
|
public void bbbbb() throws DataFormatException, IOException {
|
||||||
//START SNIPPET: metadataClientUsage
|
//START SNIPPET: metadataClientUsage
|
||||||
FhirContext ctx = new FhirContext();
|
FhirContext ctx = FhirContext.forDstu2();
|
||||||
MetadataClient client = ctx.newRestfulClient(MetadataClient.class, "http://spark.furore.com/fhir");
|
MetadataClient client = ctx.newRestfulClient(MetadataClient.class, "http://spark.furore.com/fhir");
|
||||||
Conformance metadata = client.getServerMetadata();
|
Conformance metadata = client.getServerMetadata();
|
||||||
System.out.println(ctx.newXmlParser().encodeResourceToString(metadata));
|
System.out.println(ctx.newXmlParser().encodeResourceToString(metadata));
|
||||||
|
@ -973,7 +973,7 @@ private interface IPatientClient extends IBasicClient
|
||||||
|
|
||||||
public void clientRead() {
|
public void clientRead() {
|
||||||
//START SNIPPET: clientReadTags
|
//START SNIPPET: clientReadTags
|
||||||
IPatientClient client = new FhirContext().newRestfulClient(IPatientClient.class, "http://foo/fhir");
|
IPatientClient client = FhirContext.forDstu2().newRestfulClient(IPatientClient.class, "http://foo/fhir");
|
||||||
Patient patient = client.readPatient(new IdDt("1234"));
|
Patient patient = client.readPatient(new IdDt("1234"));
|
||||||
|
|
||||||
// Access the tag list
|
// Access the tag list
|
||||||
|
|
|
@ -43,7 +43,7 @@ ExtensionDt ext2 = new ExtensionDt(false, "http://examples.com#moreext", new Str
|
||||||
given.addUndeclaredExtension(ext2);
|
given.addUndeclaredExtension(ext2);
|
||||||
//END SNIPPET: resourceStringExtension
|
//END SNIPPET: resourceStringExtension
|
||||||
|
|
||||||
String output = new FhirContext().newXmlParser().setPrettyPrint(true).encodeResourceToString(patient);
|
String output = FhirContext.forDstu2().newXmlParser().setPrettyPrint(true).encodeResourceToString(patient);
|
||||||
System.out.println(output);
|
System.out.println(output);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ public class TagsExamples {
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public void getResourceTags() {
|
public void getResourceTags() {
|
||||||
// START SNIPPET: getResourceTags
|
// START SNIPPET: getResourceTags
|
||||||
IGenericClient client = new FhirContext().newRestfulGenericClient("http://fhir.healthintersections.com.au/open");
|
IGenericClient client = FhirContext.forDstu2().newRestfulGenericClient("http://fhir.healthintersections.com.au/open");
|
||||||
Patient p = client.read(Patient.class, "1");
|
Patient p = client.read(Patient.class, "1");
|
||||||
|
|
||||||
// Retrieve the list of tags from the resource metadata
|
// Retrieve the list of tags from the resource metadata
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class ValidatorExamples {
|
||||||
public void validateResource() {
|
public void validateResource() {
|
||||||
// START SNIPPET: basicValidation
|
// START SNIPPET: basicValidation
|
||||||
// As always, you need a context
|
// As always, you need a context
|
||||||
FhirContext ctx = new FhirContext();
|
FhirContext ctx = FhirContext.forDstu2();
|
||||||
|
|
||||||
// Create and populate a new patient object
|
// Create and populate a new patient object
|
||||||
Patient p = new Patient();
|
Patient p = new Patient();
|
||||||
|
@ -73,7 +73,7 @@ public class ValidatorExamples {
|
||||||
|
|
||||||
private static void validateFiles() throws Exception {
|
private static void validateFiles() throws Exception {
|
||||||
// START SNIPPET: validateFiles
|
// START SNIPPET: validateFiles
|
||||||
FhirContext ctx = new FhirContext();
|
FhirContext ctx = FhirContext.forDstu2();
|
||||||
|
|
||||||
// Create a validator and configure it
|
// Create a validator and configure it
|
||||||
FhirValidator validator = ctx.newValidator();
|
FhirValidator validator = ctx.newValidator();
|
||||||
|
|
|
@ -292,6 +292,7 @@ public abstract class BaseThymeleafNarrativeGenerator implements INarrativeGener
|
||||||
loadProperties(next);
|
loadProperties(next);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
ourLog.info("Failed to load property file " + propFileName, e);
|
||||||
throw new ConfigurationException("Can not load property file " + propFileName, e);
|
throw new ConfigurationException("Can not load property file " + propFileName, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -103,12 +103,18 @@ public class RestfulServer extends HttpServlet {
|
||||||
private boolean myUseBrowserFriendlyContentTypes;
|
private boolean myUseBrowserFriendlyContentTypes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor. Note that if no {@link FhirContext} is passed in to the server (either through the constructor, or
|
||||||
|
* through {@link #setFhirContext(FhirContext)}) the server will determine which version of FHIR to support
|
||||||
|
* through classpath scanning. This is brittle, and it is highly recommended to explicitly specify
|
||||||
|
* a FHIR version.
|
||||||
*/
|
*/
|
||||||
public RestfulServer() {
|
public RestfulServer() {
|
||||||
this(new FhirContext());
|
this(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
public RestfulServer(FhirContext theCtx) {
|
public RestfulServer(FhirContext theCtx) {
|
||||||
myFhirContext = theCtx;
|
myFhirContext = theCtx;
|
||||||
}
|
}
|
||||||
|
@ -200,7 +206,7 @@ public class RestfulServer extends HttpServlet {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for (Method m : ReflectionUtil.getDeclaredMethods(clazz)) {
|
for (Method m : ReflectionUtil.getDeclaredMethods(clazz)) {
|
||||||
BaseMethodBinding<?> foundMethodBinding = BaseMethodBinding.bindMethod(m, myFhirContext, theProvider);
|
BaseMethodBinding<?> foundMethodBinding = BaseMethodBinding.bindMethod(m, getFhirContext(), theProvider);
|
||||||
if (foundMethodBinding == null) {
|
if (foundMethodBinding == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -220,7 +226,7 @@ public class RestfulServer extends HttpServlet {
|
||||||
if (resourceName == null) {
|
if (resourceName == null) {
|
||||||
resourceBinding = myServerBinding;
|
resourceBinding = myServerBinding;
|
||||||
} else {
|
} else {
|
||||||
RuntimeResourceDefinition definition = myFhirContext.getResourceDefinition(resourceName);
|
RuntimeResourceDefinition definition = getFhirContext().getResourceDefinition(resourceName);
|
||||||
if (myResourceNameToProvider.containsKey(definition.getName())) {
|
if (myResourceNameToProvider.containsKey(definition.getName())) {
|
||||||
resourceBinding = myResourceNameToProvider.get(definition.getName());
|
resourceBinding = myResourceNameToProvider.get(definition.getName());
|
||||||
} else {
|
} else {
|
||||||
|
@ -270,7 +276,7 @@ public class RestfulServer extends HttpServlet {
|
||||||
if (Modifier.isPublic(m.getModifiers())) {
|
if (Modifier.isPublic(m.getModifiers())) {
|
||||||
ourLog.debug("Scanning public method: {}#{}", theSystemProvider.getClass(), m.getName());
|
ourLog.debug("Scanning public method: {}#{}", theSystemProvider.getClass(), m.getName());
|
||||||
|
|
||||||
BaseMethodBinding<?> foundMethodBinding = BaseMethodBinding.bindMethod(m, myFhirContext, theSystemProvider);
|
BaseMethodBinding<?> foundMethodBinding = BaseMethodBinding.bindMethod(m, getFhirContext(), theSystemProvider);
|
||||||
if (foundMethodBinding != null) {
|
if (foundMethodBinding != null) {
|
||||||
if (foundMethodBinding instanceof ConformanceMethodBinding) {
|
if (foundMethodBinding instanceof ConformanceMethodBinding) {
|
||||||
myServerConformanceMethod = foundMethodBinding;
|
myServerConformanceMethod = foundMethodBinding;
|
||||||
|
@ -318,6 +324,9 @@ public class RestfulServer extends HttpServlet {
|
||||||
* creating their own.
|
* creating their own.
|
||||||
*/
|
*/
|
||||||
public FhirContext getFhirContext() {
|
public FhirContext getFhirContext() {
|
||||||
|
if (myFhirContext == null) {
|
||||||
|
myFhirContext = new FhirContext();
|
||||||
|
}
|
||||||
return myFhirContext;
|
return myFhirContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,7 +428,7 @@ public class RestfulServer extends HttpServlet {
|
||||||
}
|
}
|
||||||
|
|
||||||
public IResourceProvider getServerProfilesProvider() {
|
public IResourceProvider getServerProfilesProvider() {
|
||||||
return myFhirContext.getVersion().createServerProfilesProvider(this);
|
return getFhirContext().getVersion().createServerProfilesProvider(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -462,7 +471,7 @@ public class RestfulServer extends HttpServlet {
|
||||||
NarrativeModeEnum narrativeMode = RestfulServerUtils.determineNarrativeMode(theRequest);
|
NarrativeModeEnum narrativeMode = RestfulServerUtils.determineNarrativeMode(theRequest);
|
||||||
boolean respondGzip = theRequest.isRespondGzip();
|
boolean respondGzip = theRequest.isRespondGzip();
|
||||||
|
|
||||||
IVersionSpecificBundleFactory bundleFactory = myFhirContext.newBundleFactory();
|
IVersionSpecificBundleFactory bundleFactory = getFhirContext().newBundleFactory();
|
||||||
|
|
||||||
Set<Include> includes = new HashSet<Include>();
|
Set<Include> includes = new HashSet<Include>();
|
||||||
String[] reqIncludes = theRequest.getServletRequest().getParameterValues(Constants.PARAM_INCLUDE);
|
String[] reqIncludes = theRequest.getServletRequest().getParameterValues(Constants.PARAM_INCLUDE);
|
||||||
|
@ -765,7 +774,7 @@ public class RestfulServer extends HttpServlet {
|
||||||
throw new NullPointerException("getResourceType() on class '" + nextProvider.getClass().getCanonicalName() + "' returned null");
|
throw new NullPointerException("getResourceType() on class '" + nextProvider.getClass().getCanonicalName() + "' returned null");
|
||||||
}
|
}
|
||||||
|
|
||||||
String resourceName = myFhirContext.getResourceDefinition(resourceType).getName();
|
String resourceName = getFhirContext().getResourceDefinition(resourceType).getName();
|
||||||
if (typeToProvider.containsKey(resourceName)) {
|
if (typeToProvider.containsKey(resourceName)) {
|
||||||
throw new ServletException("Multiple resource providers return resource type[" + resourceName + "]: First[" + typeToProvider.get(resourceName).getClass().getCanonicalName()
|
throw new ServletException("Multiple resource providers return resource type[" + resourceName + "]: First[" + typeToProvider.get(resourceName).getClass().getCanonicalName()
|
||||||
+ "] and Second[" + nextProvider.getClass().getCanonicalName() + "]");
|
+ "] and Second[" + nextProvider.getClass().getCanonicalName() + "]");
|
||||||
|
@ -792,7 +801,7 @@ public class RestfulServer extends HttpServlet {
|
||||||
|
|
||||||
Object confProvider = getServerConformanceProvider();
|
Object confProvider = getServerConformanceProvider();
|
||||||
if (confProvider == null) {
|
if (confProvider == null) {
|
||||||
confProvider = myFhirContext.getVersion().createServerConformanceProvider(this);
|
confProvider = getFhirContext().getVersion().createServerConformanceProvider(this);
|
||||||
}
|
}
|
||||||
findSystemMethods(confProvider);
|
findSystemMethods(confProvider);
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class ResourceProviderDstu1Test {
|
||||||
private static ClassPathXmlApplicationContext ourAppCtx;
|
private static ClassPathXmlApplicationContext ourAppCtx;
|
||||||
private static IGenericClient ourClient;
|
private static IGenericClient ourClient;
|
||||||
private static DaoConfig ourDaoConfig;
|
private static DaoConfig ourDaoConfig;
|
||||||
private static FhirContext ourFhirCtx;
|
private static FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceProviderDstu1Test.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceProviderDstu1Test.class);
|
||||||
private static IFhirResourceDao<Organization> ourOrganizationDao;
|
private static IFhirResourceDao<Organization> ourOrganizationDao;
|
||||||
// private static IFhirResourceDao<Observation> ourObservationDao;
|
// private static IFhirResourceDao<Observation> ourObservationDao;
|
||||||
|
@ -405,14 +405,14 @@ public class ResourceProviderDstu1Test {
|
||||||
// Read back directly from the DAO
|
// Read back directly from the DAO
|
||||||
{
|
{
|
||||||
Organization returned = ourOrganizationDao.read(orgId);
|
Organization returned = ourOrganizationDao.read(orgId);
|
||||||
String val = ourFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned);
|
String val = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned);
|
||||||
ourLog.info(val);
|
ourLog.info(val);
|
||||||
assertThat(val, containsString("<name value=\"測試醫院\"/>"));
|
assertThat(val, containsString("<name value=\"測試醫院\"/>"));
|
||||||
}
|
}
|
||||||
// Read back through the HTTP API
|
// Read back through the HTTP API
|
||||||
{
|
{
|
||||||
Organization returned = ourClient.read(Organization.class, orgId);
|
Organization returned = ourClient.read(Organization.class, orgId);
|
||||||
String val = ourFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned);
|
String val = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned);
|
||||||
ourLog.info(val);
|
ourLog.info(val);
|
||||||
assertThat(val, containsString("<name value=\"測試醫院\"/>"));
|
assertThat(val, containsString("<name value=\"測試醫院\"/>"));
|
||||||
}
|
}
|
||||||
|
@ -492,9 +492,7 @@ public class ResourceProviderDstu1Test {
|
||||||
public static void beforeClass() throws Exception {
|
public static void beforeClass() throws Exception {
|
||||||
int port = RandomServerPortProvider.findFreePort();
|
int port = RandomServerPortProvider.findFreePort();
|
||||||
|
|
||||||
RestfulServer restServer = new RestfulServer();
|
RestfulServer restServer = new RestfulServer(ourCtx);
|
||||||
ourFhirCtx = FhirContext.forDstu1();
|
|
||||||
restServer.setFhirContext(ourFhirCtx);
|
|
||||||
|
|
||||||
String serverBase = "http://localhost:" + port + "/fhir/context";
|
String serverBase = "http://localhost:" + port + "/fhir/context";
|
||||||
|
|
||||||
|
@ -526,7 +524,7 @@ public class ResourceProviderDstu1Test {
|
||||||
ourServer.setHandler(proxyHandler);
|
ourServer.setHandler(proxyHandler);
|
||||||
ourServer.start();
|
ourServer.start();
|
||||||
|
|
||||||
ourClient = ourFhirCtx.newRestfulGenericClient(serverBase);
|
ourClient = ourCtx.newRestfulGenericClient(serverBase);
|
||||||
ourClient.registerInterceptor(new LoggingInterceptor(true));
|
ourClient.registerInterceptor(new LoggingInterceptor(true));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,7 @@ public class ResourceProviderDstu2Test {
|
||||||
private static ClassPathXmlApplicationContext ourAppCtx;
|
private static ClassPathXmlApplicationContext ourAppCtx;
|
||||||
private static IGenericClient ourClient;
|
private static IGenericClient ourClient;
|
||||||
private static DaoConfig ourDaoConfig;
|
private static DaoConfig ourDaoConfig;
|
||||||
private static FhirContext ourFhirCtx;
|
private static FhirContext ourCtx = FhirContext.forDstu2();
|
||||||
private static CloseableHttpClient ourHttpClient;
|
private static CloseableHttpClient ourHttpClient;
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceProviderDstu2Test.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceProviderDstu2Test.class);
|
||||||
private static IFhirResourceDao<Organization> ourOrganizationDao;
|
private static IFhirResourceDao<Organization> ourOrganizationDao;
|
||||||
|
@ -148,7 +148,7 @@ public class ResourceProviderDstu2Test {
|
||||||
|
|
||||||
ca.uhn.fhir.model.dstu2.resource.Bundle bundle = client.read().resource(ca.uhn.fhir.model.dstu2.resource.Bundle.class).withId(id).execute();
|
ca.uhn.fhir.model.dstu2.resource.Bundle bundle = client.read().resource(ca.uhn.fhir.model.dstu2.resource.Bundle.class).withId(id).execute();
|
||||||
|
|
||||||
ourLog.info(ourFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle));
|
ourLog.info(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -194,7 +194,7 @@ public class ResourceProviderDstu2Test {
|
||||||
|
|
||||||
Patient pt = new Patient();
|
Patient pt = new Patient();
|
||||||
pt.addName().addFamily(methodName);
|
pt.addName().addFamily(methodName);
|
||||||
String resource = ourFhirCtx.newXmlParser().encodeResourceToString(pt);
|
String resource = ourCtx.newXmlParser().encodeResourceToString(pt);
|
||||||
|
|
||||||
HttpPost post = new HttpPost(ourServerBase + "/Patient");
|
HttpPost post = new HttpPost(ourServerBase + "/Patient");
|
||||||
post.addHeader(Constants.HEADER_IF_NONE_EXIST, "Patient?name=" + methodName);
|
post.addHeader(Constants.HEADER_IF_NONE_EXIST, "Patient?name=" + methodName);
|
||||||
|
@ -284,7 +284,7 @@ public class ResourceProviderDstu2Test {
|
||||||
|
|
||||||
Patient pt = new Patient();
|
Patient pt = new Patient();
|
||||||
pt.addName().addFamily(methodName);
|
pt.addName().addFamily(methodName);
|
||||||
String resource = ourFhirCtx.newXmlParser().encodeResourceToString(pt);
|
String resource = ourCtx.newXmlParser().encodeResourceToString(pt);
|
||||||
|
|
||||||
HttpPost post = new HttpPost(ourServerBase + "/Patient");
|
HttpPost post = new HttpPost(ourServerBase + "/Patient");
|
||||||
post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||||
|
@ -328,7 +328,7 @@ public class ResourceProviderDstu2Test {
|
||||||
Patient pt = new Patient();
|
Patient pt = new Patient();
|
||||||
pt.addName().addFamily(methodName);
|
pt.addName().addFamily(methodName);
|
||||||
pt.addIdentifier().setSystem("http://ghh.org/patient").setValue(methodName);
|
pt.addIdentifier().setSystem("http://ghh.org/patient").setValue(methodName);
|
||||||
String resource = ourFhirCtx.newXmlParser().encodeResourceToString(pt);
|
String resource = ourCtx.newXmlParser().encodeResourceToString(pt);
|
||||||
|
|
||||||
HttpPost post = new HttpPost(ourServerBase + "/Patient");
|
HttpPost post = new HttpPost(ourServerBase + "/Patient");
|
||||||
post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||||
|
@ -409,8 +409,8 @@ public class ResourceProviderDstu2Test {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testDocumentManifestResources() throws Exception {
|
public void testDocumentManifestResources() throws Exception {
|
||||||
ourFhirCtx.getResourceDefinition(Practitioner.class);
|
ourCtx.getResourceDefinition(Practitioner.class);
|
||||||
ourFhirCtx.getResourceDefinition(ca.uhn.fhir.model.dstu.resource.DocumentManifest.class);
|
ourCtx.getResourceDefinition(ca.uhn.fhir.model.dstu.resource.DocumentManifest.class);
|
||||||
|
|
||||||
IGenericClient client = ourClient;
|
IGenericClient client = ourClient;
|
||||||
|
|
||||||
|
@ -449,7 +449,7 @@ public class ResourceProviderDstu2Test {
|
||||||
@Test
|
@Test
|
||||||
public void testEverythingDoesntRepeatPatient() throws Exception {
|
public void testEverythingDoesntRepeatPatient() throws Exception {
|
||||||
ca.uhn.fhir.model.dstu2.resource.Bundle b;
|
ca.uhn.fhir.model.dstu2.resource.Bundle b;
|
||||||
b = ourFhirCtx.newJsonParser().parseResource(ca.uhn.fhir.model.dstu2.resource.Bundle.class, new InputStreamReader(ResourceProviderDstu2Test.class.getResourceAsStream("/bug147-bundle.json")));
|
b = ourCtx.newJsonParser().parseResource(ca.uhn.fhir.model.dstu2.resource.Bundle.class, new InputStreamReader(ResourceProviderDstu2Test.class.getResourceAsStream("/bug147-bundle.json")));
|
||||||
|
|
||||||
ca.uhn.fhir.model.dstu2.resource.Bundle resp = ourClient.transaction().withBundle(b).execute();
|
ca.uhn.fhir.model.dstu2.resource.Bundle resp = ourClient.transaction().withBundle(b).execute();
|
||||||
List<IdDt> ids = new ArrayList<IdDt>();
|
List<IdDt> ids = new ArrayList<IdDt>();
|
||||||
|
@ -518,7 +518,7 @@ public class ResourceProviderDstu2Test {
|
||||||
|
|
||||||
ca.uhn.fhir.model.dstu2.resource.Bundle resp = ourClient.transaction().withBundle(b).execute();
|
ca.uhn.fhir.model.dstu2.resource.Bundle resp = ourClient.transaction().withBundle(b).execute();
|
||||||
|
|
||||||
ourLog.info(ourFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp));
|
ourLog.info(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp));
|
||||||
|
|
||||||
IdDt patientId = new IdDt(resp.getEntry().get(1).getTransactionResponse().getLocation());
|
IdDt patientId = new IdDt(resp.getEntry().get(1).getTransactionResponse().getLocation());
|
||||||
assertEquals("Patient", patientId.getResourceType());
|
assertEquals("Patient", patientId.getResourceType());
|
||||||
|
@ -874,14 +874,14 @@ public class ResourceProviderDstu2Test {
|
||||||
// Read back directly from the DAO
|
// Read back directly from the DAO
|
||||||
{
|
{
|
||||||
Organization returned = ourOrganizationDao.read(orgId);
|
Organization returned = ourOrganizationDao.read(orgId);
|
||||||
String val = ourFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned);
|
String val = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned);
|
||||||
ourLog.info(val);
|
ourLog.info(val);
|
||||||
assertThat(val, containsString("<name value=\"測試醫院\"/>"));
|
assertThat(val, containsString("<name value=\"測試醫院\"/>"));
|
||||||
}
|
}
|
||||||
// Read back through the HTTP API
|
// Read back through the HTTP API
|
||||||
{
|
{
|
||||||
Organization returned = ourClient.read(Organization.class, orgId);
|
Organization returned = ourClient.read(Organization.class, orgId);
|
||||||
String val = ourFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned);
|
String val = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned);
|
||||||
ourLog.info(val);
|
ourLog.info(val);
|
||||||
assertThat(val, containsString("<name value=\"測試醫院\"/>"));
|
assertThat(val, containsString("<name value=\"測試醫院\"/>"));
|
||||||
}
|
}
|
||||||
|
@ -938,7 +938,7 @@ public class ResourceProviderDstu2Test {
|
||||||
|
|
||||||
Patient pt = new Patient();
|
Patient pt = new Patient();
|
||||||
pt.addName().addFamily(methodName);
|
pt.addName().addFamily(methodName);
|
||||||
String resource = ourFhirCtx.newXmlParser().encodeResourceToString(pt);
|
String resource = ourCtx.newXmlParser().encodeResourceToString(pt);
|
||||||
|
|
||||||
HttpPost post = new HttpPost(ourServerBase + "/Patient?name=" + methodName);
|
HttpPost post = new HttpPost(ourServerBase + "/Patient?name=" + methodName);
|
||||||
post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||||
|
@ -996,7 +996,7 @@ public class ResourceProviderDstu2Test {
|
||||||
Parameters input = new Parameters();
|
Parameters input = new Parameters();
|
||||||
input.addParameter().setName("resource").setResource(patient);
|
input.addParameter().setName("resource").setResource(patient);
|
||||||
|
|
||||||
String inputStr = ourFhirCtx.newXmlParser().encodeResourceToString(input);
|
String inputStr = ourCtx.newXmlParser().encodeResourceToString(input);
|
||||||
ourLog.info(inputStr);
|
ourLog.info(inputStr);
|
||||||
|
|
||||||
HttpPost post = new HttpPost(ourServerBase + "/Patient/$validate");
|
HttpPost post = new HttpPost(ourServerBase + "/Patient/$validate");
|
||||||
|
@ -1024,7 +1024,7 @@ public class ResourceProviderDstu2Test {
|
||||||
Parameters input = new Parameters();
|
Parameters input = new Parameters();
|
||||||
input.addParameter().setName("resource").setResource(patient);
|
input.addParameter().setName("resource").setResource(patient);
|
||||||
|
|
||||||
String inputStr = ourFhirCtx.newXmlParser().encodeResourceToString(input);
|
String inputStr = ourCtx.newXmlParser().encodeResourceToString(input);
|
||||||
ourLog.info(inputStr);
|
ourLog.info(inputStr);
|
||||||
|
|
||||||
HttpPost post = new HttpPost(ourServerBase + "/Patient/$validate");
|
HttpPost post = new HttpPost(ourServerBase + "/Patient/$validate");
|
||||||
|
@ -1061,9 +1061,8 @@ public class ResourceProviderDstu2Test {
|
||||||
public static void beforeClass() throws Exception {
|
public static void beforeClass() throws Exception {
|
||||||
ourPort = RandomServerPortProvider.findFreePort();
|
ourPort = RandomServerPortProvider.findFreePort();
|
||||||
|
|
||||||
RestfulServer restServer = new RestfulServer();
|
RestfulServer restServer = new RestfulServer(ourCtx);
|
||||||
ourFhirCtx = FhirContext.forDstu2();
|
restServer.setFhirContext(ourCtx);
|
||||||
restServer.setFhirContext(ourFhirCtx);
|
|
||||||
|
|
||||||
ourServerBase = "http://localhost:" + ourPort + "/fhir/context";
|
ourServerBase = "http://localhost:" + ourPort + "/fhir/context";
|
||||||
|
|
||||||
|
@ -1095,9 +1094,9 @@ public class ResourceProviderDstu2Test {
|
||||||
ourServer.setHandler(proxyHandler);
|
ourServer.setHandler(proxyHandler);
|
||||||
ourServer.start();
|
ourServer.start();
|
||||||
|
|
||||||
ourFhirCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
|
ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
|
||||||
ourFhirCtx.getRestfulClientFactory().setSocketTimeout(1200 * 1000);
|
ourCtx.getRestfulClientFactory().setSocketTimeout(1200 * 1000);
|
||||||
ourClient = ourFhirCtx.newRestfulGenericClient(ourServerBase);
|
ourClient = ourCtx.newRestfulGenericClient(ourServerBase);
|
||||||
// ourClient.registerInterceptor(new LoggingInterceptor(true));
|
// ourClient.registerInterceptor(new LoggingInterceptor(true));
|
||||||
|
|
||||||
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
|
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
|
||||||
|
|
|
@ -139,8 +139,7 @@ public class ResourceProviderMultiVersionTest {
|
||||||
* DEV resources
|
* DEV resources
|
||||||
*/
|
*/
|
||||||
|
|
||||||
RestfulServer restServerDstu2 = new RestfulServer();
|
RestfulServer restServerDstu2 = new RestfulServer(ourAppCtx.getBean("myFhirContextDstu2", FhirContext.class));
|
||||||
restServerDstu2.setFhirContext(ourAppCtx.getBean("myFhirContextDstu2", FhirContext.class));
|
|
||||||
List<IResourceProvider> rpsDstu2 = (List<IResourceProvider>) ourAppCtx.getBean("myResourceProvidersDstu2", List.class);
|
List<IResourceProvider> rpsDstu2 = (List<IResourceProvider>) ourAppCtx.getBean("myResourceProvidersDstu2", List.class);
|
||||||
restServerDstu2.setResourceProviders(rpsDstu2);
|
restServerDstu2.setResourceProviders(rpsDstu2);
|
||||||
|
|
||||||
|
@ -155,8 +154,7 @@ public class ResourceProviderMultiVersionTest {
|
||||||
* DSTU resources
|
* DSTU resources
|
||||||
*/
|
*/
|
||||||
|
|
||||||
RestfulServer restServerDstu1 = new RestfulServer();
|
RestfulServer restServerDstu1 = new RestfulServer(ourAppCtx.getBean("myFhirContextDstu1", FhirContext.class));
|
||||||
restServerDstu1.setFhirContext(ourAppCtx.getBean("myFhirContextDstu1", FhirContext.class));
|
|
||||||
List<IResourceProvider> rpsDstu1 = (List<IResourceProvider>) ourAppCtx.getBean("myResourceProvidersDstu1", List.class);
|
List<IResourceProvider> rpsDstu1 = (List<IResourceProvider>) ourAppCtx.getBean("myResourceProvidersDstu1", List.class);
|
||||||
restServerDstu1.setResourceProviders(rpsDstu1);
|
restServerDstu1.setResourceProviders(rpsDstu1);
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class SystemProviderDstu1Test {
|
||||||
OrganizationResourceProvider organizationRp = new OrganizationResourceProvider();
|
OrganizationResourceProvider organizationRp = new OrganizationResourceProvider();
|
||||||
organizationRp.setDao(organizationDao);
|
organizationRp.setDao(organizationDao);
|
||||||
|
|
||||||
RestfulServer restServer = new RestfulServer();
|
RestfulServer restServer = new RestfulServer(ourCtx);
|
||||||
restServer.setResourceProviders(patientRp, questionnaireRp, observationRp, organizationRp);
|
restServer.setResourceProviders(patientRp, questionnaireRp, observationRp, organizationRp);
|
||||||
|
|
||||||
JpaSystemProviderDstu1 systemProv = ourAppCtx.getBean(JpaSystemProviderDstu1.class, "mySystemProviderDstu1");
|
JpaSystemProviderDstu1 systemProv = ourAppCtx.getBean(JpaSystemProviderDstu1.class, "mySystemProviderDstu1");
|
||||||
|
|
|
@ -122,7 +122,7 @@ public class SystemProviderDstu2Test {
|
||||||
OrganizationResourceProvider organizationRp = new OrganizationResourceProvider();
|
OrganizationResourceProvider organizationRp = new OrganizationResourceProvider();
|
||||||
organizationRp.setDao(organizationDao);
|
organizationRp.setDao(organizationDao);
|
||||||
|
|
||||||
RestfulServer restServer = new RestfulServer();
|
RestfulServer restServer = new RestfulServer(ourCtx);
|
||||||
restServer.setResourceProviders(patientRp, questionnaireRp, observationRp, organizationRp);
|
restServer.setResourceProviders(patientRp, questionnaireRp, observationRp, organizationRp);
|
||||||
|
|
||||||
JpaSystemProviderDstu2 systemProv = ourAppCtx.getBean(JpaSystemProviderDstu2.class, "mySystemProviderDstu2");
|
JpaSystemProviderDstu2 systemProv = ourAppCtx.getBean(JpaSystemProviderDstu2.class, "mySystemProviderDstu2");
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<appender-ref ref="STDOUT" />
|
<appender-ref ref="STDOUT" />
|
||||||
</logger>
|
</logger>
|
||||||
|
|
||||||
<logger name="ca.uhn.fhir.jpa.dao" additivity="false" level="debug">
|
<logger name="ca.uhn.fhir.jpa.dao" additivity="false" level="info">
|
||||||
<appender-ref ref="STDOUT" />
|
<appender-ref ref="STDOUT" />
|
||||||
</logger>
|
</logger>
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,10 @@ import ca.uhn.fhir.context.FhirContext;
|
||||||
|
|
||||||
public class FhirContextFactory implements FactoryBean<FhirContext>, InitializingBean {
|
public class FhirContextFactory implements FactoryBean<FhirContext>, InitializingBean {
|
||||||
|
|
||||||
private int myConnectionRequestTimeout = 5000;
|
private int myConnectionRequestTimeout = 5000;
|
||||||
private int mySocketTimeout = 10000;
|
private int mySocketTimeout = 10000;
|
||||||
private int myConnectTimeout = 4000;
|
private int myConnectTimeout = 4000;
|
||||||
|
|
||||||
public int getConnectionRequestTimeout() {
|
public int getConnectionRequestTimeout() {
|
||||||
return myConnectionRequestTimeout;
|
return myConnectionRequestTimeout;
|
||||||
}
|
}
|
||||||
|
@ -36,7 +37,7 @@ public class FhirContextFactory implements FactoryBean<FhirContext>, Initializin
|
||||||
|
|
||||||
private FhirContext myCtx;
|
private FhirContext myCtx;
|
||||||
|
|
||||||
public FhirContextFactory() {
|
public FhirContextFactory() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -56,7 +57,7 @@ public class FhirContextFactory implements FactoryBean<FhirContext>, Initializin
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterPropertiesSet() throws Exception {
|
public void afterPropertiesSet() throws Exception {
|
||||||
myCtx=new FhirContext();
|
myCtx = new FhirContext();
|
||||||
myCtx.getRestfulClientFactory().setConnectTimeout(myConnectTimeout);
|
myCtx.getRestfulClientFactory().setConnectTimeout(myConnectTimeout);
|
||||||
myCtx.getRestfulClientFactory().setSocketTimeout(mySocketTimeout);
|
myCtx.getRestfulClientFactory().setSocketTimeout(mySocketTimeout);
|
||||||
myCtx.getRestfulClientFactory().setConnectionRequestTimeout(myConnectionRequestTimeout);
|
myCtx.getRestfulClientFactory().setConnectionRequestTimeout(myConnectionRequestTimeout);
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
package ca.uhn.fhir;
|
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
|
||||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
|
||||||
|
|
||||||
public class Dstu1EnvTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCorrectDefault() {
|
|
||||||
FhirContext ctx = new FhirContext();
|
|
||||||
assertEquals("new FhirContext() is creating a context with the wrong FHIR versions. Something is probably wrong with the classpath.", FhirVersionEnum.DSTU1, ctx.getVersion().getVersion());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -23,7 +23,7 @@ public class DuplicateExtensionTest extends TestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testScannerShouldAddProvidedResources() {
|
public void testScannerShouldAddProvidedResources() {
|
||||||
FhirContext ctx = new FhirContext();
|
FhirContext ctx = FhirContext.forDstu1();
|
||||||
RuntimeResourceDefinition patientDef = ctx.getResourceDefinition(CustomPatient.class);
|
RuntimeResourceDefinition patientDef = ctx.getResourceDefinition(CustomPatient.class);
|
||||||
Profile profile = (Profile) patientDef.toProfile("http://foo.org/fhir");
|
Profile profile = (Profile) patientDef.toProfile("http://foo.org/fhir");
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ import ca.uhn.fhir.parser.MyPatient;
|
||||||
public class ExtensionTest {
|
public class ExtensionTest {
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExtensionTest.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExtensionTest.class);
|
||||||
|
|
||||||
private static FhirContext ourCtx = new FhirContext();
|
private static FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExtensionType() {
|
public void testExtensionType() {
|
||||||
|
@ -66,19 +66,19 @@ public class ExtensionTest {
|
||||||
|
|
||||||
patient.addName().addFamily("Smith").addGiven("John").addGiven("Quincy").addSuffix("Jr");
|
patient.addName().addFamily("Smith").addGiven("John").addGiven("Quincy").addSuffix("Jr");
|
||||||
|
|
||||||
IParser p = new FhirContext().newXmlParser().setPrettyPrint(true);
|
IParser p = FhirContext.forDstu1().newXmlParser().setPrettyPrint(true);
|
||||||
String messageString = p.encodeResourceToString(patient);
|
String messageString = p.encodeResourceToString(patient);
|
||||||
|
|
||||||
System.out.println(messageString);
|
System.out.println(messageString);
|
||||||
// END SNIPPET: patientUse
|
// END SNIPPET: patientUse
|
||||||
|
|
||||||
// START SNIPPET: patientParse
|
// START SNIPPET: patientParse
|
||||||
IParser parser = new FhirContext().newXmlParser();
|
IParser parser = FhirContext.forDstu1().newXmlParser();
|
||||||
MyPatient newPatient = parser.parseResource(MyPatient.class, messageString);
|
MyPatient newPatient = parser.parseResource(MyPatient.class, messageString);
|
||||||
// END SNIPPET: patientParse
|
// END SNIPPET: patientParse
|
||||||
|
|
||||||
{
|
{
|
||||||
FhirContext ctx2 = new FhirContext();
|
FhirContext ctx2 = FhirContext.forDstu1();
|
||||||
RuntimeResourceDefinition def = ctx2.getResourceDefinition(patient);
|
RuntimeResourceDefinition def = ctx2.getResourceDefinition(patient);
|
||||||
System.out.println(ctx2.newXmlParser().setPrettyPrint(true).encodeResourceToString(def.toProfile("http://foo.org/fhir")));
|
System.out.println(ctx2.newXmlParser().setPrettyPrint(true).encodeResourceToString(def.toProfile("http://foo.org/fhir")));
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,11 +9,11 @@ import ca.uhn.fhir.model.api.IResource;
|
||||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||||
import ca.uhn.fhir.model.dstu.resource.ValueSet;
|
import ca.uhn.fhir.model.dstu.resource.ValueSet;
|
||||||
|
|
||||||
public class FhirContextTest {
|
public class FhirContextDstu1Test {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIncrementalScan() {
|
public void testIncrementalScan() {
|
||||||
FhirContext ctx = new FhirContext();
|
FhirContext ctx = FhirContext.forDstu1();
|
||||||
RuntimeResourceDefinition vsDef = ctx.getResourceDefinition(ValueSet.class);
|
RuntimeResourceDefinition vsDef = ctx.getResourceDefinition(ValueSet.class);
|
||||||
RuntimeResourceDefinition ptDef = ctx.getResourceDefinition(Patient.class);
|
RuntimeResourceDefinition ptDef = ctx.getResourceDefinition(Patient.class);
|
||||||
assertNotNull(ptDef);
|
assertNotNull(ptDef);
|
||||||
|
@ -24,13 +24,13 @@ public class FhirContextTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFindBinary() {
|
public void testFindBinary() {
|
||||||
RuntimeResourceDefinition def = new FhirContext().getResourceDefinition("Binary");
|
RuntimeResourceDefinition def = FhirContext.forDstu1().getResourceDefinition("Binary");
|
||||||
assertEquals("Binary", def.getName());
|
assertEquals("Binary", def.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
public void testGetResourceDefinitionFails() {
|
public void testGetResourceDefinitionFails() {
|
||||||
new FhirContext().getResourceDefinition(IResource.class);
|
FhirContext.forDstu1().getResourceDefinition(IResource.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
|
@ -10,7 +10,7 @@ import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||||
|
|
||||||
public class InvalidResourceTypeTest {
|
public class InvalidResourceTypeTest {
|
||||||
|
|
||||||
private static FhirContext ourCtx = new FhirContext();
|
private static FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNonInstantiableType() {
|
public void testNonInstantiableType() {
|
||||||
|
|
|
@ -11,7 +11,7 @@ import ca.uhn.fhir.parser.MyPatient;
|
||||||
|
|
||||||
public class ModelExtensionTest {
|
public class ModelExtensionTest {
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ModelExtensionTest.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ModelExtensionTest.class);
|
||||||
private FhirContext ourCtx = new FhirContext();
|
private FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testModelExtension() throws DataFormatException {
|
public void testModelExtension() throws DataFormatException {
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class ModelScannerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExtendedClass() {
|
public void testExtendedClass() {
|
||||||
FhirContext ctx = new FhirContext();
|
FhirContext ctx = FhirContext.forDstu1();
|
||||||
ctx.getResourceDefinition(MyPatient.class);
|
ctx.getResourceDefinition(MyPatient.class);
|
||||||
|
|
||||||
RuntimeResourceDefinition patient = ctx.getResourceDefinition("Patient");
|
RuntimeResourceDefinition patient = ctx.getResourceDefinition("Patient");
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class NameChanges {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Test
|
@Test
|
||||||
public void testNameChanges() throws IOException, ClassNotFoundException {
|
public void testNameChanges() throws IOException, ClassNotFoundException {
|
||||||
FhirContext ctx = new FhirContext();
|
FhirContext ctx = FhirContext.forDstu1();
|
||||||
ImmutableSet<ClassInfo> names = ClassPath.from(getClass().getClassLoader()).getTopLevelClasses(Patient.class.getPackage().getName());
|
ImmutableSet<ClassInfo> names = ClassPath.from(getClass().getClassLoader()).getTopLevelClasses(Patient.class.getPackage().getName());
|
||||||
List<String> changes = new ArrayList<String>();
|
List<String> changes = new ArrayList<String>();
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ import static org.junit.Assert.assertNull;
|
||||||
public class ProvidedResourceScannerTest extends TestCase {
|
public class ProvidedResourceScannerTest extends TestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testScannerShouldAddProvidedResources() {
|
public void testScannerShouldAddProvidedResources() {
|
||||||
FhirContext ctx = new FhirContext();
|
FhirContext ctx = FhirContext.forDstu1();
|
||||||
assertEquals(CustomPatient.class, ctx.getElementDefinition(CustomPatient.class).getImplementingClass());
|
assertEquals(CustomPatient.class, ctx.getElementDefinition(CustomPatient.class).getImplementingClass());
|
||||||
assertEquals(Patient.class, ctx.getResourceDefinition("Patient").getImplementingClass());
|
assertEquals(Patient.class, ctx.getResourceDefinition("Patient").getImplementingClass());
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||||
|
|
||||||
public class TagListTest {
|
public class TagListTest {
|
||||||
|
|
||||||
private FhirContext myCtx = new FhirContext();
|
private FhirContext myCtx = FhirContext.forDstu1();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEquals() {
|
public void testEquals() {
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class BaseDateTimeDtTest {
|
||||||
private FastDateFormat myDateInstantZoneParser;
|
private FastDateFormat myDateInstantZoneParser;
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseDateTimeDtTest.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseDateTimeDtTest.class);
|
||||||
|
|
||||||
private static FhirContext ourCtx = new FhirContext();
|
private static FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void before() {
|
public void before() {
|
||||||
|
|
|
@ -206,7 +206,7 @@ public class IdDtTest {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void beforeClass() {
|
public static void beforeClass() {
|
||||||
ourCtx = new FhirContext();
|
ourCtx = FhirContext.forDstu1();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ import ca.uhn.fhir.parser.IParser;
|
||||||
|
|
||||||
public class ViewGeneratorTest {
|
public class ViewGeneratorTest {
|
||||||
|
|
||||||
private static FhirContext ourCtx = new FhirContext();
|
private static FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testView() {
|
public void testView() {
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class DefaultThymeleafNarrativeGeneratorTest {
|
||||||
gen.setIgnoreFailures(false);
|
gen.setIgnoreFailures(false);
|
||||||
gen.setIgnoreMissingTemplates(false);
|
gen.setIgnoreMissingTemplates(false);
|
||||||
|
|
||||||
myCtx = new FhirContext();
|
myCtx = FhirContext.forDstu1();
|
||||||
myCtx.setNarrativeGenerator(gen);
|
myCtx.setNarrativeGenerator(gen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ import ca.uhn.fhir.model.dstu.resource.Composition;
|
||||||
|
|
||||||
public class BaseParserTest {
|
public class BaseParserTest {
|
||||||
|
|
||||||
private static final FhirContext ourCtx = new FhirContext();
|
private static final FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
|
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseParserTest.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseParserTest.class);
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class ContainedResourceEncodingTest {
|
||||||
initPatient();
|
initPatient();
|
||||||
initAuthor();
|
initAuthor();
|
||||||
initComposition();
|
initComposition();
|
||||||
this.ctx = new FhirContext();
|
this.ctx = FhirContext.forDstu1();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.hamcrest.core.IsNot;
|
||||||
import org.hamcrest.core.StringContains;
|
import org.hamcrest.core.StringContains;
|
||||||
import org.hamcrest.text.StringContainsInOrder;
|
import org.hamcrest.text.StringContainsInOrder;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -294,13 +295,13 @@ public class JsonParserTest {
|
||||||
e.setResource(new Patient());
|
e.setResource(new Patient());
|
||||||
b.addCategory("scheme", "term", "label");
|
b.addCategory("scheme", "term", "label");
|
||||||
|
|
||||||
String val = new FhirContext().newJsonParser().setPrettyPrint(false).encodeBundleToString(b);
|
String val = ourCtx.newJsonParser().setPrettyPrint(false).encodeBundleToString(b);
|
||||||
ourLog.info(val);
|
ourLog.info(val);
|
||||||
|
|
||||||
assertThat(val, StringContains.containsString("\"category\":[{\"term\":\"term\",\"label\":\"label\",\"scheme\":\"scheme\"}]"));
|
assertThat(val, StringContains.containsString("\"category\":[{\"term\":\"term\",\"label\":\"label\",\"scheme\":\"scheme\"}]"));
|
||||||
assertThat(val, not(containsString("text")));
|
assertThat(val, not(containsString("text")));
|
||||||
|
|
||||||
b = new FhirContext().newJsonParser().parseBundle(val);
|
b = ourCtx.newJsonParser().parseBundle(val);
|
||||||
assertEquals(1, b.getEntries().size());
|
assertEquals(1, b.getEntries().size());
|
||||||
assertEquals(1, b.getCategories().size());
|
assertEquals(1, b.getCategories().size());
|
||||||
assertEquals("term", b.getCategories().get(0).getTerm());
|
assertEquals("term", b.getCategories().get(0).getTerm());
|
||||||
|
@ -489,7 +490,7 @@ public class JsonParserTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEncodeDeclaredExtensionWithAddressContent() {
|
public void testEncodeDeclaredExtensionWithAddressContent() {
|
||||||
IParser parser = new FhirContext().newJsonParser();
|
IParser parser = ourCtx.newJsonParser();
|
||||||
|
|
||||||
MyPatientWithOneDeclaredAddressExtension patient = new MyPatientWithOneDeclaredAddressExtension();
|
MyPatientWithOneDeclaredAddressExtension patient = new MyPatientWithOneDeclaredAddressExtension();
|
||||||
patient.addAddress().setUse(AddressUseEnum.HOME);
|
patient.addAddress().setUse(AddressUseEnum.HOME);
|
||||||
|
@ -508,7 +509,7 @@ public class JsonParserTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEncodeDeclaredExtensionWithResourceContent() {
|
public void testEncodeDeclaredExtensionWithResourceContent() {
|
||||||
IParser parser = new FhirContext().newJsonParser();
|
IParser parser = ourCtx.newJsonParser();
|
||||||
|
|
||||||
MyPatientWithOneDeclaredExtension patient = new MyPatientWithOneDeclaredExtension();
|
MyPatientWithOneDeclaredExtension patient = new MyPatientWithOneDeclaredExtension();
|
||||||
patient.addAddress().setUse(AddressUseEnum.HOME);
|
patient.addAddress().setUse(AddressUseEnum.HOME);
|
||||||
|
@ -620,7 +621,7 @@ public class JsonParserTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEncodeExtensionWithResourceContent() {
|
public void testEncodeExtensionWithResourceContent() {
|
||||||
IParser parser = new FhirContext().newJsonParser();
|
IParser parser = ourCtx.newJsonParser();
|
||||||
|
|
||||||
Patient patient = new Patient();
|
Patient patient = new Patient();
|
||||||
patient.addAddress().setUse(AddressUseEnum.HOME);
|
patient.addAddress().setUse(AddressUseEnum.HOME);
|
||||||
|
@ -751,7 +752,7 @@ public class JsonParserTest {
|
||||||
ExtensionDt parameter = q.addParameter();
|
ExtensionDt parameter = q.addParameter();
|
||||||
parameter.setUrl("http://hl7.org/fhir/query#_query").setValue(new StringDt("example"));
|
parameter.setUrl("http://hl7.org/fhir/query#_query").setValue(new StringDt("example"));
|
||||||
|
|
||||||
String val = new FhirContext().newJsonParser().encodeResourceToString(q);
|
String val = ourCtx.newJsonParser().encodeResourceToString(q);
|
||||||
ourLog.info(val);
|
ourLog.info(val);
|
||||||
|
|
||||||
//@formatter:off
|
//@formatter:off
|
||||||
|
@ -779,7 +780,7 @@ public class JsonParserTest {
|
||||||
Patient patient = new Patient();
|
Patient patient = new Patient();
|
||||||
patient.setManagingOrganization(new ResourceReferenceDt());
|
patient.setManagingOrganization(new ResourceReferenceDt());
|
||||||
|
|
||||||
IParser p = new FhirContext().newJsonParser();
|
IParser p = ourCtx.newJsonParser();
|
||||||
String str = p.encodeResourceToString(patient);
|
String str = p.encodeResourceToString(patient);
|
||||||
assertThat(str, IsNot.not(StringContains.containsString("managingOrganization")));
|
assertThat(str, IsNot.not(StringContains.containsString("managingOrganization")));
|
||||||
|
|
||||||
|
@ -797,7 +798,7 @@ public class JsonParserTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEncodeUndeclaredExtensionWithAddressContent() {
|
public void testEncodeUndeclaredExtensionWithAddressContent() {
|
||||||
IParser parser = new FhirContext().newJsonParser();
|
IParser parser = ourCtx.newJsonParser();
|
||||||
|
|
||||||
Patient patient = new Patient();
|
Patient patient = new Patient();
|
||||||
patient.addAddress().setUse(AddressUseEnum.HOME);
|
patient.addAddress().setUse(AddressUseEnum.HOME);
|
||||||
|
@ -845,15 +846,15 @@ public class JsonParserTest {
|
||||||
HumanNameDt given = name.addGiven("Joe");
|
HumanNameDt given = name.addGiven("Joe");
|
||||||
ExtensionDt ext2 = new ExtensionDt(false, "http://examples.com#givenext", new StringDt("Hello"));
|
ExtensionDt ext2 = new ExtensionDt(false, "http://examples.com#givenext", new StringDt("Hello"));
|
||||||
given.addUndeclaredExtension(ext2);
|
given.addUndeclaredExtension(ext2);
|
||||||
String enc = new FhirContext().newJsonParser().encodeResourceToString(patient);
|
String enc = ourCtx.newJsonParser().encodeResourceToString(patient);
|
||||||
ourLog.info(enc);
|
ourLog.info(enc);
|
||||||
assertEquals("{\"resourceType\":\"Patient\",\"name\":[{\"extension\":[{\"url\":\"http://examples.com#givenext\",\"valueString\":\"Hello\"}],\"family\":[\"Shmoe\"],\"given\":[\"Joe\"]}]}", enc);
|
assertEquals("{\"resourceType\":\"Patient\",\"name\":[{\"extension\":[{\"url\":\"http://examples.com#givenext\",\"valueString\":\"Hello\"}],\"family\":[\"Shmoe\"],\"given\":[\"Joe\"]}]}", enc);
|
||||||
|
|
||||||
IParser newJsonParser = new FhirContext().newJsonParser();
|
IParser newJsonParser = ourCtx.newJsonParser();
|
||||||
StringReader reader = new StringReader(enc);
|
StringReader reader = new StringReader(enc);
|
||||||
Patient parsed = newJsonParser.parseResource(Patient.class, reader);
|
Patient parsed = newJsonParser.parseResource(Patient.class, reader);
|
||||||
|
|
||||||
ourLog.info(new FhirContext().newXmlParser().setPrettyPrint(true).encodeResourceToString(parsed));
|
ourLog.info(ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(parsed));
|
||||||
|
|
||||||
assertEquals(1, parsed.getNameFirstRep().getUndeclaredExtensionsByUrl("http://examples.com#givenext").size());
|
assertEquals(1, parsed.getNameFirstRep().getUndeclaredExtensionsByUrl("http://examples.com#givenext").size());
|
||||||
ExtensionDt ext = parsed.getNameFirstRep().getUndeclaredExtensionsByUrl("http://examples.com#givenext").get(0);
|
ExtensionDt ext = parsed.getNameFirstRep().getUndeclaredExtensionsByUrl("http://examples.com#givenext").get(0);
|
||||||
|
@ -872,7 +873,7 @@ public class JsonParserTest {
|
||||||
|
|
||||||
ExtensionDt ext2 = new ExtensionDt(false, "http://examples.com#givenext", new StringDt("Hello"));
|
ExtensionDt ext2 = new ExtensionDt(false, "http://examples.com#givenext", new StringDt("Hello"));
|
||||||
family.addUndeclaredExtension(ext2);
|
family.addUndeclaredExtension(ext2);
|
||||||
String enc = new FhirContext().newJsonParser().encodeResourceToString(patient);
|
String enc = ourCtx.newJsonParser().encodeResourceToString(patient);
|
||||||
ourLog.info(enc);
|
ourLog.info(enc);
|
||||||
//@formatter:off
|
//@formatter:off
|
||||||
assertThat(enc, containsString(("{\n" +
|
assertThat(enc, containsString(("{\n" +
|
||||||
|
@ -897,7 +898,7 @@ public class JsonParserTest {
|
||||||
"}").replace("\n", "").replaceAll(" +", "")));
|
"}").replace("\n", "").replaceAll(" +", "")));
|
||||||
//@formatter:on
|
//@formatter:on
|
||||||
|
|
||||||
Patient parsed = new FhirContext().newJsonParser().parseResource(Patient.class, new StringReader(enc));
|
Patient parsed = ourCtx.newJsonParser().parseResource(Patient.class, new StringReader(enc));
|
||||||
assertEquals(1, parsed.getNameFirstRep().getFamilyFirstRep().getUndeclaredExtensionsByUrl("http://examples.com#givenext").size());
|
assertEquals(1, parsed.getNameFirstRep().getFamilyFirstRep().getUndeclaredExtensionsByUrl("http://examples.com#givenext").size());
|
||||||
ExtensionDt ext = parsed.getNameFirstRep().getFamilyFirstRep().getUndeclaredExtensionsByUrl("http://examples.com#givenext").get(0);
|
ExtensionDt ext = parsed.getNameFirstRep().getFamilyFirstRep().getUndeclaredExtensionsByUrl("http://examples.com#givenext").get(0);
|
||||||
assertEquals("Hello", ext.getValueAsPrimitive().getValue());
|
assertEquals("Hello", ext.getValueAsPrimitive().getValue());
|
||||||
|
@ -956,7 +957,7 @@ public class JsonParserTest {
|
||||||
// nothing
|
// nothing
|
||||||
}};
|
}};
|
||||||
|
|
||||||
FhirContext context = new FhirContext();
|
FhirContext context = ourCtx;
|
||||||
context.setNarrativeGenerator(gen);
|
context.setNarrativeGenerator(gen);
|
||||||
IParser p = context.newJsonParser();
|
IParser p = context.newJsonParser();
|
||||||
p.encodeResourceToWriter(patient, new OutputStreamWriter(System.out));
|
p.encodeResourceToWriter(patient, new OutputStreamWriter(System.out));
|
||||||
|
@ -967,6 +968,11 @@ public class JsonParserTest {
|
||||||
assertThat(str, StringContains.containsString(",\"text\":{\"status\":\"generated\",\"div\":\"<div>help</div>\"},"));
|
assertThat(str, StringContains.containsString(",\"text\":{\"status\":\"generated\",\"div\":\"<div>help</div>\"},"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void before() {
|
||||||
|
ourCtx.setNarrativeGenerator(null);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNestedContainedResources() {
|
public void testNestedContainedResources() {
|
||||||
|
|
||||||
|
@ -1330,7 +1336,7 @@ public class JsonParserTest {
|
||||||
"}";
|
"}";
|
||||||
//@formatter:on
|
//@formatter:on
|
||||||
|
|
||||||
TagList tagList = new FhirContext().newJsonParser().parseTagList(tagListStr);
|
TagList tagList = ourCtx.newJsonParser().parseTagList(tagListStr);
|
||||||
assertEquals(3, tagList.size());
|
assertEquals(3, tagList.size());
|
||||||
assertEquals("term0", tagList.get(0).getTerm());
|
assertEquals("term0", tagList.get(0).getTerm());
|
||||||
assertEquals("label0", tagList.get(0).getLabel());
|
assertEquals("label0", tagList.get(0).getLabel());
|
||||||
|
@ -1367,14 +1373,14 @@ public class JsonParserTest {
|
||||||
"}";
|
"}";
|
||||||
//@formatter:on
|
//@formatter:on
|
||||||
|
|
||||||
String encoded = new FhirContext().newJsonParser().encodeTagListToString(tagList);
|
String encoded = ourCtx.newJsonParser().encodeTagListToString(tagList);
|
||||||
assertEquals(expected, encoded);
|
assertEquals(expected, encoded);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void beforeClass() {
|
public static void beforeClass() {
|
||||||
ourCtx = new FhirContext();
|
ourCtx = FhirContext.forDstu1();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ResourceDef(name = "Patient")
|
@ResourceDef(name = "Patient")
|
||||||
|
|
|
@ -1700,8 +1700,7 @@ public class XmlParserTest {
|
||||||
@Test
|
@Test
|
||||||
public void testParseFeedWithListResource() throws ConfigurationException, DataFormatException, IOException {
|
public void testParseFeedWithListResource() throws ConfigurationException, DataFormatException, IOException {
|
||||||
|
|
||||||
// Use new context here to ensure List isn't already loaded
|
IParser p = FhirContext.forDstu1().newXmlParser(); // Use new context here
|
||||||
IParser p = new FhirContext().newXmlParser();
|
|
||||||
|
|
||||||
String string = IOUtils.toString(XmlParserTest.class.getResourceAsStream("/feed-with-list.xml"), Charset.forName("UTF-8"));
|
String string = IOUtils.toString(XmlParserTest.class.getResourceAsStream("/feed-with-list.xml"), Charset.forName("UTF-8"));
|
||||||
Bundle bundle = p.parseBundle(string);
|
Bundle bundle = p.parseBundle(string);
|
||||||
|
@ -1920,7 +1919,7 @@ public class XmlParserTest {
|
||||||
XMLUnit.setIgnoreAttributeOrder(true);
|
XMLUnit.setIgnoreAttributeOrder(true);
|
||||||
XMLUnit.setIgnoreComments(true);
|
XMLUnit.setIgnoreComments(true);
|
||||||
XMLUnit.setIgnoreWhitespace(true);
|
XMLUnit.setIgnoreWhitespace(true);
|
||||||
ourCtx = new FhirContext();
|
ourCtx = FhirContext.forDstu1();
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class BasicAuthInterceptorTest {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void beforeClass() {
|
public static void beforeClass() {
|
||||||
ourCtx = new FhirContext();
|
ourCtx = FhirContext.forDstu1();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class BearerTokenAuthInterceptorTest {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void beforeClass() {
|
public static void beforeClass() {
|
||||||
ourCtx = new FhirContext();
|
ourCtx = FhirContext.forDstu1();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
package ca.uhn.fhir.rest.client;
|
package ca.uhn.fhir.rest.client;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.containsString;
|
import static org.hamcrest.Matchers.*;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.*;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.mockito.Mockito.*;
|
||||||
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.InputStream;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
|
@ -47,7 +43,6 @@ import ca.uhn.fhir.model.api.TagList;
|
||||||
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
||||||
import ca.uhn.fhir.model.base.resource.BaseConformance;
|
import ca.uhn.fhir.model.base.resource.BaseConformance;
|
||||||
import ca.uhn.fhir.model.dstu.composite.CodingDt;
|
import ca.uhn.fhir.model.dstu.composite.CodingDt;
|
||||||
import ca.uhn.fhir.model.dstu.resource.Conformance;
|
|
||||||
import ca.uhn.fhir.model.dstu.resource.Observation;
|
import ca.uhn.fhir.model.dstu.resource.Observation;
|
||||||
import ca.uhn.fhir.model.dstu.resource.OperationOutcome;
|
import ca.uhn.fhir.model.dstu.resource.OperationOutcome;
|
||||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||||
|
@ -77,19 +72,19 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException;
|
import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException;
|
||||||
|
|
||||||
public class ClientTest {
|
public class ClientDstu1Test {
|
||||||
|
|
||||||
private FhirContext ctx;
|
private FhirContext ourCtx;
|
||||||
private HttpClient httpClient;
|
private HttpClient httpClient;
|
||||||
private HttpResponse httpResponse;
|
private HttpResponse httpResponse;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void before() {
|
public void before() {
|
||||||
ctx = new FhirContext(Patient.class, Conformance.class);
|
ourCtx = FhirContext.forDstu1();
|
||||||
|
|
||||||
httpClient = mock(HttpClient.class, new ReturnsDeepStubs());
|
httpClient = mock(HttpClient.class, new ReturnsDeepStubs());
|
||||||
ctx.getRestfulClientFactory().setHttpClient(httpClient);
|
ourCtx.getRestfulClientFactory().setHttpClient(httpClient);
|
||||||
ctx.getRestfulClientFactory().setServerValidationModeEnum(ServerValidationModeEnum.NEVER);
|
ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
|
||||||
|
|
||||||
httpResponse = mock(HttpResponse.class, new ReturnsDeepStubs());
|
httpResponse = mock(HttpResponse.class, new ReturnsDeepStubs());
|
||||||
}
|
}
|
||||||
|
@ -136,7 +131,7 @@ public class ClientTest {
|
||||||
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
|
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
|
||||||
when(httpResponse.getAllHeaders()).thenReturn(toHeaderArray("Location", "http://example.com/fhir/Patient/100/_history/200"));
|
when(httpResponse.getAllHeaders()).thenReturn(toHeaderArray("Location", "http://example.com/fhir/Patient/100/_history/200"));
|
||||||
|
|
||||||
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||||
CapturingInterceptor interceptor = new CapturingInterceptor();
|
CapturingInterceptor interceptor = new CapturingInterceptor();
|
||||||
client.registerInterceptor(interceptor);
|
client.registerInterceptor(interceptor);
|
||||||
|
|
||||||
|
@ -165,7 +160,7 @@ public class ClientTest {
|
||||||
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader("foobar"), Charset.forName("UTF-8")));
|
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader("foobar"), Charset.forName("UTF-8")));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ctx.newRestfulClient(ITestClient.class, "http://foo").createPatient(patient);
|
ourCtx.newRestfulClient(ITestClient.class, "http://foo").createPatient(patient);
|
||||||
fail();
|
fail();
|
||||||
} catch (InvalidRequestException e) {
|
} catch (InvalidRequestException e) {
|
||||||
assertThat(e.getMessage(), StringContains.containsString("foobar"));
|
assertThat(e.getMessage(), StringContains.containsString("foobar"));
|
||||||
|
@ -185,10 +180,10 @@ public class ClientTest {
|
||||||
when(httpClient.execute(capt.capture())).thenReturn(httpResponse);
|
when(httpClient.execute(capt.capture())).thenReturn(httpResponse);
|
||||||
when(httpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 201, "OK"));
|
when(httpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 201, "OK"));
|
||||||
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||||
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(ctx.newXmlParser().encodeResourceToString(patient)), Charset.forName("UTF-8")));
|
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(ourCtx.newXmlParser().encodeResourceToString(patient)), Charset.forName("UTF-8")));
|
||||||
when(httpResponse.getAllHeaders()).thenReturn(toHeaderArray("Location", "http://example.com/fhir/Patient/100/_history/200"));
|
when(httpResponse.getAllHeaders()).thenReturn(toHeaderArray("Location", "http://example.com/fhir/Patient/100/_history/200"));
|
||||||
|
|
||||||
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||||
MethodOutcome response = client.createPatient(patient);
|
MethodOutcome response = client.createPatient(patient);
|
||||||
|
|
||||||
assertEquals(HttpPost.class, capt.getValue().getClass());
|
assertEquals(HttpPost.class, capt.getValue().getClass());
|
||||||
|
@ -211,7 +206,7 @@ public class ClientTest {
|
||||||
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
|
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
|
||||||
when(httpResponse.getAllHeaders()).thenReturn(toHeaderArray("Location", "http://example.com/fhir/Patient/100/_history/200"));
|
when(httpResponse.getAllHeaders()).thenReturn(toHeaderArray("Location", "http://example.com/fhir/Patient/100/_history/200"));
|
||||||
|
|
||||||
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||||
TagList tagList = new TagList();
|
TagList tagList = new TagList();
|
||||||
tagList.add(new Tag((String) null, "Dog", "DogLabel"));
|
tagList.add(new Tag((String) null, "Dog", "DogLabel"));
|
||||||
tagList.add(new Tag("http://cats", "Cat", "CatLabel"));
|
tagList.add(new Tag("http://cats", "Cat", "CatLabel"));
|
||||||
|
@ -237,7 +232,7 @@ public class ClientTest {
|
||||||
|
|
||||||
OperationOutcome oo = new OperationOutcome();
|
OperationOutcome oo = new OperationOutcome();
|
||||||
oo.addIssue().setDetails("Hello");
|
oo.addIssue().setDetails("Hello");
|
||||||
String resp = new FhirContext().newXmlParser().encodeResourceToString(oo);
|
String resp = ourCtx.newXmlParser().encodeResourceToString(oo);
|
||||||
|
|
||||||
ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
|
ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
|
||||||
when(httpClient.execute(capt.capture())).thenReturn(httpResponse);
|
when(httpClient.execute(capt.capture())).thenReturn(httpResponse);
|
||||||
|
@ -245,7 +240,7 @@ public class ClientTest {
|
||||||
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||||
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(resp), Charset.forName("UTF-8")));
|
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(resp), Charset.forName("UTF-8")));
|
||||||
|
|
||||||
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||||
MethodOutcome response = client.deletePatient(new IdDt("1234"));
|
MethodOutcome response = client.deletePatient(new IdDt("1234"));
|
||||||
|
|
||||||
assertEquals(HttpDelete.class, capt.getValue().getClass());
|
assertEquals(HttpDelete.class, capt.getValue().getClass());
|
||||||
|
@ -262,7 +257,7 @@ public class ClientTest {
|
||||||
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_TEXT + "; charset=UTF-8"));
|
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_TEXT + "; charset=UTF-8"));
|
||||||
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
|
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
|
||||||
|
|
||||||
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||||
client.deleteDiagnosticReport(new IdDt("1234"));
|
client.deleteDiagnosticReport(new IdDt("1234"));
|
||||||
|
|
||||||
assertEquals(HttpDelete.class, capt.getValue().getClass());
|
assertEquals(HttpDelete.class, capt.getValue().getClass());
|
||||||
|
@ -272,7 +267,7 @@ public class ClientTest {
|
||||||
@Test
|
@Test
|
||||||
public void testGetConformance() throws Exception {
|
public void testGetConformance() throws Exception {
|
||||||
|
|
||||||
String msg = IOUtils.toString(ClientTest.class.getResourceAsStream("/example-metadata.xml"));
|
String msg = IOUtils.toString(ClientDstu1Test.class.getResourceAsStream("/example-metadata.xml"));
|
||||||
|
|
||||||
ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
|
ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
|
||||||
when(httpClient.execute(capt.capture())).thenReturn(httpResponse);
|
when(httpClient.execute(capt.capture())).thenReturn(httpResponse);
|
||||||
|
@ -280,7 +275,7 @@ public class ClientTest {
|
||||||
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||||
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
||||||
|
|
||||||
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||||
BaseConformance response = client.getServerConformanceStatement();
|
BaseConformance response = client.getServerConformanceStatement();
|
||||||
|
|
||||||
assertEquals("http://foo/metadata", capt.getValue().getURI().toString());
|
assertEquals("http://foo/metadata", capt.getValue().getURI().toString());
|
||||||
|
@ -319,7 +314,7 @@ public class ClientTest {
|
||||||
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_ATOM_XML + "; charset=UTF-8"));
|
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_ATOM_XML + "; charset=UTF-8"));
|
||||||
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
||||||
|
|
||||||
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||||
Bundle response = client.getHistoryPatientInstance(new IdDt("111"));
|
Bundle response = client.getHistoryPatientInstance(new IdDt("111"));
|
||||||
|
|
||||||
assertEquals("http://foo/Patient/111/_history", capt.getValue().getURI().toString());
|
assertEquals("http://foo/Patient/111/_history", capt.getValue().getURI().toString());
|
||||||
|
@ -391,7 +386,7 @@ public class ClientTest {
|
||||||
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_ATOM_XML + "; charset=UTF-8"));
|
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_ATOM_XML + "; charset=UTF-8"));
|
||||||
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
||||||
|
|
||||||
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||||
Bundle response = client.getHistoryPatientType();
|
Bundle response = client.getHistoryPatientType();
|
||||||
|
|
||||||
assertEquals("http://foo/Patient/_history", capt.getValue().getURI().toString());
|
assertEquals("http://foo/Patient/_history", capt.getValue().getURI().toString());
|
||||||
|
@ -462,7 +457,7 @@ public class ClientTest {
|
||||||
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_ATOM_XML + "; charset=UTF-8"));
|
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_ATOM_XML + "; charset=UTF-8"));
|
||||||
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
||||||
|
|
||||||
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||||
Bundle response = client.getHistoryServer();
|
Bundle response = client.getHistoryServer();
|
||||||
|
|
||||||
assertEquals("http://foo/_history", capt.getValue().getURI().toString());
|
assertEquals("http://foo/_history", capt.getValue().getURI().toString());
|
||||||
|
@ -521,7 +516,7 @@ public class ClientTest {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||||
|
|
||||||
// ensures the local timezone
|
// ensures the local timezone
|
||||||
String expectedDateString = new InstantDt(new InstantDt("2012-01-02T12:01:02").getValue()).getValueAsString();
|
String expectedDateString = new InstantDt(new InstantDt("2012-01-02T12:01:02").getValue()).getValueAsString();
|
||||||
|
@ -556,7 +551,7 @@ public class ClientTest {
|
||||||
|
|
||||||
// TODO: remove the read annotation and make sure we get a sensible
|
// TODO: remove the read annotation and make sure we get a sensible
|
||||||
// error message to tell the user why the method isn't working
|
// error message to tell the user why the method isn't working
|
||||||
FhirContext ctx = new FhirContext();
|
FhirContext ctx = ourCtx;
|
||||||
ctx.getRestfulClientFactory().setServerValidationModeEnum(ServerValidationModeEnum.NEVER);
|
ctx.getRestfulClientFactory().setServerValidationModeEnum(ServerValidationModeEnum.NEVER);
|
||||||
|
|
||||||
ClientWithoutAnnotation client = ctx.newRestfulClient(ClientWithoutAnnotation.class, "http://wildfhir.aegis.net/fhir");
|
ClientWithoutAnnotation client = ctx.newRestfulClient(ClientWithoutAnnotation.class, "http://wildfhir.aegis.net/fhir");
|
||||||
|
@ -596,7 +591,7 @@ public class ClientTest {
|
||||||
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||||
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
||||||
|
|
||||||
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||||
// Patient response = client.findPatientByMrn(new
|
// Patient response = client.findPatientByMrn(new
|
||||||
// IdentifierDt("urn:foo", "123"));
|
// IdentifierDt("urn:foo", "123"));
|
||||||
Patient response = client.getPatientById(new IdDt("111"));
|
Patient response = client.getPatientById(new IdDt("111"));
|
||||||
|
@ -640,7 +635,7 @@ public class ClientTest {
|
||||||
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", "application/fhir+xml; charset=UTF-8"));
|
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", "application/fhir+xml; charset=UTF-8"));
|
||||||
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
||||||
|
|
||||||
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||||
// Patient response = client.findPatientByMrn(new
|
// Patient response = client.findPatientByMrn(new
|
||||||
// IdentifierDt("urn:foo", "123"));
|
// IdentifierDt("urn:foo", "123"));
|
||||||
Patient response = client.getPatientById(new IdDt("111"));
|
Patient response = client.getPatientById(new IdDt("111"));
|
||||||
|
@ -662,7 +657,7 @@ public class ClientTest {
|
||||||
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_TEXT));
|
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_TEXT));
|
||||||
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader("Internal Failure"), Charset.forName("UTF-8")));
|
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader("Internal Failure"), Charset.forName("UTF-8")));
|
||||||
|
|
||||||
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||||
try {
|
try {
|
||||||
client.getPatientById(new IdDt("111"));
|
client.getPatientById(new IdDt("111"));
|
||||||
fail();
|
fail();
|
||||||
|
@ -689,7 +684,7 @@ public class ClientTest {
|
||||||
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML));
|
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML));
|
||||||
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
||||||
|
|
||||||
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||||
try {
|
try {
|
||||||
client.getPatientById(new IdDt("111"));
|
client.getPatientById(new IdDt("111"));
|
||||||
fail();
|
fail();
|
||||||
|
@ -723,7 +718,7 @@ public class ClientTest {
|
||||||
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML));
|
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML));
|
||||||
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
||||||
|
|
||||||
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||||
// Patient response = client.findPatientByMrn(new
|
// Patient response = client.findPatientByMrn(new
|
||||||
// IdentifierDt("urn:foo", "123"));
|
// IdentifierDt("urn:foo", "123"));
|
||||||
Patient response = client.getPatientById(new IdDt("111"));
|
Patient response = client.getPatientById(new IdDt("111"));
|
||||||
|
@ -748,7 +743,7 @@ public class ClientTest {
|
||||||
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||||
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
||||||
|
|
||||||
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||||
DateRangeParam param = new DateRangeParam();
|
DateRangeParam param = new DateRangeParam();
|
||||||
param.setLowerBound(new DateParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, "2011-01-01"));
|
param.setLowerBound(new DateParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, "2011-01-01"));
|
||||||
param.setUpperBound(new DateParam(QuantityCompararatorEnum.LESSTHAN_OR_EQUALS, "2021-01-01"));
|
param.setUpperBound(new DateParam(QuantityCompararatorEnum.LESSTHAN_OR_EQUALS, "2021-01-01"));
|
||||||
|
@ -772,7 +767,7 @@ public class ClientTest {
|
||||||
// httpResponse = new BasicHttpResponse(statusline, catalog, locale)
|
// httpResponse = new BasicHttpResponse(statusline, catalog, locale)
|
||||||
when(httpClient.execute(capt.capture())).thenReturn(httpResponse);
|
when(httpClient.execute(capt.capture())).thenReturn(httpResponse);
|
||||||
|
|
||||||
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||||
List<Patient> response = client.getPatientByDob(new DateParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, "2011-01-02"));
|
List<Patient> response = client.getPatientByDob(new DateParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, "2011-01-02"));
|
||||||
|
|
||||||
assertEquals("http://foo/Patient?birthdate=%3E%3D2011-01-02", capt.getValue().getURI().toString());
|
assertEquals("http://foo/Patient?birthdate=%3E%3D2011-01-02", capt.getValue().getURI().toString());
|
||||||
|
@ -793,7 +788,7 @@ public class ClientTest {
|
||||||
|
|
||||||
when(httpClient.execute(capt.capture())).thenReturn(httpResponse);
|
when(httpClient.execute(capt.capture())).thenReturn(httpResponse);
|
||||||
|
|
||||||
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||||
List<Patient> response = client.getPatientByCompartmentAndDob(new IdDt("123"), new DateParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, "2011-01-02"));
|
List<Patient> response = client.getPatientByCompartmentAndDob(new IdDt("123"), new DateParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, "2011-01-02"));
|
||||||
|
|
||||||
assertEquals("http://foo/Patient/123/compartmentName?birthdate=%3E%3D2011-01-02", capt.getValue().getURI().toString());
|
assertEquals("http://foo/Patient/123/compartmentName?birthdate=%3E%3D2011-01-02", capt.getValue().getURI().toString());
|
||||||
|
@ -819,7 +814,7 @@ public class ClientTest {
|
||||||
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||||
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
||||||
|
|
||||||
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||||
Patient response = client.findPatientQuantity(new QuantityParam(QuantityCompararatorEnum.GREATERTHAN, 123L, "foo", "bar"));
|
Patient response = client.findPatientQuantity(new QuantityParam(QuantityCompararatorEnum.GREATERTHAN, 123L, "foo", "bar"));
|
||||||
|
|
||||||
assertEquals("http://foo/Patient?quantityParam=%3E123%7Cfoo%7Cbar", capt.getValue().getURI().toString());
|
assertEquals("http://foo/Patient?quantityParam=%3E123%7Cfoo%7Cbar", capt.getValue().getURI().toString());
|
||||||
|
@ -838,7 +833,7 @@ public class ClientTest {
|
||||||
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||||
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
||||||
|
|
||||||
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||||
Patient response = client.findPatientByMrn(new TokenParam("urn:foo", "123"));
|
Patient response = client.findPatientByMrn(new TokenParam("urn:foo", "123"));
|
||||||
|
|
||||||
assertEquals("http://foo/Patient?identifier=urn%3Afoo%7C123", capt.getValue().getURI().toString());
|
assertEquals("http://foo/Patient?identifier=urn%3Afoo%7C123", capt.getValue().getURI().toString());
|
||||||
|
@ -857,7 +852,7 @@ public class ClientTest {
|
||||||
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||||
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
||||||
|
|
||||||
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||||
TokenOrListParam identifiers = new TokenOrListParam();
|
TokenOrListParam identifiers = new TokenOrListParam();
|
||||||
identifiers.add(new CodingDt("foo", "bar"));
|
identifiers.add(new CodingDt("foo", "bar"));
|
||||||
identifiers.add(new CodingDt("baz", "boz"));
|
identifiers.add(new CodingDt("baz", "boz"));
|
||||||
|
@ -878,7 +873,7 @@ public class ClientTest {
|
||||||
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||||
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
||||||
|
|
||||||
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||||
client.getPatientNoParams();
|
client.getPatientNoParams();
|
||||||
|
|
||||||
assertEquals("http://foo/Patient?_query=someQueryNoParams", capt.getValue().getURI().toString());
|
assertEquals("http://foo/Patient?_query=someQueryNoParams", capt.getValue().getURI().toString());
|
||||||
|
@ -896,7 +891,7 @@ public class ClientTest {
|
||||||
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||||
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
||||||
|
|
||||||
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||||
client.getPatientOneParam(new StringParam("BB"));
|
client.getPatientOneParam(new StringParam("BB"));
|
||||||
|
|
||||||
assertEquals("http://foo/Patient?_query=someQueryOneParam¶m1=BB", capt.getValue().getURI().toString());
|
assertEquals("http://foo/Patient?_query=someQueryOneParam¶m1=BB", capt.getValue().getURI().toString());
|
||||||
|
@ -914,7 +909,7 @@ public class ClientTest {
|
||||||
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||||
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
||||||
|
|
||||||
ITestClientWithCustomType client = ctx.newRestfulClient(ITestClientWithCustomType.class, "http://foo");
|
ITestClientWithCustomType client = ourCtx.newRestfulClient(ITestClientWithCustomType.class, "http://foo");
|
||||||
CustomPatient response = client.getPatientByDob(new DateParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, "2011-01-02"));
|
CustomPatient response = client.getPatientByDob(new DateParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, "2011-01-02"));
|
||||||
|
|
||||||
assertEquals("http://foo/Patient?birthdate=%3E%3D2011-01-02", capt.getValue().getURI().toString());
|
assertEquals("http://foo/Patient?birthdate=%3E%3D2011-01-02", capt.getValue().getURI().toString());
|
||||||
|
@ -933,7 +928,7 @@ public class ClientTest {
|
||||||
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||||
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
||||||
|
|
||||||
ITestClientWithCustomTypeList client = ctx.newRestfulClient(ITestClientWithCustomTypeList.class, "http://foo");
|
ITestClientWithCustomTypeList client = ourCtx.newRestfulClient(ITestClientWithCustomTypeList.class, "http://foo");
|
||||||
List<CustomPatient> response = client.getPatientByDob(new DateParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, "2011-01-02"));
|
List<CustomPatient> response = client.getPatientByDob(new DateParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, "2011-01-02"));
|
||||||
|
|
||||||
assertEquals("http://foo/Patient?birthdate=%3E%3D2011-01-02", capt.getValue().getURI().toString());
|
assertEquals("http://foo/Patient?birthdate=%3E%3D2011-01-02", capt.getValue().getURI().toString());
|
||||||
|
@ -954,7 +949,7 @@ public class ClientTest {
|
||||||
|
|
||||||
// TODO: document this
|
// TODO: document this
|
||||||
|
|
||||||
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||||
client.getPatientByDob(new DateParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, "2011-01-02"));
|
client.getPatientByDob(new DateParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, "2011-01-02"));
|
||||||
assertEquals("http://foo/Patient?birthdate=%3E%3D2011-01-02", capt.getAllValues().get(0).getURI().toString());
|
assertEquals("http://foo/Patient?birthdate=%3E%3D2011-01-02", capt.getAllValues().get(0).getURI().toString());
|
||||||
|
|
||||||
|
@ -982,7 +977,7 @@ public class ClientTest {
|
||||||
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||||
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
||||||
|
|
||||||
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||||
client.getPatientWithIncludes(new StringParam("aaa"), Arrays.asList(new Include[] { new Include("inc1"), new Include("inc2") }));
|
client.getPatientWithIncludes(new StringParam("aaa"), Arrays.asList(new Include[] { new Include("inc1"), new Include("inc2") }));
|
||||||
|
|
||||||
assertEquals("http://foo/Patient?withIncludes=aaa&_include=inc1&_include=inc2", capt.getValue().getURI().toString());
|
assertEquals("http://foo/Patient?withIncludes=aaa&_include=inc1&_include=inc2", capt.getValue().getURI().toString());
|
||||||
|
@ -1000,7 +995,7 @@ public class ClientTest {
|
||||||
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||||
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
||||||
|
|
||||||
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||||
Bundle response = client.findPatientByName(new StringParam("AAA"), null);
|
Bundle response = client.findPatientByName(new StringParam("AAA"), null);
|
||||||
|
|
||||||
assertEquals("http://foo/Patient?family=AAA", capt.getValue().getURI().toString());
|
assertEquals("http://foo/Patient?family=AAA", capt.getValue().getURI().toString());
|
||||||
|
@ -1012,7 +1007,7 @@ public class ClientTest {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
||||||
client = ctx.newRestfulClient(ITestClient.class, "http://foo");
|
client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||||
response = client.findPatientByName(new StringParam("AAA"), new StringParam("BBB"));
|
response = client.findPatientByName(new StringParam("AAA"), new StringParam("BBB"));
|
||||||
|
|
||||||
assertEquals("http://foo/Patient?family=AAA&given=BBB", capt.getValue().getURI().toString());
|
assertEquals("http://foo/Patient?family=AAA&given=BBB", capt.getValue().getURI().toString());
|
||||||
|
@ -1032,7 +1027,7 @@ public class ClientTest {
|
||||||
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||||
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
||||||
|
|
||||||
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||||
StringParam str = new StringParam("FOO$BAR");
|
StringParam str = new StringParam("FOO$BAR");
|
||||||
DateParam date = new DateParam("2001-01-01");
|
DateParam date = new DateParam("2001-01-01");
|
||||||
client.getObservationByNameValueDate(new CompositeParam<StringParam, DateParam>(str, date));
|
client.getObservationByNameValueDate(new CompositeParam<StringParam, DateParam>(str, date));
|
||||||
|
@ -1052,7 +1047,7 @@ public class ClientTest {
|
||||||
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||||
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
||||||
|
|
||||||
ITestClientWithStringIncludes client = ctx.newRestfulClient(ITestClientWithStringIncludes.class, "http://foo");
|
ITestClientWithStringIncludes client = ourCtx.newRestfulClient(ITestClientWithStringIncludes.class, "http://foo");
|
||||||
client.getPatientWithIncludes(new StringParam("aaa"), "inc1");
|
client.getPatientWithIncludes(new StringParam("aaa"), "inc1");
|
||||||
|
|
||||||
assertEquals("http://foo/Patient?withIncludes=aaa&_include=inc1", capt.getValue().getURI().toString());
|
assertEquals("http://foo/Patient?withIncludes=aaa&_include=inc1", capt.getValue().getURI().toString());
|
||||||
|
@ -1072,7 +1067,7 @@ public class ClientTest {
|
||||||
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
|
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
|
||||||
when(httpResponse.getAllHeaders()).thenReturn(toHeaderArray("Location", "http://example.com/fhir/Patient/100/_history/200"));
|
when(httpResponse.getAllHeaders()).thenReturn(toHeaderArray("Location", "http://example.com/fhir/Patient/100/_history/200"));
|
||||||
|
|
||||||
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||||
MethodOutcome response = client.updatePatient(new IdDt("100"), patient);
|
MethodOutcome response = client.updatePatient(new IdDt("100"), patient);
|
||||||
|
|
||||||
assertEquals(HttpPut.class, capt.getValue().getClass());
|
assertEquals(HttpPut.class, capt.getValue().getClass());
|
||||||
|
@ -1100,7 +1095,7 @@ public class ClientTest {
|
||||||
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
|
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
|
||||||
when(httpResponse.getAllHeaders()).thenReturn(toHeaderArray("Content-Location", "http://example.com/fhir/Patient/100/_history/200"));
|
when(httpResponse.getAllHeaders()).thenReturn(toHeaderArray("Content-Location", "http://example.com/fhir/Patient/100/_history/200"));
|
||||||
|
|
||||||
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||||
client.updatePatient(new IdDt("Patient/100/_history/200"), patient);
|
client.updatePatient(new IdDt("Patient/100/_history/200"), patient);
|
||||||
|
|
||||||
assertEquals(HttpPut.class, capt.getValue().getClass());
|
assertEquals(HttpPut.class, capt.getValue().getClass());
|
||||||
|
@ -1124,7 +1119,7 @@ public class ClientTest {
|
||||||
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
|
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
|
||||||
when(httpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), Constants.STATUS_HTTP_409_CONFLICT, "Conflict"));
|
when(httpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), Constants.STATUS_HTTP_409_CONFLICT, "Conflict"));
|
||||||
|
|
||||||
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||||
client.updatePatient(new IdDt("Patient/100/_history/200"), patient);
|
client.updatePatient(new IdDt("Patient/100/_history/200"), patient);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1141,7 +1136,7 @@ public class ClientTest {
|
||||||
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
|
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
|
||||||
when(httpResponse.getAllHeaders()).thenReturn(toHeaderArray("Location", "http://example.com/fhir/Patient/100/_history/200"));
|
when(httpResponse.getAllHeaders()).thenReturn(toHeaderArray("Location", "http://example.com/fhir/Patient/100/_history/200"));
|
||||||
|
|
||||||
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||||
MethodOutcome response = client.updatePatient(new IdDt("Patient/100/_history/200"), patient);
|
MethodOutcome response = client.updatePatient(new IdDt("Patient/100/_history/200"), patient);
|
||||||
|
|
||||||
assertEquals(HttpPut.class, capt.getValue().getClass());
|
assertEquals(HttpPut.class, capt.getValue().getClass());
|
||||||
|
@ -1166,7 +1161,7 @@ public class ClientTest {
|
||||||
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
|
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
|
||||||
when(httpResponse.getAllHeaders()).thenReturn(toHeaderArray("Location", "http://example.com/fhir/Patient/100/_history/200"));
|
when(httpResponse.getAllHeaders()).thenReturn(toHeaderArray("Location", "http://example.com/fhir/Patient/100/_history/200"));
|
||||||
|
|
||||||
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||||
MethodOutcome response = client.validatePatient(patient);
|
MethodOutcome response = client.validatePatient(patient);
|
||||||
|
|
||||||
assertEquals(HttpPost.class, capt.getValue().getClass());
|
assertEquals(HttpPost.class, capt.getValue().getClass());
|
||||||
|
@ -1199,7 +1194,7 @@ public class ClientTest {
|
||||||
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||||
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
||||||
|
|
||||||
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
||||||
// Patient response = client.findPatientByMrn(new
|
// Patient response = client.findPatientByMrn(new
|
||||||
// IdentifierDt("urn:foo", "123"));
|
// IdentifierDt("urn:foo", "123"));
|
||||||
Patient response = client.getPatientById(new IdDt("Patient/111/_history/999"));
|
Patient response = client.getPatientById(new IdDt("Patient/111/_history/999"));
|
||||||
|
@ -1224,7 +1219,7 @@ public class ClientTest {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ITestClientWithNarrativeParam client = ctx.newRestfulClient(ITestClientWithNarrativeParam.class, "http://foo");
|
ITestClientWithNarrativeParam client = ourCtx.newRestfulClient(ITestClientWithNarrativeParam.class, "http://foo");
|
||||||
|
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
|
|
|
@ -34,6 +34,7 @@ public class ClientIntegrationTest {
|
||||||
private int myPort;
|
private int myPort;
|
||||||
private Server myServer;
|
private Server myServer;
|
||||||
private MyPatientResourceProvider myPatientProvider;
|
private MyPatientResourceProvider myPatientProvider;
|
||||||
|
private static FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void before() {
|
public void before() {
|
||||||
|
@ -43,7 +44,7 @@ public class ClientIntegrationTest {
|
||||||
myPatientProvider = new MyPatientResourceProvider();
|
myPatientProvider = new MyPatientResourceProvider();
|
||||||
|
|
||||||
ServletHandler proxyHandler = new ServletHandler();
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
RestfulServer servlet = new RestfulServer();
|
RestfulServer servlet = new RestfulServer(ourCtx);
|
||||||
servlet.setResourceProviders(myPatientProvider);
|
servlet.setResourceProviders(myPatientProvider);
|
||||||
ServletHolder servletHolder = new ServletHolder(servlet);
|
ServletHolder servletHolder = new ServletHolder(servlet);
|
||||||
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
||||||
|
@ -57,7 +58,7 @@ public class ClientIntegrationTest {
|
||||||
|
|
||||||
myServer.start();
|
myServer.start();
|
||||||
|
|
||||||
FhirContext ctx = new FhirContext();
|
FhirContext ctx = FhirContext.forDstu1();
|
||||||
|
|
||||||
HttpClientBuilder builder = HttpClientBuilder.create();
|
HttpClientBuilder builder = HttpClientBuilder.create();
|
||||||
// PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
|
// PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class ExceptionHandlingTest {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void beforeClass() {
|
public static void beforeClass() {
|
||||||
ourCtx = new FhirContext();
|
ourCtx = FhirContext.forDstu1();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
|
|
@ -778,7 +778,7 @@ public class GenericClientTest {
|
||||||
@Test
|
@Test
|
||||||
public void testSearchByNumberExact() throws Exception {
|
public void testSearchByNumberExact() throws Exception {
|
||||||
|
|
||||||
String msg = new FhirContext().newXmlParser().encodeBundleToString(new Bundle());
|
String msg = ourCtx.newXmlParser().encodeBundleToString(new Bundle());
|
||||||
|
|
||||||
ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
|
ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
|
||||||
when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
|
when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
|
||||||
|
@ -1360,7 +1360,7 @@ public class GenericClientTest {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void beforeClass() {
|
public static void beforeClass() {
|
||||||
ourCtx = new FhirContext();
|
ourCtx = FhirContext.forDstu1();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class HttpProxyTest {
|
||||||
myFirstRequest = true;
|
myFirstRequest = true;
|
||||||
myAuthHeader = null;
|
myAuthHeader = null;
|
||||||
|
|
||||||
RestfulServer restServer = new RestfulServer() {
|
RestfulServer restServer = new RestfulServer(ourCtx) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doGet(HttpServletRequest theRequest, HttpServletResponse theResponse) throws ServletException, IOException {
|
protected void doGet(HttpServletRequest theRequest, HttpServletResponse theResponse) throws ServletException, IOException {
|
||||||
|
@ -69,7 +69,6 @@ public class HttpProxyTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
restServer.setFhirContext(ourCtx);
|
|
||||||
restServer.setResourceProviders(new PatientResourceProvider());
|
restServer.setResourceProviders(new PatientResourceProvider());
|
||||||
|
|
||||||
// ServletHandler proxyHandler = new ServletHandler();
|
// ServletHandler proxyHandler = new ServletHandler();
|
||||||
|
@ -123,7 +122,7 @@ public class HttpProxyTest {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void beforeClass() throws Exception {
|
public static void beforeClass() throws Exception {
|
||||||
ourCtx = new FhirContext();
|
ourCtx = FhirContext.forDstu1();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class PatientResourceProvider implements IResourceProvider {
|
public static class PatientResourceProvider implements IResourceProvider {
|
||||||
|
|
|
@ -39,8 +39,7 @@ public class LoggingInterceptorTest {
|
||||||
|
|
||||||
private static int ourPort;
|
private static int ourPort;
|
||||||
private static Server ourServer;
|
private static Server ourServer;
|
||||||
private static FhirContext ourCtx;
|
private static final FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
|
|
||||||
private Appender<ILoggingEvent> myMockAppender;
|
private Appender<ILoggingEvent> myMockAppender;
|
||||||
private Logger myLoggerRoot;
|
private Logger myLoggerRoot;
|
||||||
|
|
||||||
|
@ -89,15 +88,14 @@ public class LoggingInterceptorTest {
|
||||||
DummyProvider patientProvider = new DummyProvider();
|
DummyProvider patientProvider = new DummyProvider();
|
||||||
|
|
||||||
ServletHandler proxyHandler = new ServletHandler();
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
RestfulServer servlet = new RestfulServer();
|
RestfulServer servlet = new RestfulServer(ourCtx);
|
||||||
ourCtx = servlet.getFhirContext();
|
|
||||||
servlet.setResourceProviders(patientProvider);
|
servlet.setResourceProviders(patientProvider);
|
||||||
ServletHolder servletHolder = new ServletHolder(servlet);
|
ServletHolder servletHolder = new ServletHolder(servlet);
|
||||||
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
||||||
ourServer.setHandler(proxyHandler);
|
ourServer.setHandler(proxyHandler);
|
||||||
ourServer.start();
|
ourServer.start();
|
||||||
|
|
||||||
ourCtx.getRestfulClientFactory().setServerValidationModeEnum(ServerValidationModeEnum.NEVER);
|
ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -42,9 +42,9 @@ import ca.uhn.fhir.rest.param.TokenParam;
|
||||||
import ca.uhn.fhir.rest.server.Constants;
|
import ca.uhn.fhir.rest.server.Constants;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
|
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
|
||||||
|
|
||||||
public class SearchTest {
|
public class SearchClientDstu1Test {
|
||||||
|
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SearchTest.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SearchClientDstu1Test.class);
|
||||||
|
|
||||||
private FhirContext ourCtx;
|
private FhirContext ourCtx;
|
||||||
private HttpClient ourHttpClient;
|
private HttpClient ourHttpClient;
|
|
@ -184,7 +184,7 @@ public class BaseOutcomeReturningMethodBindingTest {
|
||||||
"}";
|
"}";
|
||||||
//@formatter:on
|
//@formatter:on
|
||||||
|
|
||||||
TagList parsedFromResource = new FhirContext().newJsonParser().parseTagList(resourceString);
|
TagList parsedFromResource = FhirContext.forDstu1().newJsonParser().parseTagList(resourceString);
|
||||||
|
|
||||||
assertEquals(parsedFromHeader.size(), parsedFromResource.size());
|
assertEquals(parsedFromHeader.size(), parsedFromResource.size());
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ public class AcceptHeaderTest {
|
||||||
private static CloseableHttpClient ourClient;
|
private static CloseableHttpClient ourClient;
|
||||||
private static int ourPort;
|
private static int ourPort;
|
||||||
private static Server ourServer;
|
private static Server ourServer;
|
||||||
|
private static FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testReadNoHeader() throws Exception {
|
public void testReadNoHeader() throws Exception {
|
||||||
|
@ -97,7 +98,7 @@ public class AcceptHeaderTest {
|
||||||
ourServer = new Server(ourPort);
|
ourServer = new Server(ourPort);
|
||||||
|
|
||||||
ServletHandler proxyHandler = new ServletHandler();
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
RestfulServer servlet = new RestfulServer();
|
RestfulServer servlet = new RestfulServer(ourCtx);
|
||||||
servlet.setResourceProviders(new PatientProvider());
|
servlet.setResourceProviders(new PatientProvider());
|
||||||
servlet.setDefaultResponseEncoding(EncodingEnum.XML);
|
servlet.setDefaultResponseEncoding(EncodingEnum.XML);
|
||||||
ServletHolder servletHolder = new ServletHolder(servlet);
|
ServletHolder servletHolder = new ServletHolder(servlet);
|
||||||
|
|
|
@ -44,7 +44,7 @@ import ca.uhn.fhir.util.PortUtil;
|
||||||
public class BinaryTest {
|
public class BinaryTest {
|
||||||
|
|
||||||
private static CloseableHttpClient ourClient;
|
private static CloseableHttpClient ourClient;
|
||||||
private static FhirContext ourCtx = new FhirContext();
|
private static FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
private static Binary ourLast;
|
private static Binary ourLast;
|
||||||
|
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BinaryTest.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BinaryTest.class);
|
||||||
|
@ -166,7 +166,7 @@ public class BinaryTest {
|
||||||
ResourceProvider patientProvider = new ResourceProvider();
|
ResourceProvider patientProvider = new ResourceProvider();
|
||||||
|
|
||||||
ServletHandler proxyHandler = new ServletHandler();
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
RestfulServer servlet = new RestfulServer();
|
RestfulServer servlet = new RestfulServer(ourCtx);
|
||||||
servlet.setResourceProviders(patientProvider);
|
servlet.setResourceProviders(patientProvider);
|
||||||
ServletHolder servletHolder = new ServletHolder(servlet);
|
ServletHolder servletHolder = new ServletHolder(servlet);
|
||||||
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
||||||
|
|
|
@ -40,7 +40,7 @@ import ca.uhn.fhir.util.PortUtil;
|
||||||
public class CompositeParameterTest {
|
public class CompositeParameterTest {
|
||||||
|
|
||||||
private static CloseableHttpClient ourClient;
|
private static CloseableHttpClient ourClient;
|
||||||
private static FhirContext ourCtx;
|
private static final FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
private static int ourPort;
|
private static int ourPort;
|
||||||
private static Server ourServer;
|
private static Server ourServer;
|
||||||
|
|
||||||
|
@ -106,8 +106,7 @@ public class CompositeParameterTest {
|
||||||
DummyObservationResourceProvider patientProvider = new DummyObservationResourceProvider();
|
DummyObservationResourceProvider patientProvider = new DummyObservationResourceProvider();
|
||||||
|
|
||||||
ServletHandler proxyHandler = new ServletHandler();
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
RestfulServer servlet = new RestfulServer();
|
RestfulServer servlet = new RestfulServer(ourCtx);
|
||||||
ourCtx = servlet.getFhirContext();
|
|
||||||
servlet.setResourceProviders(patientProvider);
|
servlet.setResourceProviders(patientProvider);
|
||||||
ServletHolder servletHolder = new ServletHolder(servlet);
|
ServletHolder servletHolder = new ServletHolder(servlet);
|
||||||
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
||||||
|
@ -118,8 +117,6 @@ public class CompositeParameterTest {
|
||||||
HttpClientBuilder builder = HttpClientBuilder.create();
|
HttpClientBuilder builder = HttpClientBuilder.create();
|
||||||
builder.setConnectionManager(connectionManager);
|
builder.setConnectionManager(connectionManager);
|
||||||
ourClient = builder.build();
|
ourClient = builder.build();
|
||||||
|
|
||||||
ourCtx = servlet.getFhirContext();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class CompressionTest {
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(CompressionTest.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(CompressionTest.class);
|
||||||
private static int ourPort;
|
private static int ourPort;
|
||||||
private static Server ourServer;
|
private static Server ourServer;
|
||||||
private static FhirContext ourCtx;
|
private static final FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
|
|
||||||
public static String decompress(byte[] theResource) {
|
public static String decompress(byte[] theResource) {
|
||||||
GZIPInputStream is;
|
GZIPInputStream is;
|
||||||
|
@ -107,8 +107,7 @@ public class CompressionTest {
|
||||||
DummyProvider patientProvider = new DummyProvider();
|
DummyProvider patientProvider = new DummyProvider();
|
||||||
|
|
||||||
ServletHandler proxyHandler = new ServletHandler();
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
RestfulServer servlet = new RestfulServer();
|
RestfulServer servlet = new RestfulServer(ourCtx);
|
||||||
ourCtx = servlet.getFhirContext();
|
|
||||||
servlet.setResourceProviders(patientProvider);
|
servlet.setResourceProviders(patientProvider);
|
||||||
ServletHolder servletHolder = new ServletHolder(servlet);
|
ServletHolder servletHolder = new ServletHolder(servlet);
|
||||||
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
||||||
|
|
|
@ -37,7 +37,7 @@ import ca.uhn.fhir.util.PortUtil;
|
||||||
*/
|
*/
|
||||||
public class CorsTest {
|
public class CorsTest {
|
||||||
private static CloseableHttpClient ourClient;
|
private static CloseableHttpClient ourClient;
|
||||||
private static FhirContext ourCtx;
|
private static final FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(CorsTest.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(CorsTest.class);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -45,8 +45,7 @@ public class CorsTest {
|
||||||
int port = PortUtil.findFreePort();
|
int port = PortUtil.findFreePort();
|
||||||
Server server = new Server(port);
|
Server server = new Server(port);
|
||||||
|
|
||||||
RestfulServer restServer = new RestfulServer();
|
RestfulServer restServer = new RestfulServer(ourCtx);
|
||||||
restServer.setFhirContext(ourCtx);
|
|
||||||
restServer.setResourceProviders(new DummyPatientResourceProvider());
|
restServer.setResourceProviders(new DummyPatientResourceProvider());
|
||||||
|
|
||||||
// ServletHandler proxyHandler = new ServletHandler();
|
// ServletHandler proxyHandler = new ServletHandler();
|
||||||
|
@ -125,8 +124,6 @@ public class CorsTest {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void beforeClass() throws Exception {
|
public static void beforeClass() throws Exception {
|
||||||
ourCtx = new FhirContext();
|
|
||||||
|
|
||||||
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
|
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
|
||||||
HttpClientBuilder builder = HttpClientBuilder.create();
|
HttpClientBuilder builder = HttpClientBuilder.create();
|
||||||
builder.setConnectionManager(connectionManager);
|
builder.setConnectionManager(connectionManager);
|
||||||
|
|
|
@ -51,11 +51,11 @@ import ca.uhn.fhir.util.PortUtil;
|
||||||
*/
|
*/
|
||||||
public class CreateTest {
|
public class CreateTest {
|
||||||
private static CloseableHttpClient ourClient;
|
private static CloseableHttpClient ourClient;
|
||||||
|
private static final FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
private static EncodingEnum ourLastEncoding;
|
private static EncodingEnum ourLastEncoding;
|
||||||
private static String ourLastResourceBody;
|
private static String ourLastResourceBody;
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(CreateTest.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(CreateTest.class);
|
||||||
private static int ourPort;
|
private static int ourPort;
|
||||||
|
|
||||||
private static DiagnosticReportProvider ourReportProvider;
|
private static DiagnosticReportProvider ourReportProvider;
|
||||||
|
|
||||||
private static Server ourServer;
|
private static Server ourServer;
|
||||||
|
@ -74,7 +74,7 @@ public class CreateTest {
|
||||||
patient.addIdentifier().setValue("002");
|
patient.addIdentifier().setValue("002");
|
||||||
|
|
||||||
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient");
|
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient");
|
||||||
httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||||
|
|
||||||
HttpResponse status = ourClient.execute(httpPost);
|
HttpResponse status = ourClient.execute(httpPost);
|
||||||
|
|
||||||
|
@ -91,31 +91,6 @@ public class CreateTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCreateWithNoParsed() throws Exception {
|
|
||||||
|
|
||||||
Organization org = new Organization();
|
|
||||||
org.addIdentifier().setValue("001");
|
|
||||||
org.addIdentifier().setValue("002");
|
|
||||||
|
|
||||||
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Organization");
|
|
||||||
httpPost.setEntity(new StringEntity(new FhirContext().newJsonParser().encodeResourceToString(org), ContentType.create(Constants.CT_FHIR_JSON, "UTF-8")));
|
|
||||||
|
|
||||||
HttpResponse status = ourClient.execute(httpPost);
|
|
||||||
|
|
||||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
|
||||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
|
||||||
ourLog.info("Response was:\n{}", responseContent);
|
|
||||||
|
|
||||||
assertEquals(201, status.getStatusLine().getStatusCode());
|
|
||||||
assertEquals("http://localhost:" + ourPort + "/Organization/001", status.getFirstHeader("location").getValue());
|
|
||||||
assertThat(status.getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue(), StringContains.containsString("UTF-8"));
|
|
||||||
|
|
||||||
assertThat(ourLastResourceBody, stringContainsInOrder("\"resourceType\":\"Organization\"", "\"identifier\"","\"value\":\"001"));
|
|
||||||
assertEquals(EncodingEnum.JSON, ourLastEncoding);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateById() throws Exception {
|
public void testCreateById() throws Exception {
|
||||||
|
|
||||||
|
@ -124,7 +99,7 @@ public class CreateTest {
|
||||||
patient.addIdentifier().setValue("002");
|
patient.addIdentifier().setValue("002");
|
||||||
|
|
||||||
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/1234");
|
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/1234");
|
||||||
httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||||
|
|
||||||
HttpResponse status = ourClient.execute(httpPost);
|
HttpResponse status = ourClient.execute(httpPost);
|
||||||
|
|
||||||
|
@ -144,7 +119,7 @@ public class CreateTest {
|
||||||
obs.getIdentifier().setValue("001");
|
obs.getIdentifier().setValue("001");
|
||||||
|
|
||||||
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Observation");
|
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Observation");
|
||||||
httpPost.setEntity(new StringEntity(new FhirContext().newJsonParser().encodeResourceToString(obs), ContentType.create(Constants.CT_FHIR_JSON, "UTF-8")));
|
httpPost.setEntity(new StringEntity(ourCtx.newJsonParser().encodeResourceToString(obs), ContentType.create(Constants.CT_FHIR_JSON, "UTF-8")));
|
||||||
|
|
||||||
HttpResponse status = ourClient.execute(httpPost);
|
HttpResponse status = ourClient.execute(httpPost);
|
||||||
|
|
||||||
|
@ -166,7 +141,7 @@ public class CreateTest {
|
||||||
patient.addIdentifier().setValue("002");
|
patient.addIdentifier().setValue("002");
|
||||||
|
|
||||||
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient");
|
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient");
|
||||||
httpPost.setEntity(new StringEntity(new FhirContext().newJsonParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_JSON, "UTF-8")));
|
httpPost.setEntity(new StringEntity(ourCtx.newJsonParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_JSON, "UTF-8")));
|
||||||
|
|
||||||
HttpResponse status = ourClient.execute(httpPost);
|
HttpResponse status = ourClient.execute(httpPost);
|
||||||
|
|
||||||
|
@ -180,6 +155,31 @@ public class CreateTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateWithNoParsed() throws Exception {
|
||||||
|
|
||||||
|
Organization org = new Organization();
|
||||||
|
org.addIdentifier().setValue("001");
|
||||||
|
org.addIdentifier().setValue("002");
|
||||||
|
|
||||||
|
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Organization");
|
||||||
|
httpPost.setEntity(new StringEntity(ourCtx.newJsonParser().encodeResourceToString(org), ContentType.create(Constants.CT_FHIR_JSON, "UTF-8")));
|
||||||
|
|
||||||
|
HttpResponse status = ourClient.execute(httpPost);
|
||||||
|
|
||||||
|
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||||
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
ourLog.info("Response was:\n{}", responseContent);
|
||||||
|
|
||||||
|
assertEquals(201, status.getStatusLine().getStatusCode());
|
||||||
|
assertEquals("http://localhost:" + ourPort + "/Organization/001", status.getFirstHeader("location").getValue());
|
||||||
|
assertThat(status.getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue(), StringContains.containsString("UTF-8"));
|
||||||
|
|
||||||
|
assertThat(ourLastResourceBody, stringContainsInOrder("\"resourceType\":\"Organization\"", "\"identifier\"","\"value\":\"001"));
|
||||||
|
assertEquals(EncodingEnum.JSON, ourLastEncoding);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateWithUnprocessableEntity() throws Exception {
|
public void testCreateWithUnprocessableEntity() throws Exception {
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ public class CreateTest {
|
||||||
report.getIdentifier().setValue("001");
|
report.getIdentifier().setValue("001");
|
||||||
|
|
||||||
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/DiagnosticReport");
|
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/DiagnosticReport");
|
||||||
httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(report), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(report), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||||
|
|
||||||
HttpResponse status = ourClient.execute(httpPost);
|
HttpResponse status = ourClient.execute(httpPost);
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ public class CreateTest {
|
||||||
|
|
||||||
assertEquals(422, status.getStatusLine().getStatusCode());
|
assertEquals(422, status.getStatusLine().getStatusCode());
|
||||||
|
|
||||||
OperationOutcome outcome = new FhirContext().newXmlParser().parseResource(OperationOutcome.class, new StringReader(responseContent));
|
OperationOutcome outcome = ourCtx.newXmlParser().parseResource(OperationOutcome.class, new StringReader(responseContent));
|
||||||
assertEquals("FOOBAR", outcome.getIssueFirstRep().getDetails().getValue());
|
assertEquals("FOOBAR", outcome.getIssueFirstRep().getDetails().getValue());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -218,7 +218,7 @@ public class CreateTest {
|
||||||
ourReportProvider = new DiagnosticReportProvider();
|
ourReportProvider = new DiagnosticReportProvider();
|
||||||
|
|
||||||
ServletHandler proxyHandler = new ServletHandler();
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
RestfulServer servlet = new RestfulServer();
|
RestfulServer servlet = new RestfulServer(ourCtx);
|
||||||
servlet.setResourceProviders(
|
servlet.setResourceProviders(
|
||||||
patientProvider, ourReportProvider, new DummyAdverseReactionResourceProvider(), new CustomObservationProvider(),
|
patientProvider, ourReportProvider, new DummyAdverseReactionResourceProvider(), new CustomObservationProvider(),
|
||||||
new OrganizationProvider());
|
new OrganizationProvider());
|
||||||
|
@ -329,6 +329,23 @@ public class CreateTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class OrganizationProvider implements IResourceProvider {
|
||||||
|
|
||||||
|
@Create()
|
||||||
|
public MethodOutcome create(@ResourceParam String theResourceBody, @ResourceParam EncodingEnum theEncoding) {
|
||||||
|
ourLastResourceBody=theResourceBody;
|
||||||
|
ourLastEncoding=theEncoding;
|
||||||
|
|
||||||
|
return new MethodOutcome(new IdDt("001"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends IResource> getResourceType() {
|
||||||
|
return Organization.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static class PatientProvider implements IResourceProvider {
|
public static class PatientProvider implements IResourceProvider {
|
||||||
|
|
||||||
@Create()
|
@Create()
|
||||||
|
@ -351,21 +368,4 @@ public class CreateTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class OrganizationProvider implements IResourceProvider {
|
|
||||||
|
|
||||||
@Create()
|
|
||||||
public MethodOutcome create(@ResourceParam String theResourceBody, @ResourceParam EncodingEnum theEncoding) {
|
|
||||||
ourLastResourceBody=theResourceBody;
|
|
||||||
ourLastEncoding=theEncoding;
|
|
||||||
|
|
||||||
return new MethodOutcome(new IdDt("001"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<? extends IResource> getResourceType() {
|
|
||||||
return Organization.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,7 +165,7 @@ public class CustomTypeTest {
|
||||||
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
|
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
|
||||||
|
|
||||||
ServletHandler proxyHandler = new ServletHandler();
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
ourServlet = new RestfulServer();
|
ourServlet = new RestfulServer(ourCtx);
|
||||||
ourServlet.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
|
ourServlet.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
|
||||||
|
|
||||||
ourServlet.setResourceProviders(patientProvider);
|
ourServlet.setResourceProviders(patientProvider);
|
||||||
|
|
|
@ -20,6 +20,7 @@ import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||||
import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator;
|
import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator;
|
||||||
|
@ -37,6 +38,7 @@ public class DateRangeParamSearchTest {
|
||||||
private static CloseableHttpClient ourClient;
|
private static CloseableHttpClient ourClient;
|
||||||
private static int ourPort;
|
private static int ourPort;
|
||||||
private static Server ourServer;
|
private static Server ourServer;
|
||||||
|
private static final FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSearchForOneUnqualifiedDate() throws Exception {
|
public void testSearchForOneUnqualifiedDate() throws Exception {
|
||||||
|
@ -85,7 +87,7 @@ public class DateRangeParamSearchTest {
|
||||||
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
|
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
|
||||||
|
|
||||||
ServletHandler proxyHandler = new ServletHandler();
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
RestfulServer servlet = new RestfulServer();
|
RestfulServer servlet = new RestfulServer(ourCtx);
|
||||||
servlet.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
|
servlet.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
|
||||||
|
|
||||||
servlet.setResourceProviders(patientProvider);
|
servlet.setResourceProviders(patientProvider);
|
||||||
|
|
|
@ -44,9 +44,8 @@ public class DefaultEncodingTest {
|
||||||
private static CloseableHttpClient ourClient;
|
private static CloseableHttpClient ourClient;
|
||||||
private static int ourPort;
|
private static int ourPort;
|
||||||
private static Server ourServer;
|
private static Server ourServer;
|
||||||
private static FhirContext ourCtx;
|
private static final FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
private static RestfulServer ourRestfulServer;
|
private static RestfulServer ourRestfulServer;
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(DefaultEncodingTest.class);
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testReadWithDefaultJsonPretty() throws Exception {
|
public void testReadWithDefaultJsonPretty() throws Exception {
|
||||||
|
@ -135,8 +134,7 @@ public class DefaultEncodingTest {
|
||||||
ourServer = new Server(ourPort);
|
ourServer = new Server(ourPort);
|
||||||
|
|
||||||
ServletHandler proxyHandler = new ServletHandler();
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
ourRestfulServer = new RestfulServer();
|
ourRestfulServer = new RestfulServer(ourCtx);
|
||||||
ourCtx = ourRestfulServer.getFhirContext();
|
|
||||||
ourRestfulServer.setResourceProviders(new PatientProvider());
|
ourRestfulServer.setResourceProviders(new PatientProvider());
|
||||||
ServletHolder servletHolder = new ServletHolder(ourRestfulServer);
|
ServletHolder servletHolder = new ServletHolder(ourRestfulServer);
|
||||||
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
||||||
|
|
|
@ -1,23 +1,22 @@
|
||||||
package ca.uhn.fhir.rest.server;
|
package ca.uhn.fhir.rest.server;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import javax.servlet.ServletException;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.runners.MockitoJUnitRunner;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
import ca.uhn.fhir.model.dstu.resource.DiagnosticReport;
|
import ca.uhn.fhir.model.dstu.resource.DiagnosticReport;
|
||||||
import ca.uhn.fhir.rest.annotation.Create;
|
import ca.uhn.fhir.rest.annotation.Create;
|
||||||
import ca.uhn.fhir.rest.annotation.Destroy;
|
import ca.uhn.fhir.rest.annotation.Destroy;
|
||||||
import ca.uhn.fhir.rest.annotation.ResourceParam;
|
import ca.uhn.fhir.rest.annotation.ResourceParam;
|
||||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.mockito.Mock;
|
|
||||||
import org.mockito.runners.MockitoJUnitRunner;
|
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import static org.mockito.Mockito.spy;
|
|
||||||
import static org.mockito.Mockito.verify;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Bill de Beaubien on 11/10/2014.
|
* Created by Bill de Beaubien on 11/10/2014.
|
||||||
|
@ -26,70 +25,72 @@ import static org.mockito.Mockito.verify;
|
||||||
@RunWith(MockitoJUnitRunner.class)
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
public class DestroyTest {
|
public class DestroyTest {
|
||||||
|
|
||||||
@Test
|
private static final FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
public void testDestroyCallsAnnotatedMethodsOnProviders() throws ServletException {
|
|
||||||
RestfulServer servlet = new RestfulServer();
|
|
||||||
DiagnosticReportProvider provider = spy(new DiagnosticReportProvider());
|
|
||||||
servlet.setResourceProviders(Arrays.asList((IResourceProvider) provider));
|
|
||||||
servlet.init();
|
|
||||||
servlet.destroy();
|
|
||||||
verify(provider).destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testChainsUpThroughSuperclasses() throws ServletException {
|
public void testDestroyCallsAnnotatedMethodsOnProviders() throws ServletException {
|
||||||
RestfulServer servlet = new RestfulServer();
|
RestfulServer servlet = new RestfulServer(ourCtx);
|
||||||
DerivedDiagnosticReportProvider provider = spy(new DerivedDiagnosticReportProvider());
|
DiagnosticReportProvider provider = spy(new DiagnosticReportProvider());
|
||||||
servlet.setResourceProviders(Arrays.asList((IResourceProvider) provider));
|
servlet.setResourceProviders(Arrays.asList((IResourceProvider) provider));
|
||||||
servlet.init();
|
servlet.init();
|
||||||
servlet.destroy();
|
servlet.destroy();
|
||||||
verify(provider).destroy();
|
verify(provider).destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoDestroyDoesNotCauseInfiniteRecursion() throws ServletException {
|
public void testChainsUpThroughSuperclasses() throws ServletException {
|
||||||
RestfulServer servlet = new RestfulServer();
|
RestfulServer servlet = new RestfulServer(ourCtx);
|
||||||
DiagnosticReportProviderSansDestroy provider = new DiagnosticReportProviderSansDestroy();
|
DerivedDiagnosticReportProvider provider = spy(new DerivedDiagnosticReportProvider());
|
||||||
servlet.setResourceProviders(Arrays.asList((IResourceProvider) provider));
|
servlet.setResourceProviders(Arrays.asList((IResourceProvider) provider));
|
||||||
servlet.init();
|
servlet.init();
|
||||||
servlet.destroy();
|
servlet.destroy();
|
||||||
// nothing to verify other than the test didn't hang forever
|
verify(provider).destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DiagnosticReportProvider implements IResourceProvider {
|
@Test
|
||||||
|
public void testNoDestroyDoesNotCauseInfiniteRecursion() throws ServletException {
|
||||||
|
RestfulServer servlet = new RestfulServer(ourCtx);
|
||||||
|
DiagnosticReportProviderSansDestroy provider = new DiagnosticReportProviderSansDestroy();
|
||||||
|
servlet.setResourceProviders(Arrays.asList((IResourceProvider) provider));
|
||||||
|
servlet.init();
|
||||||
|
servlet.destroy();
|
||||||
|
// nothing to verify other than the test didn't hang forever
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
public class DiagnosticReportProvider implements IResourceProvider {
|
||||||
public Class<? extends IResource> getResourceType() {
|
|
||||||
return DiagnosticReport.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Create
|
@Override
|
||||||
public MethodOutcome createResource(@ResourceParam DiagnosticReport theDiagnosticReport) {
|
public Class<? extends IResource> getResourceType() {
|
||||||
// do nothing
|
return DiagnosticReport.class;
|
||||||
return new MethodOutcome();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Destroy
|
@Create
|
||||||
public void destroy() {
|
public MethodOutcome createResource(@ResourceParam DiagnosticReport theDiagnosticReport) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
return new MethodOutcome();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DerivedDiagnosticReportProvider extends DiagnosticReportProvider {
|
@Destroy
|
||||||
// move along, nothing to see here
|
public void destroy() {
|
||||||
}
|
// do nothing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class DiagnosticReportProviderSansDestroy implements IResourceProvider {
|
public class DerivedDiagnosticReportProvider extends DiagnosticReportProvider {
|
||||||
|
// move along, nothing to see here
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
public class DiagnosticReportProviderSansDestroy implements IResourceProvider {
|
||||||
public Class<? extends IResource> getResourceType() {
|
|
||||||
return DiagnosticReport.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Create
|
@Override
|
||||||
public MethodOutcome createResource(@ResourceParam DiagnosticReport theDiagnosticReport) {
|
public Class<? extends IResource> getResourceType() {
|
||||||
// do nothing
|
return DiagnosticReport.class;
|
||||||
return new MethodOutcome();
|
}
|
||||||
}
|
|
||||||
}
|
@Create
|
||||||
|
public MethodOutcome createResource(@ResourceParam DiagnosticReport theDiagnosticReport) {
|
||||||
|
// do nothing
|
||||||
|
return new MethodOutcome();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ import ca.uhn.fhir.util.PortUtil;
|
||||||
public class DynamicSearchTest {
|
public class DynamicSearchTest {
|
||||||
|
|
||||||
private static CloseableHttpClient ourClient;
|
private static CloseableHttpClient ourClient;
|
||||||
private static FhirContext ourCtx = new FhirContext();
|
private static FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(DynamicSearchTest.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(DynamicSearchTest.class);
|
||||||
private static int ourPort;
|
private static int ourPort;
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ public class DynamicSearchTest {
|
||||||
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
|
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
|
||||||
|
|
||||||
ServletHandler proxyHandler = new ServletHandler();
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
RestfulServer servlet = new RestfulServer();
|
RestfulServer servlet = new RestfulServer(ourCtx);
|
||||||
servlet.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
|
servlet.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
|
||||||
|
|
||||||
servlet.setResourceProviders(patientProvider);
|
servlet.setResourceProviders(patientProvider);
|
||||||
|
|
|
@ -23,6 +23,7 @@ import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
import ca.uhn.fhir.model.dstu.resource.OperationOutcome;
|
import ca.uhn.fhir.model.dstu.resource.OperationOutcome;
|
||||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||||
|
@ -52,6 +53,7 @@ public class ExceptionTest {
|
||||||
private static int ourPort;
|
private static int ourPort;
|
||||||
private static Server ourServer;
|
private static Server ourServer;
|
||||||
private static RestfulServer servlet;
|
private static RestfulServer servlet;
|
||||||
|
private static final FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void before() {
|
public void before() {
|
||||||
|
@ -189,7 +191,7 @@ public class ExceptionTest {
|
||||||
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
|
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
|
||||||
|
|
||||||
ServletHandler proxyHandler = new ServletHandler();
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
servlet = new RestfulServer();
|
servlet = new RestfulServer(ourCtx);
|
||||||
servlet.setResourceProviders(patientProvider);
|
servlet.setResourceProviders(patientProvider);
|
||||||
ServletHolder servletHolder = new ServletHolder(servlet);
|
ServletHolder servletHolder = new ServletHolder(servlet);
|
||||||
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
||||||
|
|
|
@ -37,24 +37,26 @@ import ca.uhn.fhir.util.PortUtil;
|
||||||
public class HistoryTest {
|
public class HistoryTest {
|
||||||
|
|
||||||
private static CloseableHttpClient ourClient;
|
private static CloseableHttpClient ourClient;
|
||||||
|
private static FhirContext ourCtx= FhirContext.forDstu1();
|
||||||
private static int ourPort;
|
private static int ourPort;
|
||||||
|
|
||||||
private static Server ourServer;
|
private static Server ourServer;
|
||||||
|
|
||||||
/**
|
|
||||||
* We test this here because of bug 3- At one point VRead would "steal" instance history calls and handle them
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
public void testVread() throws Exception {
|
public void testInstanceHistory() throws Exception {
|
||||||
{
|
{
|
||||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/123/_history/456");
|
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/123/_history");
|
||||||
HttpResponse status = ourClient.execute(httpGet);
|
HttpResponse status = ourClient.execute(httpGet);
|
||||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
|
|
||||||
Patient bundle = new FhirContext().newXmlParser().parseResource(Patient.class, responseContent);
|
Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
|
||||||
assertEquals("vread", bundle.getNameFirstRep().getFamilyFirstRep().getValue());
|
assertEquals(2, bundle.getEntries().size());
|
||||||
|
assertEquals("http://localhost:" + ourPort +"/Patient/ih1/_history/1", bundle.getEntries().get(0).getLinkSelf().getValue());
|
||||||
|
assertEquals("http://localhost:" + ourPort +"/Patient/ih1/_history/2", bundle.getEntries().get(1).getLinkSelf().getValue());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +70,7 @@ public class HistoryTest {
|
||||||
|
|
||||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
|
|
||||||
Bundle bundle = new FhirContext().newXmlParser().parseBundle(responseContent);
|
Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
|
||||||
assertEquals(2, bundle.getEntries().size());
|
assertEquals(2, bundle.getEntries().size());
|
||||||
assertEquals("http://localhost:" + ourPort +"/Patient/h1/_history/1", bundle.getEntries().get(0).getLinkSelf().getValue());
|
assertEquals("http://localhost:" + ourPort +"/Patient/h1/_history/1", bundle.getEntries().get(0).getLinkSelf().getValue());
|
||||||
assertEquals("http://localhost:" + ourPort +"/Patient/h1/_history/2", bundle.getEntries().get(1).getLinkSelf().getValue());
|
assertEquals("http://localhost:" + ourPort +"/Patient/h1/_history/2", bundle.getEntries().get(1).getLinkSelf().getValue());
|
||||||
|
@ -76,24 +78,6 @@ public class HistoryTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testInstanceHistory() throws Exception {
|
|
||||||
{
|
|
||||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/123/_history");
|
|
||||||
HttpResponse status = ourClient.execute(httpGet);
|
|
||||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
|
||||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
|
||||||
|
|
||||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
|
||||||
|
|
||||||
Bundle bundle = new FhirContext().newXmlParser().parseBundle(responseContent);
|
|
||||||
assertEquals(2, bundle.getEntries().size());
|
|
||||||
assertEquals("http://localhost:" + ourPort +"/Patient/ih1/_history/1", bundle.getEntries().get(0).getLinkSelf().getValue());
|
|
||||||
assertEquals("http://localhost:" + ourPort +"/Patient/ih1/_history/2", bundle.getEntries().get(1).getLinkSelf().getValue());
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTypeHistory() throws Exception {
|
public void testTypeHistory() throws Exception {
|
||||||
{
|
{
|
||||||
|
@ -104,7 +88,7 @@ public class HistoryTest {
|
||||||
|
|
||||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
|
|
||||||
Bundle bundle = new FhirContext().newXmlParser().parseBundle(responseContent);
|
Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
|
||||||
assertEquals(2, bundle.getEntries().size());
|
assertEquals(2, bundle.getEntries().size());
|
||||||
assertEquals("http://localhost:" + ourPort +"/Patient/th1/_history/1", bundle.getEntries().get(0).getLinkSelf().getValue());
|
assertEquals("http://localhost:" + ourPort +"/Patient/th1/_history/1", bundle.getEntries().get(0).getLinkSelf().getValue());
|
||||||
assertEquals("http://localhost:" + ourPort +"/Patient/th1/_history/2", bundle.getEntries().get(1).getLinkSelf().getValue());
|
assertEquals("http://localhost:" + ourPort +"/Patient/th1/_history/2", bundle.getEntries().get(1).getLinkSelf().getValue());
|
||||||
|
@ -112,6 +96,24 @@ public class HistoryTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We test this here because of bug 3- At one point VRead would "steal" instance history calls and handle them
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testVread() throws Exception {
|
||||||
|
{
|
||||||
|
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/123/_history/456");
|
||||||
|
HttpResponse status = ourClient.execute(httpGet);
|
||||||
|
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||||
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
|
|
||||||
|
Patient bundle = ourCtx.newXmlParser().parseResource(Patient.class, responseContent);
|
||||||
|
assertEquals("vread", bundle.getNameFirstRep().getFamilyFirstRep().getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public static void afterClass() throws Exception {
|
public static void afterClass() throws Exception {
|
||||||
ourServer.stop();
|
ourServer.stop();
|
||||||
|
@ -126,7 +128,7 @@ public class HistoryTest {
|
||||||
DummyResourceProvider patientProvider = new DummyResourceProvider();
|
DummyResourceProvider patientProvider = new DummyResourceProvider();
|
||||||
|
|
||||||
ServletHandler proxyHandler = new ServletHandler();
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
RestfulServer servlet = new RestfulServer();
|
RestfulServer servlet = new RestfulServer(ourCtx);
|
||||||
servlet.setPlainProviders(plainProvider);
|
servlet.setPlainProviders(plainProvider);
|
||||||
servlet.setResourceProviders(patientProvider);
|
servlet.setResourceProviders(patientProvider);
|
||||||
ServletHolder servletHolder = new ServletHolder(servlet);
|
ServletHolder servletHolder = new ServletHolder(servlet);
|
||||||
|
@ -141,6 +143,34 @@ public class HistoryTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by dsotnikov on 2/25/2014.
|
||||||
|
*/
|
||||||
|
public static class DummyPlainProvider {
|
||||||
|
|
||||||
|
@History
|
||||||
|
public List<Patient> history(@Since InstantDt theSince) {
|
||||||
|
ArrayList<Patient> retVal = new ArrayList<Patient>();
|
||||||
|
|
||||||
|
Patient patient = new Patient();
|
||||||
|
patient.setId("Patient/h1/_history/1");
|
||||||
|
patient.addName().addFamily("history");
|
||||||
|
retVal.add(patient);
|
||||||
|
|
||||||
|
Patient patient2 = new Patient();
|
||||||
|
patient2.setId("Patient/h1/_history/2");
|
||||||
|
patient2.addName().addFamily("history");
|
||||||
|
retVal.add(patient2);
|
||||||
|
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class DummyResourceProvider implements IResourceProvider {
|
public static class DummyResourceProvider implements IResourceProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -148,14 +178,6 @@ public class HistoryTest {
|
||||||
return Patient.class;
|
return Patient.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Read(version=true)
|
|
||||||
public Patient vread(@IdParam IdDt theId) {
|
|
||||||
Patient retVal = new Patient();
|
|
||||||
retVal.addName().addFamily("vread");
|
|
||||||
retVal.setId(theId);
|
|
||||||
return retVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
@History
|
@History
|
||||||
public List<Patient> instanceHistory(@IdParam IdDt theId) {
|
public List<Patient> instanceHistory(@IdParam IdDt theId) {
|
||||||
ArrayList<Patient> retVal = new ArrayList<Patient>();
|
ArrayList<Patient> retVal = new ArrayList<Patient>();
|
||||||
|
@ -190,35 +212,15 @@ public class HistoryTest {
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Read(version=true)
|
||||||
}
|
public Patient vread(@IdParam IdDt theId) {
|
||||||
|
Patient retVal = new Patient();
|
||||||
|
retVal.addName().addFamily("vread");
|
||||||
/**
|
retVal.setId(theId);
|
||||||
* Created by dsotnikov on 2/25/2014.
|
|
||||||
*/
|
|
||||||
public static class DummyPlainProvider {
|
|
||||||
|
|
||||||
@History
|
|
||||||
public List<Patient> history(@Since InstantDt theSince) {
|
|
||||||
ArrayList<Patient> retVal = new ArrayList<Patient>();
|
|
||||||
|
|
||||||
Patient patient = new Patient();
|
|
||||||
patient.setId("Patient/h1/_history/1");
|
|
||||||
patient.addName().addFamily("history");
|
|
||||||
retVal.add(patient);
|
|
||||||
|
|
||||||
Patient patient2 = new Patient();
|
|
||||||
patient2.setId("Patient/h1/_history/2");
|
|
||||||
patient2.addName().addFamily("history");
|
|
||||||
retVal.add(patient2);
|
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,8 +89,7 @@ public class IncludeTest {
|
||||||
assertEquals("foo", p.getName().get(0).getFamilyFirstRep().getValue());
|
assertEquals("foo", p.getName().get(0).getFamilyFirstRep().getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Test
|
||||||
// @Test
|
|
||||||
public void testMixedContainedAndNonContained() throws Exception {
|
public void testMixedContainedAndNonContained() throws Exception {
|
||||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/DiagnosticReport?_query=stitchedInclude&_pretty=true");
|
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/DiagnosticReport?_query=stitchedInclude&_pretty=true");
|
||||||
HttpResponse status = ourClient.execute(httpGet);
|
HttpResponse status = ourClient.execute(httpGet);
|
||||||
|
@ -104,7 +103,6 @@ public class IncludeTest {
|
||||||
assertEquals(4, bundle.size());
|
assertEquals(4, bundle.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIIncludedResourcesNonContained() throws Exception {
|
public void testIIncludedResourcesNonContained() throws Exception {
|
||||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=normalInclude&_pretty=true");
|
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=normalInclude&_pretty=true");
|
||||||
|
@ -123,11 +121,10 @@ public class IncludeTest {
|
||||||
assertEquals(new IdDt("Organization/o1"), bundle.toListOfResources().get(2).getId().toUnqualifiedVersionless());
|
assertEquals(new IdDt("Organization/o1"), bundle.toListOfResources().get(2).getId().toUnqualifiedVersionless());
|
||||||
|
|
||||||
Patient p1 = (Patient) bundle.toListOfResources().get(0);
|
Patient p1 = (Patient) bundle.toListOfResources().get(0);
|
||||||
assertEquals(0,p1.getContained().getContainedResources().size());
|
assertEquals(0, p1.getContained().getContainedResources().size());
|
||||||
|
|
||||||
Patient p2 = (Patient) bundle.toListOfResources().get(1);
|
Patient p2 = (Patient) bundle.toListOfResources().get(1);
|
||||||
assertEquals(0,p2.getContained().getContainedResources().size());
|
assertEquals(0, p2.getContained().getContainedResources().size());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,15 +146,13 @@ public class IncludeTest {
|
||||||
assertEquals(new IdDt("Organization/o1"), bundle.toListOfResources().get(2).getId().toUnqualifiedVersionless());
|
assertEquals(new IdDt("Organization/o1"), bundle.toListOfResources().get(2).getId().toUnqualifiedVersionless());
|
||||||
|
|
||||||
Patient p1 = (Patient) bundle.toListOfResources().get(0);
|
Patient p1 = (Patient) bundle.toListOfResources().get(0);
|
||||||
assertEquals(0,p1.getContained().getContainedResources().size());
|
assertEquals(0, p1.getContained().getContainedResources().size());
|
||||||
|
|
||||||
Patient p2 = (Patient) bundle.toListOfResources().get(1);
|
Patient p2 = (Patient) bundle.toListOfResources().get(1);
|
||||||
assertEquals(0,p2.getContained().getContainedResources().size());
|
assertEquals(0, p2.getContained().getContainedResources().size());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIIncludedResourcesNonContainedInExtensionJson() throws Exception {
|
public void testIIncludedResourcesNonContainedInExtensionJson() throws Exception {
|
||||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=extInclude&_pretty=true&_format=json");
|
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=extInclude&_pretty=true&_format=json");
|
||||||
|
@ -176,11 +171,10 @@ public class IncludeTest {
|
||||||
assertEquals(new IdDt("Organization/o1"), bundle.toListOfResources().get(2).getId().toUnqualifiedVersionless());
|
assertEquals(new IdDt("Organization/o1"), bundle.toListOfResources().get(2).getId().toUnqualifiedVersionless());
|
||||||
|
|
||||||
Patient p1 = (Patient) bundle.toListOfResources().get(0);
|
Patient p1 = (Patient) bundle.toListOfResources().get(0);
|
||||||
assertEquals(0,p1.getContained().getContainedResources().size());
|
assertEquals(0, p1.getContained().getContainedResources().size());
|
||||||
|
|
||||||
Patient p2 = (Patient) bundle.toListOfResources().get(1);
|
Patient p2 = (Patient) bundle.toListOfResources().get(1);
|
||||||
assertEquals(0,p2.getContained().getContainedResources().size());
|
assertEquals(0, p2.getContained().getContainedResources().size());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,16 +197,13 @@ public class IncludeTest {
|
||||||
assertEquals(new IdDt("Organization/o2"), bundle.toListOfResources().get(3).getId().toUnqualifiedVersionless());
|
assertEquals(new IdDt("Organization/o2"), bundle.toListOfResources().get(3).getId().toUnqualifiedVersionless());
|
||||||
|
|
||||||
Patient p1 = (Patient) bundle.toListOfResources().get(0);
|
Patient p1 = (Patient) bundle.toListOfResources().get(0);
|
||||||
assertEquals(0,p1.getContained().getContainedResources().size());
|
assertEquals(0, p1.getContained().getContainedResources().size());
|
||||||
|
|
||||||
Patient p2 = (Patient) bundle.toListOfResources().get(1);
|
Patient p2 = (Patient) bundle.toListOfResources().get(1);
|
||||||
assertEquals(0,p2.getContained().getContainedResources().size());
|
assertEquals(0, p2.getContained().getContainedResources().size());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTwoInclude() throws Exception {
|
public void testTwoInclude() throws Exception {
|
||||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?name=Hello&_include=foo&_include=bar");
|
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?name=Hello&_include=foo&_include=bar");
|
||||||
|
@ -229,8 +220,8 @@ public class IncludeTest {
|
||||||
assertEquals("Hello", p.getId().getIdPart());
|
assertEquals("Hello", p.getId().getIdPart());
|
||||||
|
|
||||||
Set<String> values = new HashSet<String>();
|
Set<String> values = new HashSet<String>();
|
||||||
values.add( p.getName().get(0).getFamilyFirstRep().getValue());
|
values.add(p.getName().get(0).getFamilyFirstRep().getValue());
|
||||||
values.add( p.getName().get(1).getFamilyFirstRep().getValue());
|
values.add(p.getName().get(1).getFamilyFirstRep().getValue());
|
||||||
assertThat(values, containsInAnyOrder("foo", "bar"));
|
assertThat(values, containsInAnyOrder("foo", "bar"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -244,7 +235,7 @@ public class IncludeTest {
|
||||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
ourLog.info(responseContent);
|
ourLog.info(responseContent);
|
||||||
assertThat(responseContent,containsString("Invalid _include parameter value"));
|
assertThat(responseContent, containsString("Invalid _include parameter value"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
|
@ -255,16 +246,15 @@ public class IncludeTest {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void beforeClass() throws Exception {
|
public static void beforeClass() throws Exception {
|
||||||
|
|
||||||
ourCtx = new FhirContext();
|
ourCtx = FhirContext.forDstu1();
|
||||||
ourPort = PortUtil.findFreePort();
|
ourPort = PortUtil.findFreePort();
|
||||||
ourServer = new Server(ourPort);
|
ourServer = new Server(ourPort);
|
||||||
|
|
||||||
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
|
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
|
||||||
|
|
||||||
ServletHandler proxyHandler = new ServletHandler();
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
RestfulServer servlet = new RestfulServer();
|
RestfulServer servlet = new RestfulServer(ourCtx);
|
||||||
servlet.setFhirContext(ourCtx);
|
servlet.setBundleInclusionRule(BundleInclusionRule.BASED_ON_RESOURCE_PRESENCE);
|
||||||
servlet.setBundleInclusionRule(BundleInclusionRule.BASED_ON_RESOURCE_PRESENCE);
|
|
||||||
servlet.setResourceProviders(patientProvider, new DummyDiagnosticReportResourceProvider());
|
servlet.setResourceProviders(patientProvider, new DummyDiagnosticReportResourceProvider());
|
||||||
ServletHolder servletHolder = new ServletHolder(servlet);
|
ServletHolder servletHolder = new ServletHolder(servlet);
|
||||||
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
||||||
|
@ -278,11 +268,10 @@ public class IncludeTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ResourceDef(name="Patient")
|
@ResourceDef(name = "Patient")
|
||||||
public static class ExtPatient extends Patient
|
public static class ExtPatient extends Patient {
|
||||||
{
|
@Child(name = "secondOrg")
|
||||||
@Child(name="secondOrg")
|
@Extension(url = "http://foo#secondOrg", definedLocally = false, isModifier = false)
|
||||||
@Extension(url="http://foo#secondOrg", definedLocally = false, isModifier = false)
|
|
||||||
private ResourceReferenceDt mySecondOrg;
|
private ResourceReferenceDt mySecondOrg;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -291,8 +280,8 @@ public class IncludeTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResourceReferenceDt getSecondOrg() {
|
public ResourceReferenceDt getSecondOrg() {
|
||||||
if (mySecondOrg==null) {
|
if (mySecondOrg == null) {
|
||||||
mySecondOrg= new ResourceReferenceDt();
|
mySecondOrg = new ResourceReferenceDt();
|
||||||
}
|
}
|
||||||
return mySecondOrg;
|
return mySecondOrg;
|
||||||
}
|
}
|
||||||
|
@ -349,11 +338,8 @@ public class IncludeTest {
|
||||||
return Collections.singletonList(rep);
|
return Collections.singletonList(rep);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by dsotnikov on 2/25/2014.
|
* Created by dsotnikov on 2/25/2014.
|
||||||
*/
|
*/
|
||||||
|
@ -378,7 +364,6 @@ public class IncludeTest {
|
||||||
return Arrays.asList(p1, p2);
|
return Arrays.asList(p1, p2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Search(queryName = "extInclude")
|
@Search(queryName = "extInclude")
|
||||||
public List<Patient> extInclude() {
|
public List<Patient> extInclude() {
|
||||||
Organization o1 = new Organization();
|
Organization o1 = new Organization();
|
||||||
|
@ -422,7 +407,6 @@ public class IncludeTest {
|
||||||
return Arrays.asList(p1, p2);
|
return Arrays.asList(p1, p2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Search(queryName = "containedInclude")
|
@Search(queryName = "containedInclude")
|
||||||
public List<Patient> containedInclude() {
|
public List<Patient> containedInclude() {
|
||||||
Organization o1 = new Organization();
|
Organization o1 = new Organization();
|
||||||
|
@ -442,9 +426,7 @@ public class IncludeTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Search
|
@Search
|
||||||
public List<Patient> findPatientWithSimpleNames(
|
public List<Patient> findPatientWithSimpleNames(@RequiredParam(name = Patient.SP_NAME) StringDt theName, @IncludeParam(allow = { "foo", "bar" }) Set<Include> theIncludes) {
|
||||||
@RequiredParam(name = Patient.SP_NAME) StringDt theName,
|
|
||||||
@IncludeParam(allow = { "foo", "bar" }) Set<Include> theIncludes) {
|
|
||||||
ArrayList<Patient> retVal = new ArrayList<Patient>();
|
ArrayList<Patient> retVal = new ArrayList<Patient>();
|
||||||
|
|
||||||
Patient p = new Patient();
|
Patient p = new Patient();
|
||||||
|
@ -469,7 +451,6 @@ public class IncludeTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
Organization org = new Organization();
|
Organization org = new Organization();
|
||||||
|
@ -481,8 +462,7 @@ public class IncludeTest {
|
||||||
patient.addIdentifier("urn:mrns", "253345");
|
patient.addIdentifier("urn:mrns", "253345");
|
||||||
patient.getManagingOrganization().setResource(patient);
|
patient.getManagingOrganization().setResource(patient);
|
||||||
|
|
||||||
|
System.out.println(FhirContext.forDstu1().newXmlParser().setPrettyPrint(true).encodeResourceToString(patient));
|
||||||
System.out.println(new FhirContext().newXmlParser().setPrettyPrint(true).encodeResourceToString(patient));
|
|
||||||
|
|
||||||
patient.getManagingOrganization().getReference();
|
patient.getManagingOrganization().getReference();
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mockito.InOrder;
|
import org.mockito.InOrder;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
import ca.uhn.fhir.model.dstu.composite.HumanNameDt;
|
import ca.uhn.fhir.model.dstu.composite.HumanNameDt;
|
||||||
import ca.uhn.fhir.model.dstu.composite.IdentifierDt;
|
import ca.uhn.fhir.model.dstu.composite.IdentifierDt;
|
||||||
|
@ -53,6 +54,7 @@ public class InterceptorTest {
|
||||||
private static RestfulServer servlet;
|
private static RestfulServer servlet;
|
||||||
private IServerInterceptor myInterceptor1;
|
private IServerInterceptor myInterceptor1;
|
||||||
private IServerInterceptor myInterceptor2;
|
private IServerInterceptor myInterceptor2;
|
||||||
|
private static final FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInterceptorFires() throws Exception {
|
public void testInterceptorFires() throws Exception {
|
||||||
|
@ -101,7 +103,7 @@ public class InterceptorTest {
|
||||||
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
|
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
|
||||||
|
|
||||||
ServletHandler proxyHandler = new ServletHandler();
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
servlet = new RestfulServer();
|
servlet = new RestfulServer(ourCtx);
|
||||||
servlet.setResourceProviders(patientProvider);
|
servlet.setResourceProviders(patientProvider);
|
||||||
ServletHolder servletHolder = new ServletHolder(servlet);
|
ServletHolder servletHolder = new ServletHolder(servlet);
|
||||||
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
||||||
|
|
|
@ -36,7 +36,7 @@ import ca.uhn.fhir.util.PortUtil;
|
||||||
public class MethodPriorityTest {
|
public class MethodPriorityTest {
|
||||||
|
|
||||||
private static CloseableHttpClient ourClient;
|
private static CloseableHttpClient ourClient;
|
||||||
private static FhirContext ourCtx = new FhirContext();
|
private static FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
private static int ourPort;
|
private static int ourPort;
|
||||||
private static Server ourServer;
|
private static Server ourServer;
|
||||||
private static RestfulServer ourServlet;
|
private static RestfulServer ourServlet;
|
||||||
|
@ -72,8 +72,7 @@ public class MethodPriorityTest {
|
||||||
ourServer = new Server(ourPort);
|
ourServer = new Server(ourPort);
|
||||||
|
|
||||||
ServletHandler proxyHandler = new ServletHandler();
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
ourServlet = new RestfulServer();
|
ourServlet = new RestfulServer(ourCtx);
|
||||||
ourServlet.setFhirContext(ourCtx);
|
|
||||||
ourServlet.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
|
ourServlet.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
|
||||||
|
|
||||||
ServletHolder servletHolder = new ServletHolder(ourServlet);
|
ServletHolder servletHolder = new ServletHolder(ourServlet);
|
||||||
|
|
|
@ -46,6 +46,7 @@ public class PagingTest {
|
||||||
|
|
||||||
private static CloseableHttpClient ourClient;
|
private static CloseableHttpClient ourClient;
|
||||||
private static int ourPort;
|
private static int ourPort;
|
||||||
|
private static final FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
private static Server ourServer;
|
private static Server ourServer;
|
||||||
private static FhirContext ourContext;
|
private static FhirContext ourContext;
|
||||||
private static RestfulServer myRestfulServer;
|
private static RestfulServer myRestfulServer;
|
||||||
|
@ -270,7 +271,7 @@ public class PagingTest {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void beforeClass() throws Exception {
|
public static void beforeClass() throws Exception {
|
||||||
ourContext = new FhirContext();
|
ourContext = FhirContext.forDstu1();
|
||||||
|
|
||||||
ourPort = PortUtil.findFreePort();
|
ourPort = PortUtil.findFreePort();
|
||||||
ourServer = new Server(ourPort);
|
ourServer = new Server(ourPort);
|
||||||
|
@ -278,7 +279,7 @@ public class PagingTest {
|
||||||
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
|
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
|
||||||
|
|
||||||
ServletHandler proxyHandler = new ServletHandler();
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
myRestfulServer = new RestfulServer();
|
myRestfulServer = new RestfulServer(ourCtx);
|
||||||
myRestfulServer.setResourceProviders(patientProvider);
|
myRestfulServer.setResourceProviders(patientProvider);
|
||||||
ServletHolder servletHolder = new ServletHolder(myRestfulServer);
|
ServletHolder servletHolder = new ServletHolder(myRestfulServer);
|
||||||
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
||||||
|
|
|
@ -51,18 +51,17 @@ public class PlainProviderTest {
|
||||||
private int myPort;
|
private int myPort;
|
||||||
private Server myServer;
|
private Server myServer;
|
||||||
private CloseableHttpClient myClient;
|
private CloseableHttpClient myClient;
|
||||||
private FhirContext myCtx;
|
private static final FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
private RestfulServer myRestfulServer;
|
private RestfulServer myRestfulServer;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void before() throws Exception {
|
public void before() throws Exception {
|
||||||
myPort = PortUtil.findFreePort();
|
myPort = PortUtil.findFreePort();
|
||||||
myServer = new Server(myPort);
|
myServer = new Server(myPort);
|
||||||
myCtx = new FhirContext(Patient.class);
|
|
||||||
|
|
||||||
ServletHandler proxyHandler = new ServletHandler();
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
ServletHolder servletHolder = new ServletHolder();
|
ServletHolder servletHolder = new ServletHolder();
|
||||||
myRestfulServer = new RestfulServer();
|
myRestfulServer = new RestfulServer(ourCtx);
|
||||||
servletHolder.setServlet(myRestfulServer);
|
servletHolder.setServlet(myRestfulServer);
|
||||||
proxyHandler.addServletWithMapping(servletHolder, "/fhir/context/*");
|
proxyHandler.addServletWithMapping(servletHolder, "/fhir/context/*");
|
||||||
myServer.setHandler(proxyHandler);
|
myServer.setHandler(proxyHandler);
|
||||||
|
@ -95,7 +94,7 @@ public class PlainProviderTest {
|
||||||
ourLog.info("Response was:\n{}", responseContent);
|
ourLog.info("Response was:\n{}", responseContent);
|
||||||
|
|
||||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
Bundle bundle = myCtx.newXmlParser().parseBundle(responseContent);
|
Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
|
||||||
|
|
||||||
assertEquals(1, bundle.getEntries().size());
|
assertEquals(1, bundle.getEntries().size());
|
||||||
|
|
||||||
|
@ -121,7 +120,7 @@ public class PlainProviderTest {
|
||||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
ourLog.info("Response was:\n{}", responseContent);
|
ourLog.info("Response was:\n{}", responseContent);
|
||||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
Bundle bundle = myCtx.newXmlParser().parseBundle(responseContent);
|
Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
|
||||||
assertEquals(3, bundle.getEntries().size());
|
assertEquals(3, bundle.getEntries().size());
|
||||||
|
|
||||||
assertThat(provider.myLastSince.getValueAsString(), StringStartsWith.startsWith("2012-01-02T00:01:02"));
|
assertThat(provider.myLastSince.getValueAsString(), StringStartsWith.startsWith("2012-01-02T00:01:02"));
|
||||||
|
@ -131,7 +130,7 @@ public class PlainProviderTest {
|
||||||
responseContent = IOUtils.toString(status.getEntity().getContent());
|
responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
bundle = myCtx.newXmlParser().parseBundle(responseContent);
|
bundle = ourCtx.newXmlParser().parseBundle(responseContent);
|
||||||
assertEquals(3, bundle.getEntries().size());
|
assertEquals(3, bundle.getEntries().size());
|
||||||
assertNull(provider.myLastSince.getValueAsString());
|
assertNull(provider.myLastSince.getValueAsString());
|
||||||
assertThat(provider.myLastCount.getValueAsString(), IsEqual.equalTo("12"));
|
assertThat(provider.myLastCount.getValueAsString(), IsEqual.equalTo("12"));
|
||||||
|
@ -140,7 +139,7 @@ public class PlainProviderTest {
|
||||||
responseContent = IOUtils.toString(status.getEntity().getContent());
|
responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
bundle = myCtx.newXmlParser().parseBundle(responseContent);
|
bundle = ourCtx.newXmlParser().parseBundle(responseContent);
|
||||||
assertEquals(3, bundle.getEntries().size());
|
assertEquals(3, bundle.getEntries().size());
|
||||||
assertThat(provider.myLastSince.getValueAsString(), StringStartsWith.startsWith("2012-01-02T00:01:02"));
|
assertThat(provider.myLastSince.getValueAsString(), StringStartsWith.startsWith("2012-01-02T00:01:02"));
|
||||||
assertNull(provider.myLastCount.getValueAsString());
|
assertNull(provider.myLastCount.getValueAsString());
|
||||||
|
@ -149,7 +148,7 @@ public class PlainProviderTest {
|
||||||
responseContent = IOUtils.toString(status.getEntity().getContent());
|
responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
bundle = myCtx.newXmlParser().parseBundle(responseContent);
|
bundle = ourCtx.newXmlParser().parseBundle(responseContent);
|
||||||
assertEquals(3, bundle.getEntries().size());
|
assertEquals(3, bundle.getEntries().size());
|
||||||
assertNull(provider.myLastSince.getValueAsString());
|
assertNull(provider.myLastSince.getValueAsString());
|
||||||
assertNull(provider.myLastCount.getValueAsString());
|
assertNull(provider.myLastCount.getValueAsString());
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
package ca.uhn.fhir.rest.server;
|
package ca.uhn.fhir.rest.server;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.not;
|
import static org.hamcrest.Matchers.*;
|
||||||
import static org.hamcrest.Matchers.stringContainsInOrder;
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@ -22,8 +20,6 @@ import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import com.google.common.net.UrlEscapers;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
import ca.uhn.fhir.model.dstu.composite.IdentifierDt;
|
import ca.uhn.fhir.model.dstu.composite.IdentifierDt;
|
||||||
|
@ -39,13 +35,13 @@ import ca.uhn.fhir.util.PortUtil;
|
||||||
/**
|
/**
|
||||||
* Created by dsotnikov on 2/25/2014.
|
* Created by dsotnikov on 2/25/2014.
|
||||||
*/
|
*/
|
||||||
public class ReadTest {
|
public class ReadDstu1Test {
|
||||||
|
|
||||||
private static CloseableHttpClient ourClient;
|
private static CloseableHttpClient ourClient;
|
||||||
private static int ourPort;
|
private static int ourPort;
|
||||||
private static Server ourServer;
|
private static Server ourServer;
|
||||||
private static FhirContext ourCtx;
|
private static final FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ReadTest.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ReadDstu1Test.class);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testReadXml() throws Exception {
|
public void testReadXml() throws Exception {
|
||||||
|
@ -205,8 +201,8 @@ public class ReadTest {
|
||||||
PatientProvider patientProvider = new PatientProvider();
|
PatientProvider patientProvider = new PatientProvider();
|
||||||
|
|
||||||
ServletHandler proxyHandler = new ServletHandler();
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
RestfulServer servlet = new RestfulServer();
|
RestfulServer servlet = new RestfulServer(ourCtx);
|
||||||
ourCtx = servlet.getFhirContext();
|
|
||||||
servlet.setResourceProviders(patientProvider, new BinaryProvider(), new OrganizationProviderWithAbstractReturnType());
|
servlet.setResourceProviders(patientProvider, new BinaryProvider(), new OrganizationProviderWithAbstractReturnType());
|
||||||
ServletHolder servletHolder = new ServletHolder(servlet);
|
ServletHolder servletHolder = new ServletHolder(servlet);
|
||||||
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
|
@ -53,7 +53,7 @@ import ca.uhn.fhir.util.PortUtil;
|
||||||
public class ReferenceParameterTest {
|
public class ReferenceParameterTest {
|
||||||
|
|
||||||
private static CloseableHttpClient ourClient;
|
private static CloseableHttpClient ourClient;
|
||||||
private static FhirContext ourCtx;
|
private static final FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ReferenceParameterTest.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ReferenceParameterTest.class);
|
||||||
private static int ourPort;
|
private static int ourPort;
|
||||||
private static Server ourServer;
|
private static Server ourServer;
|
||||||
|
@ -298,9 +298,8 @@ public class ReferenceParameterTest {
|
||||||
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
|
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
|
||||||
|
|
||||||
ServletHandler proxyHandler = new ServletHandler();
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
RestfulServer servlet = new RestfulServer();
|
RestfulServer servlet = new RestfulServer(ourCtx);
|
||||||
servlet.setBundleInclusionRule(BundleInclusionRule.BASED_ON_RESOURCE_PRESENCE);
|
servlet.setBundleInclusionRule(BundleInclusionRule.BASED_ON_RESOURCE_PRESENCE);
|
||||||
ourCtx = servlet.getFhirContext();
|
|
||||||
servlet.setResourceProviders(patientProvider, new DummyOrganizationResourceProvider(), new DummyLocationResourceProvider());
|
servlet.setResourceProviders(patientProvider, new DummyOrganizationResourceProvider(), new DummyLocationResourceProvider());
|
||||||
ServletHolder servletHolder = new ServletHolder(servlet);
|
ServletHolder servletHolder = new ServletHolder(servlet);
|
||||||
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
||||||
|
@ -311,8 +310,6 @@ public class ReferenceParameterTest {
|
||||||
HttpClientBuilder builder = HttpClientBuilder.create();
|
HttpClientBuilder builder = HttpClientBuilder.create();
|
||||||
builder.setConnectionManager(connectionManager);
|
builder.setConnectionManager(connectionManager);
|
||||||
ourClient = builder.build();
|
ourClient = builder.build();
|
||||||
|
|
||||||
ourCtx = servlet.getFhirContext();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class DummyLocationResourceProvider implements IResourceProvider {
|
public static class DummyLocationResourceProvider implements IResourceProvider {
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class ResourceMethodTest {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void before() throws NoSuchMethodException, SecurityException {
|
public void before() throws NoSuchMethodException, SecurityException {
|
||||||
rm = new SearchMethodBinding(Patient.class, ResourceMethodTest.class.getMethod("foo"), new FhirContext(), null);
|
rm = new SearchMethodBinding(Patient.class, ResourceMethodTest.class.getMethod("foo"), FhirContext.forDstu1(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -10,6 +10,7 @@ import org.eclipse.jetty.servlet.ServletHolder;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
import ca.uhn.fhir.model.dstu.resource.Binary;
|
import ca.uhn.fhir.model.dstu.resource.Binary;
|
||||||
import ca.uhn.fhir.model.primitive.IdDt;
|
import ca.uhn.fhir.model.primitive.IdDt;
|
||||||
|
@ -20,6 +21,7 @@ import ca.uhn.fhir.util.PortUtil;
|
||||||
public class ResourceProviderWithNoMethodsTest {
|
public class ResourceProviderWithNoMethodsTest {
|
||||||
|
|
||||||
private Server ourServer;
|
private Server ourServer;
|
||||||
|
private static final FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void after() throws Exception {
|
public void after() throws Exception {
|
||||||
|
@ -34,7 +36,7 @@ public class ResourceProviderWithNoMethodsTest {
|
||||||
ResourceProvider patientProvider = new ResourceProvider();
|
ResourceProvider patientProvider = new ResourceProvider();
|
||||||
|
|
||||||
ServletHandler proxyHandler = new ServletHandler();
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
RestfulServer servlet = new RestfulServer();
|
RestfulServer servlet = new RestfulServer(ourCtx);
|
||||||
servlet.setResourceProviders(patientProvider);
|
servlet.setResourceProviders(patientProvider);
|
||||||
ServletHolder servletHolder = new ServletHolder(servlet);
|
ServletHolder servletHolder = new ServletHolder(servlet);
|
||||||
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
||||||
|
@ -56,7 +58,7 @@ public class ResourceProviderWithNoMethodsTest {
|
||||||
NonPublicMethodProvider patientProvider = new NonPublicMethodProvider();
|
NonPublicMethodProvider patientProvider = new NonPublicMethodProvider();
|
||||||
|
|
||||||
ServletHandler proxyHandler = new ServletHandler();
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
RestfulServer servlet = new RestfulServer();
|
RestfulServer servlet = new RestfulServer(ourCtx);
|
||||||
servlet.setResourceProviders(patientProvider);
|
servlet.setResourceProviders(patientProvider);
|
||||||
ServletHolder servletHolder = new ServletHolder(servlet);
|
ServletHolder servletHolder = new ServletHolder(servlet);
|
||||||
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
||||||
|
|
|
@ -91,7 +91,7 @@ import ca.uhn.fhir.util.PortUtil;
|
||||||
public class RestfulServerMethodTest {
|
public class RestfulServerMethodTest {
|
||||||
|
|
||||||
private static CloseableHttpClient ourClient;
|
private static CloseableHttpClient ourClient;
|
||||||
private static FhirContext ourCtx;
|
private static final FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(RestfulServerMethodTest.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(RestfulServerMethodTest.class);
|
||||||
private static int ourPort;
|
private static int ourPort;
|
||||||
private static DummyDiagnosticReportResourceProvider ourReportProvider;
|
private static DummyDiagnosticReportResourceProvider ourReportProvider;
|
||||||
|
@ -951,7 +951,7 @@ public class RestfulServerMethodTest {
|
||||||
patient.addName().addFamily("FOO");
|
patient.addName().addFamily("FOO");
|
||||||
|
|
||||||
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/_validate");
|
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/_validate");
|
||||||
httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||||
|
|
||||||
HttpResponse status = ourClient.execute(httpPost);
|
HttpResponse status = ourClient.execute(httpPost);
|
||||||
|
|
||||||
|
@ -962,7 +962,7 @@ public class RestfulServerMethodTest {
|
||||||
assertThat(responseContent, not(containsString("\n ")));
|
assertThat(responseContent, not(containsString("\n ")));
|
||||||
|
|
||||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
OperationOutcome oo = new FhirContext().newXmlParser().parseResource(OperationOutcome.class, responseContent);
|
OperationOutcome oo = ourCtx.newXmlParser().parseResource(OperationOutcome.class, responseContent);
|
||||||
assertEquals("it passed", oo.getIssueFirstRep().getDetails().getValue());
|
assertEquals("it passed", oo.getIssueFirstRep().getDetails().getValue());
|
||||||
|
|
||||||
// Now should fail
|
// Now should fail
|
||||||
|
@ -971,7 +971,7 @@ public class RestfulServerMethodTest {
|
||||||
patient.addName().addFamily("BAR");
|
patient.addName().addFamily("BAR");
|
||||||
|
|
||||||
httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/_validate");
|
httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/_validate");
|
||||||
httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||||
|
|
||||||
status = ourClient.execute(httpPost);
|
status = ourClient.execute(httpPost);
|
||||||
|
|
||||||
|
@ -981,7 +981,7 @@ public class RestfulServerMethodTest {
|
||||||
ourLog.info("Response was:\n{}", responseContent);
|
ourLog.info("Response was:\n{}", responseContent);
|
||||||
|
|
||||||
assertEquals(422, status.getStatusLine().getStatusCode());
|
assertEquals(422, status.getStatusLine().getStatusCode());
|
||||||
oo = new FhirContext().newXmlParser().parseResource(OperationOutcome.class, responseContent);
|
oo = ourCtx.newXmlParser().parseResource(OperationOutcome.class, responseContent);
|
||||||
assertEquals("it failed", oo.getIssueFirstRep().getDetails().getValue());
|
assertEquals("it failed", oo.getIssueFirstRep().getDetails().getValue());
|
||||||
|
|
||||||
// Should fail with outcome
|
// Should fail with outcome
|
||||||
|
@ -990,7 +990,7 @@ public class RestfulServerMethodTest {
|
||||||
patient.addName().addFamily("BAZ");
|
patient.addName().addFamily("BAZ");
|
||||||
|
|
||||||
httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/_validate");
|
httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/_validate");
|
||||||
httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||||
|
|
||||||
status = ourClient.execute(httpPost);
|
status = ourClient.execute(httpPost);
|
||||||
|
|
||||||
|
@ -1010,7 +1010,7 @@ public class RestfulServerMethodTest {
|
||||||
patient.addName().addFamily("FOO");
|
patient.addName().addFamily("FOO");
|
||||||
|
|
||||||
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/_validate?_pretty=true");
|
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/_validate?_pretty=true");
|
||||||
httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||||
|
|
||||||
HttpResponse status = ourClient.execute(httpPost);
|
HttpResponse status = ourClient.execute(httpPost);
|
||||||
|
|
||||||
|
@ -1065,7 +1065,6 @@ public class RestfulServerMethodTest {
|
||||||
public static void beforeClass() throws Exception {
|
public static void beforeClass() throws Exception {
|
||||||
ourPort = PortUtil.findFreePort();
|
ourPort = PortUtil.findFreePort();
|
||||||
ourServer = new Server(ourPort);
|
ourServer = new Server(ourPort);
|
||||||
ourCtx = new FhirContext(Patient.class);
|
|
||||||
|
|
||||||
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
|
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
|
||||||
ourReportProvider = new DummyDiagnosticReportResourceProvider();
|
ourReportProvider = new DummyDiagnosticReportResourceProvider();
|
||||||
|
@ -1429,6 +1428,7 @@ public class RestfulServerMethodTest {
|
||||||
private Collection<IResourceProvider> myResourceProviders;
|
private Collection<IResourceProvider> myResourceProviders;
|
||||||
|
|
||||||
public DummyRestfulServer(IResourceProvider... theResourceProviders) {
|
public DummyRestfulServer(IResourceProvider... theResourceProviders) {
|
||||||
|
super(ourCtx);
|
||||||
myResourceProviders = new ArrayList<IResourceProvider>(Arrays.asList(theResourceProviders));
|
myResourceProviders = new ArrayList<IResourceProvider>(Arrays.asList(theResourceProviders));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class RestfulServerSelfReferenceTest {
|
||||||
int port = PortUtil.findFreePort();
|
int port = PortUtil.findFreePort();
|
||||||
Server server = new Server(port);
|
Server server = new Server(port);
|
||||||
|
|
||||||
RestfulServer restServer = new RestfulServer();
|
RestfulServer restServer = new RestfulServer(ourCtx);
|
||||||
restServer.setFhirContext(ourCtx);
|
restServer.setFhirContext(ourCtx);
|
||||||
restServer.setResourceProviders(new DummyPatientResourceProvider());
|
restServer.setResourceProviders(new DummyPatientResourceProvider());
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ public class RestfulServerSelfReferenceTest {
|
||||||
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
|
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
|
||||||
|
|
||||||
ServletHandler proxyHandler = new ServletHandler();
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
RestfulServer server = new RestfulServer();
|
RestfulServer server = new RestfulServer(ourCtx);
|
||||||
ServerProfileProvider profProvider = new ServerProfileProvider(server);
|
ServerProfileProvider profProvider = new ServerProfileProvider(server);
|
||||||
server.setFhirContext(ourCtx);
|
server.setFhirContext(ourCtx);
|
||||||
server.setResourceProviders(patientProvider, profProvider);
|
server.setResourceProviders(patientProvider, profProvider);
|
||||||
|
|
|
@ -66,11 +66,11 @@ import com.google.common.net.UrlEscapers;
|
||||||
/**
|
/**
|
||||||
* Created by dsotnikov on 2/25/2014.
|
* Created by dsotnikov on 2/25/2014.
|
||||||
*/
|
*/
|
||||||
public class SearchTest {
|
public class SearchSearchServerDstu1Test {
|
||||||
|
|
||||||
private static CloseableHttpClient ourClient;
|
private static CloseableHttpClient ourClient;
|
||||||
private static FhirContext ourCtx = new FhirContext();
|
private static FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SearchTest.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SearchSearchServerDstu1Test.class);
|
||||||
private static int ourPort;
|
private static int ourPort;
|
||||||
|
|
||||||
private static Server ourServer;
|
private static Server ourServer;
|
|
@ -35,7 +35,7 @@ public class ServerBaseTest {
|
||||||
private static CloseableHttpClient ourClient;
|
private static CloseableHttpClient ourClient;
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ServerBaseTest.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ServerBaseTest.class);
|
||||||
private Server myServer;
|
private Server myServer;
|
||||||
private static FhirContext ourCtx = new FhirContext();
|
private static FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTransaction() throws Exception {
|
public void testTransaction() throws Exception {
|
||||||
|
|
|
@ -41,12 +41,12 @@ import javax.servlet.http.HttpServletRequest;
|
||||||
public class ServerConformanceProviderTest {
|
public class ServerConformanceProviderTest {
|
||||||
|
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ServerConformanceProviderTest.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ServerConformanceProviderTest.class);
|
||||||
private FhirContext myCtx = new FhirContext();
|
private static FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSearchParameterDocumentation() throws Exception {
|
public void testSearchParameterDocumentation() throws Exception {
|
||||||
|
|
||||||
RestfulServer rs = new RestfulServer();
|
RestfulServer rs = new RestfulServer(ourCtx);
|
||||||
rs.setProviders(new SearchProvider());
|
rs.setProviders(new SearchProvider());
|
||||||
|
|
||||||
ServerConformanceProvider sc = new ServerConformanceProvider(rs);
|
ServerConformanceProvider sc = new ServerConformanceProvider(rs);
|
||||||
|
@ -68,7 +68,7 @@ public class ServerConformanceProviderTest {
|
||||||
assertTrue(found);
|
assertTrue(found);
|
||||||
Conformance conformance = sc.getServerConformance(createHttpServletRequest());
|
Conformance conformance = sc.getServerConformance(createHttpServletRequest());
|
||||||
|
|
||||||
String conf = myCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance);
|
String conf = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance);
|
||||||
ourLog.info(conf);
|
ourLog.info(conf);
|
||||||
|
|
||||||
assertThat(conf, containsString("<documentation value=\"The patient's identifier (MRN or other card number)\"/>"));
|
assertThat(conf, containsString("<documentation value=\"The patient's identifier (MRN or other card number)\"/>"));
|
||||||
|
@ -80,7 +80,7 @@ public class ServerConformanceProviderTest {
|
||||||
@Test
|
@Test
|
||||||
public void testValidateGeneratedStatement() throws Exception {
|
public void testValidateGeneratedStatement() throws Exception {
|
||||||
|
|
||||||
RestfulServer rs = new RestfulServer();
|
RestfulServer rs = new RestfulServer(ourCtx);
|
||||||
rs.setProviders(new MultiOptionalProvider());
|
rs.setProviders(new MultiOptionalProvider());
|
||||||
|
|
||||||
ServerConformanceProvider sc = new ServerConformanceProvider(rs);
|
ServerConformanceProvider sc = new ServerConformanceProvider(rs);
|
||||||
|
@ -90,7 +90,7 @@ public class ServerConformanceProviderTest {
|
||||||
|
|
||||||
Conformance conformance = sc.getServerConformance(createHttpServletRequest());
|
Conformance conformance = sc.getServerConformance(createHttpServletRequest());
|
||||||
|
|
||||||
myCtx.newValidator().validate(conformance);
|
ourCtx.newValidator().validate(conformance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ public class ServerConformanceProviderTest {
|
||||||
@Test
|
@Test
|
||||||
public void testMultiOptionalDocumentation() throws Exception {
|
public void testMultiOptionalDocumentation() throws Exception {
|
||||||
|
|
||||||
RestfulServer rs = new RestfulServer();
|
RestfulServer rs = new RestfulServer(ourCtx);
|
||||||
rs.setProviders(new MultiOptionalProvider());
|
rs.setProviders(new MultiOptionalProvider());
|
||||||
|
|
||||||
ServerConformanceProvider sc = new ServerConformanceProvider(rs);
|
ServerConformanceProvider sc = new ServerConformanceProvider(rs);
|
||||||
|
@ -119,7 +119,7 @@ public class ServerConformanceProviderTest {
|
||||||
}
|
}
|
||||||
assertTrue(found);
|
assertTrue(found);
|
||||||
Conformance conformance = sc.getServerConformance(createHttpServletRequest());
|
Conformance conformance = sc.getServerConformance(createHttpServletRequest());
|
||||||
String conf = new FhirContext().newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance);
|
String conf = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance);
|
||||||
ourLog.info(conf);
|
ourLog.info(conf);
|
||||||
|
|
||||||
assertThat(conf, containsString("<documentation value=\"The patient's identifier\"/>"));
|
assertThat(conf, containsString("<documentation value=\"The patient's identifier\"/>"));
|
||||||
|
@ -130,7 +130,7 @@ public class ServerConformanceProviderTest {
|
||||||
@Test
|
@Test
|
||||||
public void testProviderWithRequiredAndOptional() throws Exception {
|
public void testProviderWithRequiredAndOptional() throws Exception {
|
||||||
|
|
||||||
RestfulServer rs = new RestfulServer();
|
RestfulServer rs = new RestfulServer(ourCtx);
|
||||||
rs.setProviders(new ProviderWithRequiredAndOptional());
|
rs.setProviders(new ProviderWithRequiredAndOptional());
|
||||||
|
|
||||||
ServerConformanceProvider sc = new ServerConformanceProvider(rs);
|
ServerConformanceProvider sc = new ServerConformanceProvider(rs);
|
||||||
|
@ -139,7 +139,7 @@ public class ServerConformanceProviderTest {
|
||||||
rs.init(createServletConfig());
|
rs.init(createServletConfig());
|
||||||
|
|
||||||
Conformance conformance = sc.getServerConformance(createHttpServletRequest());
|
Conformance conformance = sc.getServerConformance(createHttpServletRequest());
|
||||||
String conf = new FhirContext().newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance);
|
String conf = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance);
|
||||||
ourLog.info(conf);
|
ourLog.info(conf);
|
||||||
|
|
||||||
Rest rest = conformance.getRestFirstRep();
|
Rest rest = conformance.getRestFirstRep();
|
||||||
|
|
|
@ -34,6 +34,7 @@ public class ServerExtraParametersTest {
|
||||||
private int myPort;
|
private int myPort;
|
||||||
private Server myServer;
|
private Server myServer;
|
||||||
private RestfulServer myServlet;
|
private RestfulServer myServlet;
|
||||||
|
private static FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void before() {
|
public void before() {
|
||||||
|
@ -41,7 +42,9 @@ public class ServerExtraParametersTest {
|
||||||
myServer = new Server(myPort);
|
myServer = new Server(myPort);
|
||||||
|
|
||||||
ServletHandler proxyHandler = new ServletHandler();
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
myServlet = new RestfulServer();
|
myServlet = new RestfulServer(ourCtx);
|
||||||
|
myServlet.setFhirContext(ourCtx);
|
||||||
|
|
||||||
ServletHolder servletHolder = new ServletHolder(myServlet);
|
ServletHolder servletHolder = new ServletHolder(myServlet);
|
||||||
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
||||||
myServer.setHandler(proxyHandler);
|
myServer.setHandler(proxyHandler);
|
||||||
|
@ -55,7 +58,7 @@ public class ServerExtraParametersTest {
|
||||||
|
|
||||||
myServer.start();
|
myServer.start();
|
||||||
|
|
||||||
FhirContext ctx = new FhirContext();
|
FhirContext ctx = ourCtx;
|
||||||
PatientClient client = ctx.newRestfulClient(PatientClient.class, "http://localhost:" + myPort + "/");
|
PatientClient client = ctx.newRestfulClient(PatientClient.class, "http://localhost:" + myPort + "/");
|
||||||
|
|
||||||
List<Patient> actualPatients = client.searchForPatients(new StringDt("AAAABBBB"));
|
List<Patient> actualPatients = client.searchForPatients(new StringDt("AAAABBBB"));
|
||||||
|
@ -72,7 +75,7 @@ public class ServerExtraParametersTest {
|
||||||
|
|
||||||
myServer.start();
|
myServer.start();
|
||||||
|
|
||||||
FhirContext ctx = new FhirContext();
|
FhirContext ctx = ourCtx;
|
||||||
IGenericClient client = ctx.newRestfulGenericClient("http://localhost:" + myPort + "/");
|
IGenericClient client = ctx.newRestfulGenericClient("http://localhost:" + myPort + "/");
|
||||||
client.registerInterceptor(new LoggingInterceptor(true));
|
client.registerInterceptor(new LoggingInterceptor(true));
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.model.api.Bundle;
|
import ca.uhn.fhir.model.api.Bundle;
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
import ca.uhn.fhir.model.dstu.composite.HumanNameDt;
|
import ca.uhn.fhir.model.dstu.composite.HumanNameDt;
|
||||||
|
@ -51,6 +52,7 @@ public class ServerFeaturesTest {
|
||||||
private static int ourPort;
|
private static int ourPort;
|
||||||
private static Server ourServer;
|
private static Server ourServer;
|
||||||
private static RestfulServer servlet;
|
private static RestfulServer servlet;
|
||||||
|
private static final FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPrettyPrint() throws Exception {
|
public void testPrettyPrint() throws Exception {
|
||||||
|
@ -295,7 +297,7 @@ public class ServerFeaturesTest {
|
||||||
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
|
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
|
||||||
|
|
||||||
ServletHandler proxyHandler = new ServletHandler();
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
servlet = new RestfulServer();
|
servlet = new RestfulServer(ourCtx);
|
||||||
servlet.setResourceProviders(patientProvider);
|
servlet.setResourceProviders(patientProvider);
|
||||||
servlet.setBundleInclusionRule(BundleInclusionRule.BASED_ON_RESOURCE_PRESENCE);
|
servlet.setBundleInclusionRule(BundleInclusionRule.BASED_ON_RESOURCE_PRESENCE);
|
||||||
ServletHolder servletHolder = new ServletHolder(servlet);
|
ServletHolder servletHolder = new ServletHolder(servlet);
|
||||||
|
|
|
@ -11,6 +11,7 @@ import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
import org.hl7.fhir.instance.model.api.IIdType;
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||||
import ca.uhn.fhir.model.api.IElement;
|
import ca.uhn.fhir.model.api.IElement;
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
|
@ -27,20 +28,21 @@ import ca.uhn.fhir.rest.annotation.Search;
|
||||||
import ca.uhn.fhir.rest.param.StringParam;
|
import ca.uhn.fhir.rest.param.StringParam;
|
||||||
|
|
||||||
public class ServerInvalidDefinitionTest {
|
public class ServerInvalidDefinitionTest {
|
||||||
|
private static final FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Normal, should initialize properly
|
* Normal, should initialize properly
|
||||||
*/
|
*/
|
||||||
@Test()
|
@Test()
|
||||||
public void testBaseline() throws ServletException {
|
public void testBaseline() throws ServletException {
|
||||||
RestfulServer srv = new RestfulServer();
|
RestfulServer srv = new RestfulServer(ourCtx);
|
||||||
srv.setResourceProviders(new InstantiableTypeForResourceProvider());
|
srv.setResourceProviders(new InstantiableTypeForResourceProvider());
|
||||||
srv.init();
|
srv.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInvalidSpecialNameResourceProvider() {
|
public void testInvalidSpecialNameResourceProvider() {
|
||||||
RestfulServer srv = new RestfulServer();
|
RestfulServer srv = new RestfulServer(ourCtx);
|
||||||
srv.setResourceProviders(new InvalidSpecialParameterNameResourceProvider());
|
srv.setResourceProviders(new InvalidSpecialParameterNameResourceProvider());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -54,7 +56,7 @@ public class ServerInvalidDefinitionTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMultipleResourceProviderForSameType() {
|
public void testMultipleResourceProviderForSameType() {
|
||||||
RestfulServer srv = new RestfulServer();
|
RestfulServer srv = new RestfulServer(ourCtx);
|
||||||
srv.setResourceProviders(new PatientResourceProvider1(), new PatientResourceProvider2());
|
srv.setResourceProviders(new PatientResourceProvider1(), new PatientResourceProvider2());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -69,7 +71,7 @@ public class ServerInvalidDefinitionTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPrivateResourceProvider() {
|
public void testPrivateResourceProvider() {
|
||||||
RestfulServer srv = new RestfulServer();
|
RestfulServer srv = new RestfulServer(ourCtx);
|
||||||
srv.setResourceProviders(new PrivateResourceProvider());
|
srv.setResourceProviders(new PrivateResourceProvider());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -83,7 +85,7 @@ public class ServerInvalidDefinitionTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testProviderWithNonResourceType() {
|
public void testProviderWithNonResourceType() {
|
||||||
RestfulServer srv = new RestfulServer();
|
RestfulServer srv = new RestfulServer(ourCtx);
|
||||||
srv.setResourceProviders(new ProviderWithNonResourceType());
|
srv.setResourceProviders(new ProviderWithNonResourceType());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -97,7 +99,7 @@ public class ServerInvalidDefinitionTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testReadMethodWithoutIdParamProvider() {
|
public void testReadMethodWithoutIdParamProvider() {
|
||||||
RestfulServer srv = new RestfulServer();
|
RestfulServer srv = new RestfulServer(ourCtx);
|
||||||
srv.setResourceProviders(new ReadMethodWithoutIdParamProvider());
|
srv.setResourceProviders(new ReadMethodWithoutIdParamProvider());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -110,7 +112,7 @@ public class ServerInvalidDefinitionTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testReadMethodWithSearchParameters() {
|
public void testReadMethodWithSearchParameters() {
|
||||||
RestfulServer srv = new RestfulServer();
|
RestfulServer srv = new RestfulServer(ourCtx);
|
||||||
srv.setResourceProviders(new ReadMethodWithSearchParamProvider());
|
srv.setResourceProviders(new ReadMethodWithSearchParamProvider());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -123,7 +125,7 @@ public class ServerInvalidDefinitionTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSearchWithId() {
|
public void testSearchWithId() {
|
||||||
RestfulServer srv = new RestfulServer();
|
RestfulServer srv = new RestfulServer(ourCtx);
|
||||||
srv.setResourceProviders(new SearchWithIdParamProvider());
|
srv.setResourceProviders(new SearchWithIdParamProvider());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package ca.uhn.fhir.rest.server;
|
package ca.uhn.fhir.rest.server;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
import ca.uhn.fhir.model.api.annotation.ProvidesResources;
|
import ca.uhn.fhir.model.api.annotation.ProvidesResources;
|
||||||
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
||||||
|
@ -9,9 +10,11 @@ import ca.uhn.fhir.model.primitive.IdDt;
|
||||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||||
import ca.uhn.fhir.rest.annotation.Read;
|
import ca.uhn.fhir.rest.annotation.Read;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -19,7 +22,9 @@ import java.util.List;
|
||||||
* Created by Bill de Beaubien on 11/1/2014.
|
* Created by Bill de Beaubien on 11/1/2014.
|
||||||
*/
|
*/
|
||||||
public class ServerProvidedResourceScannerTest extends TestCase {
|
public class ServerProvidedResourceScannerTest extends TestCase {
|
||||||
@Test
|
private static final FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testWhenRestfulServerInitialized_annotatedResources_shouldBeAddedToContext() throws ServletException {
|
public void testWhenRestfulServerInitialized_annotatedResources_shouldBeAddedToContext() throws ServletException {
|
||||||
// Given
|
// Given
|
||||||
MyServer server = new MyServer();
|
MyServer server = new MyServer();
|
||||||
|
@ -35,7 +40,7 @@ public class ServerProvidedResourceScannerTest extends TestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testWhenUnannotatedServerInitialized_annotatedResources_shouldNotBeAddedToContext() throws ServletException {
|
public void testWhenUnannotatedServerInitialized_annotatedResources_shouldNotBeAddedToContext() throws ServletException {
|
||||||
// Given
|
// Given
|
||||||
RestfulServer server = new RestfulServer();
|
RestfulServer server = new RestfulServer(ourCtx);
|
||||||
|
|
||||||
// When
|
// When
|
||||||
server.init();
|
server.init();
|
||||||
|
@ -67,10 +72,23 @@ public class ServerProvidedResourceScannerTest extends TestCase {
|
||||||
|
|
||||||
@ProvidesResources(resources={CustomPatient.class,CustomObservation.class})
|
@ProvidesResources(resources={CustomPatient.class,CustomObservation.class})
|
||||||
class MyServer extends RestfulServer {
|
class MyServer extends RestfulServer {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public MyServer() {
|
||||||
|
super(ourCtx);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyServerWithProvider extends RestfulServer {
|
class MyServerWithProvider extends RestfulServer {
|
||||||
@Override
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public MyServerWithProvider() {
|
||||||
|
super(ourCtx);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void initialize() throws ServletException {
|
protected void initialize() throws ServletException {
|
||||||
List<IResourceProvider> providers = new ArrayList<IResourceProvider>();
|
List<IResourceProvider> providers = new ArrayList<IResourceProvider>();
|
||||||
providers.add(new MyObservationProvider());
|
providers.add(new MyObservationProvider());
|
||||||
|
|
|
@ -36,9 +36,9 @@ import ca.uhn.fhir.util.PortUtil;
|
||||||
public class SortTest {
|
public class SortTest {
|
||||||
|
|
||||||
private static CloseableHttpClient ourClient;
|
private static CloseableHttpClient ourClient;
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SortTest.class);
|
|
||||||
private static int ourPort;
|
private static int ourPort;
|
||||||
private static Server ourServer;
|
private static Server ourServer;
|
||||||
|
private static FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoSort() throws Exception {
|
public void testNoSort() throws Exception {
|
||||||
|
@ -47,7 +47,7 @@ public class SortTest {
|
||||||
String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
|
String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
Bundle bundle = new FhirContext().newXmlParser().parseBundle(responseContent);
|
Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
|
||||||
assertEquals(1, bundle.size());
|
assertEquals(1, bundle.size());
|
||||||
|
|
||||||
Patient p = bundle.getResources(Patient.class).get(0);
|
Patient p = bundle.getResources(Patient.class).get(0);
|
||||||
|
@ -63,7 +63,7 @@ public class SortTest {
|
||||||
String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
|
String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
Bundle bundle = new FhirContext().newXmlParser().parseBundle(responseContent);
|
Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
|
||||||
assertEquals(1, bundle.size());
|
assertEquals(1, bundle.size());
|
||||||
|
|
||||||
Patient p = bundle.getResources(Patient.class).get(0);
|
Patient p = bundle.getResources(Patient.class).get(0);
|
||||||
|
@ -77,7 +77,7 @@ public class SortTest {
|
||||||
String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
|
String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
Bundle bundle = new FhirContext().newXmlParser().parseBundle(responseContent);
|
Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
|
||||||
assertEquals(1, bundle.size());
|
assertEquals(1, bundle.size());
|
||||||
|
|
||||||
Patient p = bundle.getResources(Patient.class).get(0);
|
Patient p = bundle.getResources(Patient.class).get(0);
|
||||||
|
@ -91,7 +91,7 @@ public class SortTest {
|
||||||
String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
|
String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
Bundle bundle = new FhirContext().newXmlParser().parseBundle(responseContent);
|
Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
|
||||||
assertEquals(1, bundle.size());
|
assertEquals(1, bundle.size());
|
||||||
|
|
||||||
Patient p = bundle.getResources(Patient.class).get(0);
|
Patient p = bundle.getResources(Patient.class).get(0);
|
||||||
|
@ -110,7 +110,7 @@ public class SortTest {
|
||||||
String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
|
String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
Bundle bundle = new FhirContext().newXmlParser().parseBundle(responseContent);
|
Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
|
||||||
assertEquals(1, bundle.size());
|
assertEquals(1, bundle.size());
|
||||||
|
|
||||||
Patient p = bundle.getResources(Patient.class).get(0);
|
Patient p = bundle.getResources(Patient.class).get(0);
|
||||||
|
@ -136,7 +136,7 @@ public class SortTest {
|
||||||
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
|
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
|
||||||
|
|
||||||
ServletHandler proxyHandler = new ServletHandler();
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
RestfulServer servlet = new RestfulServer();
|
RestfulServer servlet = new RestfulServer(ourCtx);
|
||||||
servlet.setResourceProviders(patientProvider);
|
servlet.setResourceProviders(patientProvider);
|
||||||
ServletHolder servletHolder = new ServletHolder(servlet);
|
ServletHolder servletHolder = new ServletHolder(servlet);
|
||||||
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
||||||
|
|
|
@ -34,69 +34,30 @@ import ca.uhn.fhir.util.PortUtil;
|
||||||
public class StringParameterTest {
|
public class StringParameterTest {
|
||||||
|
|
||||||
private static CloseableHttpClient ourClient;
|
private static CloseableHttpClient ourClient;
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(StringParameterTest.class);
|
private static FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
private static int ourPort;
|
private static int ourPort;
|
||||||
|
|
||||||
private static Server ourServer;
|
private static Server ourServer;
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSearchWithFormatAndPretty() throws Exception {
|
|
||||||
{
|
|
||||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?str=aaa&_format=xml&_pretty=true");
|
|
||||||
HttpResponse status = ourClient.execute(httpGet);
|
|
||||||
String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
|
|
||||||
|
|
||||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
|
||||||
assertEquals(1, new FhirContext().newXmlParser().parseBundle(responseContent).getEntries().size());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSearchNormalMatch() throws Exception {
|
|
||||||
{
|
|
||||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?str=aaa");
|
|
||||||
HttpResponse status = ourClient.execute(httpGet);
|
|
||||||
String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
|
|
||||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
|
||||||
|
|
||||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
|
||||||
assertEquals(1, new FhirContext().newXmlParser().parseBundle(responseContent).getEntries().size());
|
|
||||||
}
|
|
||||||
{
|
|
||||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?str=AAA");
|
|
||||||
HttpResponse status = ourClient.execute(httpGet);
|
|
||||||
String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
|
|
||||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
|
||||||
|
|
||||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
|
||||||
assertEquals(1, new FhirContext().newXmlParser().parseBundle(responseContent).getEntries().size());
|
|
||||||
}
|
|
||||||
{
|
|
||||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?str=BBB");
|
|
||||||
HttpResponse status = ourClient.execute(httpGet);
|
|
||||||
String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
|
|
||||||
|
|
||||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
|
||||||
assertEquals(0, new FhirContext().newXmlParser().parseBundle(responseContent).getEntries().size());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRawString() throws Exception {
|
public void testRawString() throws Exception {
|
||||||
{
|
{
|
||||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?plain=aaa");
|
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?plain=aaa");
|
||||||
HttpResponse status = ourClient.execute(httpGet);
|
HttpResponse status = ourClient.execute(httpGet);
|
||||||
String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
|
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||||
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
assertEquals(1, new FhirContext().newXmlParser().parseBundle(responseContent).getEntries().size());
|
assertEquals(1, ourCtx.newXmlParser().parseBundle(responseContent).getEntries().size());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?plain=BBB");
|
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?plain=BBB");
|
||||||
HttpResponse status = ourClient.execute(httpGet);
|
HttpResponse status = ourClient.execute(httpGet);
|
||||||
String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
|
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||||
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
assertEquals(0, new FhirContext().newXmlParser().parseBundle(responseContent).getEntries().size());
|
assertEquals(0, ourCtx.newXmlParser().parseBundle(responseContent).getEntries().size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,26 +66,29 @@ public class StringParameterTest {
|
||||||
{
|
{
|
||||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?str:exact=aaa");
|
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?str:exact=aaa");
|
||||||
HttpResponse status = ourClient.execute(httpGet);
|
HttpResponse status = ourClient.execute(httpGet);
|
||||||
String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
|
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||||
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
assertEquals(1, new FhirContext().newXmlParser().parseBundle(responseContent).getEntries().size());
|
assertEquals(1, ourCtx.newXmlParser().parseBundle(responseContent).getEntries().size());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?str:exact=AAA");
|
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?str:exact=AAA");
|
||||||
HttpResponse status = ourClient.execute(httpGet);
|
HttpResponse status = ourClient.execute(httpGet);
|
||||||
String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
|
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||||
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
assertEquals(0, new FhirContext().newXmlParser().parseBundle(responseContent).getEntries().size());
|
assertEquals(0, ourCtx.newXmlParser().parseBundle(responseContent).getEntries().size());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?str:exact=BBB");
|
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?str:exact=BBB");
|
||||||
HttpResponse status = ourClient.execute(httpGet);
|
HttpResponse status = ourClient.execute(httpGet);
|
||||||
String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
|
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||||
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
assertEquals(0, new FhirContext().newXmlParser().parseBundle(responseContent).getEntries().size());
|
assertEquals(0, ourCtx.newXmlParser().parseBundle(responseContent).getEntries().size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,13 +97,59 @@ public class StringParameterTest {
|
||||||
{
|
{
|
||||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?ccc:exact=aaa");
|
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?ccc:exact=aaa");
|
||||||
HttpResponse status = ourClient.execute(httpGet);
|
HttpResponse status = ourClient.execute(httpGet);
|
||||||
String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
|
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||||
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
assertEquals(1, new FhirContext().newXmlParser().parseBundle(responseContent).getEntries().size());
|
assertEquals(1, ourCtx.newXmlParser().parseBundle(responseContent).getEntries().size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSearchNormalMatch() throws Exception {
|
||||||
|
{
|
||||||
|
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?str=aaa");
|
||||||
|
HttpResponse status = ourClient.execute(httpGet);
|
||||||
|
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||||
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
|
assertEquals(1, ourCtx.newXmlParser().parseBundle(responseContent).getEntries().size());
|
||||||
|
}
|
||||||
|
{
|
||||||
|
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?str=AAA");
|
||||||
|
HttpResponse status = ourClient.execute(httpGet);
|
||||||
|
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||||
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
|
assertEquals(1, ourCtx.newXmlParser().parseBundle(responseContent).getEntries().size());
|
||||||
|
}
|
||||||
|
{
|
||||||
|
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?str=BBB");
|
||||||
|
HttpResponse status = ourClient.execute(httpGet);
|
||||||
|
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||||
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
|
assertEquals(0, ourCtx.newXmlParser().parseBundle(responseContent).getEntries().size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSearchWithFormatAndPretty() throws Exception {
|
||||||
|
{
|
||||||
|
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?str=aaa&_format=xml&_pretty=true");
|
||||||
|
HttpResponse status = ourClient.execute(httpGet);
|
||||||
|
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||||
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
|
assertEquals(1, ourCtx.newXmlParser().parseBundle(responseContent).getEntries().size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public static void afterClass() throws Exception {
|
public static void afterClass() throws Exception {
|
||||||
|
@ -154,7 +164,8 @@ public class StringParameterTest {
|
||||||
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
|
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
|
||||||
|
|
||||||
ServletHandler proxyHandler = new ServletHandler();
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
RestfulServer servlet = new RestfulServer();
|
RestfulServer servlet = new RestfulServer(ourCtx);
|
||||||
|
servlet.setFhirContext(ourCtx);
|
||||||
servlet.setResourceProviders(patientProvider);
|
servlet.setResourceProviders(patientProvider);
|
||||||
ServletHolder servletHolder = new ServletHolder(servlet);
|
ServletHolder servletHolder = new ServletHolder(servlet);
|
||||||
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
||||||
|
@ -173,6 +184,19 @@ public class StringParameterTest {
|
||||||
*/
|
*/
|
||||||
public static class DummyPatientResourceProvider implements IResourceProvider {
|
public static class DummyPatientResourceProvider implements IResourceProvider {
|
||||||
|
|
||||||
|
@Search
|
||||||
|
public List<Patient> findPatientByString(@RequiredParam(name = "plain") String theParam) {
|
||||||
|
ArrayList<Patient> retVal = new ArrayList<Patient>();
|
||||||
|
|
||||||
|
if (theParam.toLowerCase().equals("aaa")) {
|
||||||
|
Patient patient = new Patient();
|
||||||
|
patient.setId("1");
|
||||||
|
retVal.add(patient);
|
||||||
|
}
|
||||||
|
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
@Search
|
@Search
|
||||||
public List<Patient> findPatientByStringParam(@RequiredParam(name = "str") StringParam theParam) {
|
public List<Patient> findPatientByStringParam(@RequiredParam(name = "str") StringParam theParam) {
|
||||||
ArrayList<Patient> retVal = new ArrayList<Patient>();
|
ArrayList<Patient> retVal = new ArrayList<Patient>();
|
||||||
|
@ -191,19 +215,6 @@ public class StringParameterTest {
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Search
|
|
||||||
public List<Patient> findPatientByString(@RequiredParam(name = "plain") String theParam) {
|
|
||||||
ArrayList<Patient> retVal = new ArrayList<Patient>();
|
|
||||||
|
|
||||||
if (theParam.toLowerCase().equals("aaa")) {
|
|
||||||
Patient patient = new Patient();
|
|
||||||
patient.setId("1");
|
|
||||||
retVal.add(patient);
|
|
||||||
}
|
|
||||||
|
|
||||||
return retVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Search
|
@Search
|
||||||
public List<Patient> findPatientWithOptional(@OptionalParam(name = "ccc") StringParam theParam) {
|
public List<Patient> findPatientWithOptional(@OptionalParam(name = "ccc") StringParam theParam) {
|
||||||
ArrayList<Patient> retVal = new ArrayList<Patient>();
|
ArrayList<Patient> retVal = new ArrayList<Patient>();
|
||||||
|
@ -222,7 +233,6 @@ public class StringParameterTest {
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<? extends IResource> getResourceType() {
|
public Class<? extends IResource> getResourceType() {
|
||||||
return Patient.class;
|
return Patient.class;
|
||||||
|
|
|
@ -240,7 +240,7 @@ public class TagsServerTest {
|
||||||
ourProvider = new DummyProvider();
|
ourProvider = new DummyProvider();
|
||||||
|
|
||||||
ServletHandler proxyHandler = new ServletHandler();
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
RestfulServer servlet = new RestfulServer();
|
RestfulServer servlet = new RestfulServer(ourCtx);
|
||||||
servlet.setPlainProviders(ourProvider);
|
servlet.setPlainProviders(ourProvider);
|
||||||
ServletHolder servletHolder = new ServletHolder(servlet);
|
ServletHolder servletHolder = new ServletHolder(servlet);
|
||||||
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
||||||
|
|
|
@ -40,7 +40,7 @@ import ca.uhn.fhir.util.PortUtil;
|
||||||
public class TransactionTest {
|
public class TransactionTest {
|
||||||
|
|
||||||
private static CloseableHttpClient ourClient;
|
private static CloseableHttpClient ourClient;
|
||||||
private static FhirContext ourCtx = new FhirContext();
|
private static FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
private static boolean ourDropFirstResource;
|
private static boolean ourDropFirstResource;
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(TransactionTest.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(TransactionTest.class);
|
||||||
private static int ourPort;
|
private static int ourPort;
|
||||||
|
@ -88,7 +88,7 @@ public class TransactionTest {
|
||||||
|
|
||||||
ourLog.info(responseContent);
|
ourLog.info(responseContent);
|
||||||
|
|
||||||
Bundle bundle = new FhirContext().newXmlParser().parseBundle(responseContent);
|
Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
|
||||||
assertEquals(3, bundle.size());
|
assertEquals(3, bundle.size());
|
||||||
|
|
||||||
BundleEntry entry0 = bundle.getEntries().get(0);
|
BundleEntry entry0 = bundle.getEntries().get(0);
|
||||||
|
@ -144,7 +144,7 @@ public class TransactionTest {
|
||||||
|
|
||||||
ourLog.info(responseContent);
|
ourLog.info(responseContent);
|
||||||
|
|
||||||
Bundle bundle = new FhirContext().newXmlParser().parseBundle(responseContent);
|
Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
|
||||||
assertEquals(2, bundle.size());
|
assertEquals(2, bundle.size());
|
||||||
|
|
||||||
BundleEntry entry1 = bundle.getEntries().get(0);
|
BundleEntry entry1 = bundle.getEntries().get(0);
|
||||||
|
@ -195,7 +195,7 @@ public class TransactionTest {
|
||||||
|
|
||||||
ourLog.info(responseContent);
|
ourLog.info(responseContent);
|
||||||
|
|
||||||
Bundle bundle = new FhirContext().newXmlParser().parseBundle(responseContent);
|
Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
|
||||||
assertEquals(4, bundle.size());
|
assertEquals(4, bundle.size());
|
||||||
|
|
||||||
assertEquals(OperationOutcome.class, bundle.getEntries().get(0).getResource().getClass());
|
assertEquals(OperationOutcome.class, bundle.getEntries().get(0).getResource().getClass());
|
||||||
|
@ -228,7 +228,7 @@ public class TransactionTest {
|
||||||
ourServer = new Server(ourPort);
|
ourServer = new Server(ourPort);
|
||||||
|
|
||||||
DummyProvider patientProvider = new DummyProvider();
|
DummyProvider patientProvider = new DummyProvider();
|
||||||
RestfulServer server = new RestfulServer();
|
RestfulServer server = new RestfulServer(ourCtx);
|
||||||
server.setProviders(patientProvider);
|
server.setProviders(patientProvider);
|
||||||
|
|
||||||
org.eclipse.jetty.servlet.ServletContextHandler proxyHandler = new org.eclipse.jetty.servlet.ServletContextHandler();
|
org.eclipse.jetty.servlet.ServletContextHandler proxyHandler = new org.eclipse.jetty.servlet.ServletContextHandler();
|
||||||
|
|
|
@ -40,7 +40,7 @@ import ca.uhn.fhir.util.PortUtil;
|
||||||
public class TransactionWithBundleParamTest {
|
public class TransactionWithBundleParamTest {
|
||||||
|
|
||||||
private static CloseableHttpClient ourClient;
|
private static CloseableHttpClient ourClient;
|
||||||
private static FhirContext ourCtx = new FhirContext();
|
private static FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(TransactionWithBundleParamTest.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(TransactionWithBundleParamTest.class);
|
||||||
private static int ourPort;
|
private static int ourPort;
|
||||||
private static boolean ourReturnOperationOutcome;
|
private static boolean ourReturnOperationOutcome;
|
||||||
|
@ -144,7 +144,7 @@ public class TransactionWithBundleParamTest {
|
||||||
|
|
||||||
ourLog.info(responseContent);
|
ourLog.info(responseContent);
|
||||||
|
|
||||||
Bundle bundle = new FhirContext().newXmlParser().parseBundle(responseContent);
|
Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
|
||||||
assertEquals(4, bundle.size());
|
assertEquals(4, bundle.size());
|
||||||
|
|
||||||
assertEquals(OperationOutcome.class, bundle.getEntries().get(0).getResource().getClass());
|
assertEquals(OperationOutcome.class, bundle.getEntries().get(0).getResource().getClass());
|
||||||
|
@ -177,7 +177,7 @@ public class TransactionWithBundleParamTest {
|
||||||
ourServer = new Server(ourPort);
|
ourServer = new Server(ourPort);
|
||||||
|
|
||||||
DummyProvider patientProvider = new DummyProvider();
|
DummyProvider patientProvider = new DummyProvider();
|
||||||
RestfulServer server = new RestfulServer();
|
RestfulServer server = new RestfulServer(ourCtx);
|
||||||
server.setProviders(patientProvider);
|
server.setProviders(patientProvider);
|
||||||
|
|
||||||
org.eclipse.jetty.servlet.ServletContextHandler proxyHandler = new org.eclipse.jetty.servlet.ServletContextHandler();
|
org.eclipse.jetty.servlet.ServletContextHandler proxyHandler = new org.eclipse.jetty.servlet.ServletContextHandler();
|
||||||
|
|
|
@ -47,6 +47,7 @@ public class UpdateTest {
|
||||||
private static int ourPort;
|
private static int ourPort;
|
||||||
private static DiagnosticReportProvider ourReportProvider;
|
private static DiagnosticReportProvider ourReportProvider;
|
||||||
private static Server ourServer;
|
private static Server ourServer;
|
||||||
|
private static FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdate() throws Exception {
|
public void testUpdate() throws Exception {
|
||||||
|
@ -55,7 +56,7 @@ public class UpdateTest {
|
||||||
patient.addIdentifier().setValue("002");
|
patient.addIdentifier().setValue("002");
|
||||||
|
|
||||||
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/Patient/001");
|
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/Patient/001");
|
||||||
httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||||
|
|
||||||
HttpResponse status = ourClient.execute(httpPost);
|
HttpResponse status = ourClient.execute(httpPost);
|
||||||
|
|
||||||
|
@ -64,7 +65,7 @@ public class UpdateTest {
|
||||||
|
|
||||||
ourLog.info("Response was:\n{}", responseContent);
|
ourLog.info("Response was:\n{}", responseContent);
|
||||||
|
|
||||||
OperationOutcome oo = new FhirContext().newXmlParser().parseResource(OperationOutcome.class, responseContent);
|
OperationOutcome oo = ourCtx.newXmlParser().parseResource(OperationOutcome.class, responseContent);
|
||||||
assertEquals("OODETAILS", oo.getIssueFirstRep().getDetails().getValue());
|
assertEquals("OODETAILS", oo.getIssueFirstRep().getDetails().getValue());
|
||||||
|
|
||||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
|
@ -81,7 +82,7 @@ public class UpdateTest {
|
||||||
patient.addIdentifier().setValue("002");
|
patient.addIdentifier().setValue("002");
|
||||||
|
|
||||||
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/Patient/001CREATE");
|
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/Patient/001CREATE");
|
||||||
httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||||
|
|
||||||
HttpResponse status = ourClient.execute(httpPost);
|
HttpResponse status = ourClient.execute(httpPost);
|
||||||
|
|
||||||
|
@ -90,7 +91,7 @@ public class UpdateTest {
|
||||||
|
|
||||||
ourLog.info("Response was:\n{}", responseContent);
|
ourLog.info("Response was:\n{}", responseContent);
|
||||||
|
|
||||||
OperationOutcome oo = new FhirContext().newXmlParser().parseResource(OperationOutcome.class, responseContent);
|
OperationOutcome oo = ourCtx.newXmlParser().parseResource(OperationOutcome.class, responseContent);
|
||||||
assertEquals("OODETAILS", oo.getIssueFirstRep().getDetails().getValue());
|
assertEquals("OODETAILS", oo.getIssueFirstRep().getDetails().getValue());
|
||||||
|
|
||||||
assertEquals(201, status.getStatusLine().getStatusCode());
|
assertEquals(201, status.getStatusLine().getStatusCode());
|
||||||
|
@ -105,7 +106,7 @@ public class UpdateTest {
|
||||||
patient.addIdentifier().setValue("002");
|
patient.addIdentifier().setValue("002");
|
||||||
|
|
||||||
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/AAAAAA");
|
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/AAAAAA");
|
||||||
httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||||
|
|
||||||
HttpResponse status = ourClient.execute(httpPost);
|
HttpResponse status = ourClient.execute(httpPost);
|
||||||
|
|
||||||
|
@ -125,7 +126,7 @@ public class UpdateTest {
|
||||||
dr.addCodedDiagnosis().addCoding().setCode("AAA");
|
dr.addCodedDiagnosis().addCoding().setCode("AAA");
|
||||||
|
|
||||||
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
|
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
|
||||||
httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||||
|
|
||||||
HttpResponse status = ourClient.execute(httpPost);
|
HttpResponse status = ourClient.execute(httpPost);
|
||||||
|
|
||||||
|
@ -143,7 +144,7 @@ public class UpdateTest {
|
||||||
|
|
||||||
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
|
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
|
||||||
httpPost.addHeader("Category", "Dog; scheme=\"urn:animals\", Cat; scheme=\"urn:animals\"");
|
httpPost.addHeader("Category", "Dog; scheme=\"urn:animals\", Cat; scheme=\"urn:animals\"");
|
||||||
httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||||
CloseableHttpResponse status = ourClient.execute(httpPost);
|
CloseableHttpResponse status = ourClient.execute(httpPost);
|
||||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
|
@ -153,7 +154,7 @@ public class UpdateTest {
|
||||||
|
|
||||||
httpPost = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
|
httpPost = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
|
||||||
httpPost.addHeader("Category", "Dog; label=\"aa\"; scheme=\"urn:animals\", Cat; label=\"bb\"; scheme=\"urn:animals\"");
|
httpPost.addHeader("Category", "Dog; label=\"aa\"; scheme=\"urn:animals\", Cat; label=\"bb\"; scheme=\"urn:animals\"");
|
||||||
httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||||
status = ourClient.execute(httpPost);
|
status = ourClient.execute(httpPost);
|
||||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
|
@ -171,7 +172,7 @@ public class UpdateTest {
|
||||||
|
|
||||||
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
|
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
|
||||||
httpPost.addHeader("Category", "Dog; scheme=\"animals\"");
|
httpPost.addHeader("Category", "Dog; scheme=\"animals\"");
|
||||||
httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||||
CloseableHttpResponse status = ourClient.execute(httpPost);
|
CloseableHttpResponse status = ourClient.execute(httpPost);
|
||||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
|
@ -188,7 +189,7 @@ public class UpdateTest {
|
||||||
|
|
||||||
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
|
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
|
||||||
httpPost.addHeader("Category", "Dog; scheme=\"http://foo\"");
|
httpPost.addHeader("Category", "Dog; scheme=\"http://foo\"");
|
||||||
httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||||
CloseableHttpResponse status = ourClient.execute(httpPost);
|
CloseableHttpResponse status = ourClient.execute(httpPost);
|
||||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
|
@ -197,7 +198,7 @@ public class UpdateTest {
|
||||||
|
|
||||||
httpPost = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
|
httpPost = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
|
||||||
httpPost.addHeader("Category", "Dog; scheme=\"http://foo\";");
|
httpPost.addHeader("Category", "Dog; scheme=\"http://foo\";");
|
||||||
httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||||
ourClient.execute(httpPost);
|
ourClient.execute(httpPost);
|
||||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
|
@ -214,7 +215,7 @@ public class UpdateTest {
|
||||||
|
|
||||||
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
|
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
|
||||||
httpPost.addHeader("Category", "Dog; scheme=\"http://foo\"; label=\"aaaa\"");
|
httpPost.addHeader("Category", "Dog; scheme=\"http://foo\"; label=\"aaaa\"");
|
||||||
httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||||
CloseableHttpResponse status = ourClient.execute(httpPost);
|
CloseableHttpResponse status = ourClient.execute(httpPost);
|
||||||
assertEquals(1, ourReportProvider.getLastTags().size());
|
assertEquals(1, ourReportProvider.getLastTags().size());
|
||||||
assertEquals(new Tag("http://foo", "Dog", "aaaa"), ourReportProvider.getLastTags().get(0));
|
assertEquals(new Tag("http://foo", "Dog", "aaaa"), ourReportProvider.getLastTags().get(0));
|
||||||
|
@ -222,7 +223,7 @@ public class UpdateTest {
|
||||||
|
|
||||||
httpPost = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
|
httpPost = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
|
||||||
httpPost.addHeader("Category", "Dog; scheme=\"http://foo\"; label=\"aaaa\"; ");
|
httpPost.addHeader("Category", "Dog; scheme=\"http://foo\"; label=\"aaaa\"; ");
|
||||||
httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||||
status=ourClient.execute(httpPost);
|
status=ourClient.execute(httpPost);
|
||||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
|
@ -239,7 +240,7 @@ public class UpdateTest {
|
||||||
|
|
||||||
HttpPut httpPut = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
|
HttpPut httpPut = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
|
||||||
httpPut.addHeader("Content-Location", "/DiagnosticReport/001/_history/004");
|
httpPut.addHeader("Content-Location", "/DiagnosticReport/001/_history/004");
|
||||||
httpPut.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
httpPut.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||||
|
|
||||||
HttpResponse status = ourClient.execute(httpPut);
|
HttpResponse status = ourClient.execute(httpPut);
|
||||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
@ -261,7 +262,7 @@ public class UpdateTest {
|
||||||
|
|
||||||
HttpPut httpPut = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
|
HttpPut httpPut = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
|
||||||
httpPut.addHeader("Content-Location", "/Patient/001/_history/002");
|
httpPut.addHeader("Content-Location", "/Patient/001/_history/002");
|
||||||
httpPut.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
httpPut.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||||
|
|
||||||
CloseableHttpResponse status = ourClient.execute(httpPut);
|
CloseableHttpResponse status = ourClient.execute(httpPut);
|
||||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||||
|
@ -282,7 +283,7 @@ public class UpdateTest {
|
||||||
patient.addIdentifier().setValue("002");
|
patient.addIdentifier().setValue("002");
|
||||||
|
|
||||||
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
|
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
|
||||||
httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||||
|
|
||||||
ourClient.execute(httpPost);
|
ourClient.execute(httpPost);
|
||||||
fail();
|
fail();
|
||||||
|
@ -295,7 +296,7 @@ public class UpdateTest {
|
||||||
patient.addIdentifier().setValue("002");
|
patient.addIdentifier().setValue("002");
|
||||||
|
|
||||||
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/Organization/001");
|
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/Organization/001");
|
||||||
httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||||
|
|
||||||
CloseableHttpResponse status = ourClient.execute(httpPost);
|
CloseableHttpResponse status = ourClient.execute(httpPost);
|
||||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
@ -320,7 +321,7 @@ public class UpdateTest {
|
||||||
ourReportProvider = new DiagnosticReportProvider();
|
ourReportProvider = new DiagnosticReportProvider();
|
||||||
|
|
||||||
ServletHandler proxyHandler = new ServletHandler();
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
RestfulServer servlet = new RestfulServer();
|
RestfulServer servlet = new RestfulServer(ourCtx);
|
||||||
servlet.setResourceProviders(patientProvider, ourReportProvider, new ObservationProvider(), new OrganizationResourceProvider());
|
servlet.setResourceProviders(patientProvider, ourReportProvider, new ObservationProvider(), new OrganizationResourceProvider());
|
||||||
ServletHolder servletHolder = new ServletHolder(servlet);
|
ServletHolder servletHolder = new ServletHolder(servlet);
|
||||||
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
||||||
|
@ -386,7 +387,6 @@ public class UpdateTest {
|
||||||
return Observation.class;
|
return Observation.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Update()
|
@Update()
|
||||||
public MethodOutcome updateDiagnosticReportWithVersion(@IdParam IdDt theId, @ResourceParam DiagnosticOrder thePatient) {
|
public MethodOutcome updateDiagnosticReportWithVersion(@IdParam IdDt theId, @ResourceParam DiagnosticOrder thePatient) {
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -39,8 +39,8 @@ public class ValidateDstu1Test {
|
||||||
private static CloseableHttpClient ourClient;
|
private static CloseableHttpClient ourClient;
|
||||||
private static EncodingEnum ourLastEncoding;
|
private static EncodingEnum ourLastEncoding;
|
||||||
private static String ourLastResourceBody;
|
private static String ourLastResourceBody;
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ValidateDstu1Test.class);
|
|
||||||
private static int ourPort;
|
private static int ourPort;
|
||||||
|
private static FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
private static Server ourServer;
|
private static Server ourServer;
|
||||||
|
|
||||||
@Before()
|
@Before()
|
||||||
|
@ -57,7 +57,7 @@ public class ValidateDstu1Test {
|
||||||
patient.addIdentifier().setValue("002");
|
patient.addIdentifier().setValue("002");
|
||||||
|
|
||||||
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/_validate");
|
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/_validate");
|
||||||
httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||||
|
|
||||||
HttpResponse status = ourClient.execute(httpPost);
|
HttpResponse status = ourClient.execute(httpPost);
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ public class ValidateDstu1Test {
|
||||||
org.addIdentifier().setValue("002");
|
org.addIdentifier().setValue("002");
|
||||||
|
|
||||||
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Organization/_validate");
|
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Organization/_validate");
|
||||||
httpPost.setEntity(new StringEntity(new FhirContext().newJsonParser().encodeResourceToString(org), ContentType.create(Constants.CT_FHIR_JSON, "UTF-8")));
|
httpPost.setEntity(new StringEntity(ourCtx.newJsonParser().encodeResourceToString(org), ContentType.create(Constants.CT_FHIR_JSON, "UTF-8")));
|
||||||
|
|
||||||
HttpResponse status = ourClient.execute(httpPost);
|
HttpResponse status = ourClient.execute(httpPost);
|
||||||
assertEquals(204, status.getStatusLine().getStatusCode());
|
assertEquals(204, status.getStatusLine().getStatusCode());
|
||||||
|
@ -99,7 +99,7 @@ public class ValidateDstu1Test {
|
||||||
PatientProvider patientProvider = new PatientProvider();
|
PatientProvider patientProvider = new PatientProvider();
|
||||||
|
|
||||||
ServletHandler proxyHandler = new ServletHandler();
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
RestfulServer servlet = new RestfulServer();
|
RestfulServer servlet = new RestfulServer(ourCtx);
|
||||||
servlet.setResourceProviders(patientProvider, new OrganizationProvider());
|
servlet.setResourceProviders(patientProvider, new OrganizationProvider());
|
||||||
ServletHolder servletHolder = new ServletHolder(servlet);
|
ServletHolder servletHolder = new ServletHolder(servlet);
|
||||||
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
import ca.uhn.fhir.model.base.composite.BaseCodingDt;
|
import ca.uhn.fhir.model.base.composite.BaseCodingDt;
|
||||||
import ca.uhn.fhir.model.base.resource.BaseSecurityEvent;
|
import ca.uhn.fhir.model.base.resource.BaseSecurityEvent;
|
||||||
|
@ -64,6 +65,7 @@ public class AuditingInterceptorTest {
|
||||||
private static Server ourServer;
|
private static Server ourServer;
|
||||||
private static RestfulServer servlet;
|
private static RestfulServer servlet;
|
||||||
private IServerInterceptor myInterceptor;
|
private IServerInterceptor myInterceptor;
|
||||||
|
private static final FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
|
|
||||||
private class MockDataStore implements IAuditDataStore {
|
private class MockDataStore implements IAuditDataStore {
|
||||||
|
|
||||||
|
@ -190,7 +192,7 @@ public class AuditingInterceptorTest {
|
||||||
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
|
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
|
||||||
|
|
||||||
ServletHandler proxyHandler = new ServletHandler();
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
servlet = new RestfulServer();
|
servlet = new RestfulServer(ourCtx);
|
||||||
servlet.setResourceProviders(patientProvider);
|
servlet.setResourceProviders(patientProvider);
|
||||||
ServletHolder servletHolder = new ServletHolder(servlet);
|
ServletHolder servletHolder = new ServletHolder(servlet);
|
||||||
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
||||||
|
|
|
@ -24,6 +24,7 @@ import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
import ca.uhn.fhir.model.dstu.resource.OperationOutcome;
|
import ca.uhn.fhir.model.dstu.resource.OperationOutcome;
|
||||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||||
|
@ -52,6 +53,7 @@ public class ExceptionHandlingInterceptorTest {
|
||||||
private static Server ourServer;
|
private static Server ourServer;
|
||||||
private static RestfulServer servlet;
|
private static RestfulServer servlet;
|
||||||
private static ExceptionHandlingInterceptor myInterceptor;
|
private static ExceptionHandlingInterceptor myInterceptor;
|
||||||
|
private static final FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void before() {
|
public void before() {
|
||||||
|
@ -109,7 +111,7 @@ public class ExceptionHandlingInterceptorTest {
|
||||||
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
|
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
|
||||||
|
|
||||||
ServletHandler proxyHandler = new ServletHandler();
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
servlet = new RestfulServer();
|
servlet = new RestfulServer(ourCtx);
|
||||||
servlet.setResourceProviders(patientProvider);
|
servlet.setResourceProviders(patientProvider);
|
||||||
ServletHolder servletHolder = new ServletHolder(servlet);
|
ServletHolder servletHolder = new ServletHolder(servlet);
|
||||||
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.invocation.InvocationOnMock;
|
import org.mockito.invocation.InvocationOnMock;
|
||||||
import org.mockito.stubbing.Answer;
|
import org.mockito.stubbing.Answer;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||||
import ca.uhn.fhir.rest.annotation.Search;
|
import ca.uhn.fhir.rest.annotation.Search;
|
||||||
import ca.uhn.fhir.rest.method.RequestDetails;
|
import ca.uhn.fhir.rest.method.RequestDetails;
|
||||||
|
@ -43,6 +44,7 @@ public class ExceptionInterceptorMethodTest {
|
||||||
private static RestfulServer servlet;
|
private static RestfulServer servlet;
|
||||||
private IServerInterceptor myInterceptor;
|
private IServerInterceptor myInterceptor;
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExceptionInterceptorMethodTest.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExceptionInterceptorMethodTest.class);
|
||||||
|
private static final FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testThrowUnprocessableEntityException() throws Exception {
|
public void testThrowUnprocessableEntityException() throws Exception {
|
||||||
|
@ -112,7 +114,7 @@ public class ExceptionInterceptorMethodTest {
|
||||||
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
|
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
|
||||||
|
|
||||||
ServletHandler proxyHandler = new ServletHandler();
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
servlet = new RestfulServer();
|
servlet = new RestfulServer(ourCtx);
|
||||||
servlet.setResourceProviders(patientProvider);
|
servlet.setResourceProviders(patientProvider);
|
||||||
ServletHolder servletHolder = new ServletHolder(servlet);
|
ServletHolder servletHolder = new ServletHolder(servlet);
|
||||||
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
proxyHandler.addServletWithMapping(servletHolder, "/*");
|
||||||
|
|
|
@ -17,7 +17,7 @@ import ca.uhn.fhir.model.primitive.StringDt;
|
||||||
|
|
||||||
public class FhirTerserTest {
|
public class FhirTerserTest {
|
||||||
|
|
||||||
private static FhirContext ourCtx = new FhirContext();
|
private static FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAllPopulatedChildElementsOfType() {
|
public void testGetAllPopulatedChildElementsOfType() {
|
||||||
|
@ -29,7 +29,7 @@ public class FhirTerserTest {
|
||||||
p.addAddress().addLine("Line2");
|
p.addAddress().addLine("Line2");
|
||||||
p.addName().addFamily("Line3");
|
p.addName().addFamily("Line3");
|
||||||
|
|
||||||
FhirTerser t = new FhirContext().newTerser();
|
FhirTerser t = ourCtx.newTerser();
|
||||||
List<StringDt> strings = t.getAllPopulatedChildElementsOfType(p, StringDt.class);
|
List<StringDt> strings = t.getAllPopulatedChildElementsOfType(p, StringDt.class);
|
||||||
|
|
||||||
assertEquals(3, strings.size());
|
assertEquals(3, strings.size());
|
||||||
|
@ -43,7 +43,7 @@ public class FhirTerserTest {
|
||||||
Observation obs = new Observation();
|
Observation obs = new Observation();
|
||||||
obs.setValue(new QuantityDt(123L));
|
obs.setValue(new QuantityDt(123L));
|
||||||
|
|
||||||
FhirTerser t = new FhirContext().newTerser();
|
FhirTerser t = ourCtx.newTerser();
|
||||||
|
|
||||||
// As string
|
// As string
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,7 +26,7 @@ import static org.junit.Assert.fail;
|
||||||
|
|
||||||
public class ResourceValidatorTest {
|
public class ResourceValidatorTest {
|
||||||
|
|
||||||
private static FhirContext ourCtx = new FhirContext();
|
private static FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
private static Locale ourDefaultLocale;
|
private static Locale ourDefaultLocale;
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceValidatorTest.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceValidatorTest.class);
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class ValidationResultTest {
|
public class ValidationResultDstu1Test {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isSuccessful_IsTrueForNullOperationOutcome() {
|
public void isSuccessful_IsTrueForNullOperationOutcome() {
|
|
@ -8,12 +8,12 @@ import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.validation.FhirValidator;
|
import ca.uhn.fhir.validation.FhirValidator;
|
||||||
|
|
||||||
public class ValidatorInstantiatorTest {
|
public class ValidatorInstantiatorTest {
|
||||||
|
private static FhirContext ourCtx = FhirContext.forDstu1();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testValidator() {
|
public void testValidator() {
|
||||||
|
|
||||||
FhirContext ctx = new FhirContext();
|
FhirValidator val = ourCtx.newValidator();
|
||||||
FhirValidator val = ctx.newValidator();
|
|
||||||
|
|
||||||
// We have a full classpath, so take advantage
|
// We have a full classpath, so take advantage
|
||||||
assertTrue(val.isValidateAgainstStandardSchema());
|
assertTrue(val.isValidateAgainstStandardSchema());
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
</logger>
|
</logger>
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<root level="debug">
|
<root level="info">
|
||||||
<appender-ref ref="STDOUT" />
|
<appender-ref ref="STDOUT" />
|
||||||
</root>
|
</root>
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
# Format is file:/path/foo.html or classpath:/com/classpath/foo.html
|
# Format is file:/path/foo.html or classpath:/com/classpath/foo.html
|
||||||
#
|
#
|
||||||
practitioner.class=ca.uhn.fhir.model.dstu.resource.Practitioner
|
practitioner.class=ca.uhn.fhir.model.dstu.resource.Practitioner
|
||||||
practitioner.narrative=file:src/test/resources/narrative/Practitioner.html
|
practitioner.narrative=classpath:narrative/Practitioner.html
|
||||||
|
|
||||||
# You may also override/define behaviour for datatypes
|
# You may also override/define behaviour for datatypes
|
||||||
humanname.class=ca.uhn.fhir.model.dstu.composite.HumanNameDt
|
humanname.class=ca.uhn.fhir.model.dstu.composite.HumanNameDt
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue