From 7f965c447f5e855514e807c1afd27e565039053d Mon Sep 17 00:00:00 2001 From: "b.debeaubien" Date: Mon, 27 Oct 2014 13:53:01 -0400 Subject: [PATCH] ServerProfileProvider now uses IdDt.getIdPart() rather than getValue() so that it can find the profiles in in FhirContext's myIdToResourceDefinition. --- .gitignore | 4 ++++ .../provider/ServerProfileProvider.java | 2 +- .../ca/uhn/fhir/context/ModelScannerTest.java | 2 ++ .../rest/server/ResfulServerMethodTest.java | 19 ++++++++++++------- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index d3ee296ebcb..232298d69bd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,9 @@ /bin /target +.idea/ +.project/ +.settings/ +*.iml *.log *.log* nohup.out diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/provider/ServerProfileProvider.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/provider/ServerProfileProvider.java index 2f3e94a43d6..826aafa2096 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/provider/ServerProfileProvider.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/provider/ServerProfileProvider.java @@ -50,7 +50,7 @@ public class ServerProfileProvider implements IResourceProvider { @Read() public Profile getProfileById(@IdParam IdDt theId) { - RuntimeResourceDefinition retVal = myContext.getResourceDefinitionById(theId.getValue()); + RuntimeResourceDefinition retVal = myContext.getResourceDefinitionById(theId.getIdPart()); if (retVal==null) { return null; } diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/context/ModelScannerTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/context/ModelScannerTest.java index 00018828684..29b1e2ca097 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/context/ModelScannerTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/context/ModelScannerTest.java @@ -63,5 +63,7 @@ public class ModelScannerTest { assertNotNull(valueDate); } + + } diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ResfulServerMethodTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ResfulServerMethodTest.java index 2dd748421d5..80ef57c2c70 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ResfulServerMethodTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/rest/server/ResfulServerMethodTest.java @@ -13,6 +13,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; +import ca.uhn.fhir.model.dstu.resource.*; import org.apache.commons.io.IOUtils; import org.apache.http.HttpResponse; import org.apache.http.client.entity.UrlEncodedFormEntity; @@ -44,11 +45,6 @@ import ca.uhn.fhir.model.dstu.composite.CodingDt; import ca.uhn.fhir.model.dstu.composite.HumanNameDt; import ca.uhn.fhir.model.dstu.composite.IdentifierDt; import ca.uhn.fhir.model.dstu.composite.QuantityDt; -import ca.uhn.fhir.model.dstu.resource.AdverseReaction; -import ca.uhn.fhir.model.dstu.resource.Conformance; -import ca.uhn.fhir.model.dstu.resource.DiagnosticReport; -import ca.uhn.fhir.model.dstu.resource.OperationOutcome; -import ca.uhn.fhir.model.dstu.resource.Patient; import ca.uhn.fhir.model.dstu.valueset.IdentifierUseEnum; import ca.uhn.fhir.model.primitive.IdDt; import ca.uhn.fhir.model.primitive.InstantDt; @@ -86,6 +82,7 @@ public class ResfulServerMethodTest { private static int ourPort; private static DummyDiagnosticReportResourceProvider ourReportProvider; private static Server ourServer; + private static RestfulServer ourRestfulServer; @Test public void test404IsPropagatedCorrectly() throws Exception { @@ -995,6 +992,14 @@ public class ResfulServerMethodTest { } + @Test + public void testServerProfileProviderFindsProfiles() { + ServerProfileProvider profileProvider = (ServerProfileProvider)ourRestfulServer.getServerProfilesProvider(); + IdDt id = new IdDt("Profile", "observation"); + Profile profile = profileProvider.getProfileById(id); + assertNotNull(profile); + } + @AfterClass public static void afterClass() throws Exception { ourServer.stop(); @@ -1012,8 +1017,8 @@ public class ResfulServerMethodTest { DummyAdverseReactionResourceProvider adv = new DummyAdverseReactionResourceProvider(); ServletHandler proxyHandler = new ServletHandler(); - DummyRestfulServer servlet = new DummyRestfulServer(patientProvider, profProvider, ourReportProvider, adv); - ServletHolder servletHolder = new ServletHolder(servlet); + ourRestfulServer =new DummyRestfulServer(patientProvider, profProvider, ourReportProvider, adv); + ServletHolder servletHolder = new ServletHolder(ourRestfulServer); proxyHandler.addServletWithMapping(servletHolder, "/*"); ourServer.setHandler(proxyHandler); ourServer.start();