diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/ServerValidationModeEnum.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/ServerValidationModeEnum.java
index 9e213dd38bb..a26356e34c7 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/ServerValidationModeEnum.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/ServerValidationModeEnum.java
@@ -1,5 +1,25 @@
package ca.uhn.fhir.rest.client;
+/*
+ * #%L
+ * HAPI FHIR - Core Library
+ * %%
+ * Copyright (C) 2014 - 2015 University Health Network
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
import ca.uhn.fhir.context.FhirContext;
public enum ServerValidationModeEnum {
diff --git a/hapi-fhir-jpaserver-base/pom.xml b/hapi-fhir-jpaserver-base/pom.xml
index d321567c8da..389c97f9851 100644
--- a/hapi-fhir-jpaserver-base/pom.xml
+++ b/hapi-fhir-jpaserver-base/pom.xml
@@ -68,7 +68,7 @@
org.hamcrest
- hamcrest-all
+ java-hamcrest
${hamcrest_version}
test
diff --git a/hapi-fhir-jpaserver-test/pom.xml b/hapi-fhir-jpaserver-test/pom.xml
index 8992cc2d5f9..f8023be8b22 100644
--- a/hapi-fhir-jpaserver-test/pom.xml
+++ b/hapi-fhir-jpaserver-test/pom.xml
@@ -43,7 +43,7 @@
org.hamcrest
- hamcrest-all
+ java-hamcrest
${hamcrest_version}
test
diff --git a/hapi-fhir-oauth2/pom.xml b/hapi-fhir-oauth2/pom.xml
index 5171085fdce..7ba35d308e9 100644
--- a/hapi-fhir-oauth2/pom.xml
+++ b/hapi-fhir-oauth2/pom.xml
@@ -107,7 +107,7 @@
org.hamcrest
- hamcrest-all
+ java-hamcrest
${hamcrest_version}
test
diff --git a/hapi-fhir-structures-dev/pom.xml b/hapi-fhir-structures-dev/pom.xml
index 4d0cf49f82f..4a562fabe99 100644
--- a/hapi-fhir-structures-dev/pom.xml
+++ b/hapi-fhir-structures-dev/pom.xml
@@ -159,7 +159,7 @@
org.hamcrest
- hamcrest-all
+ java-hamcrest
${hamcrest_version}
test
diff --git a/hapi-fhir-structures-dstu/pom.xml b/hapi-fhir-structures-dstu/pom.xml
index 881e2f20d5c..08087319acc 100644
--- a/hapi-fhir-structures-dstu/pom.xml
+++ b/hapi-fhir-structures-dstu/pom.xml
@@ -157,7 +157,7 @@
org.hamcrest
- hamcrest-all
+ java-hamcrest
${hamcrest_version}
test
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/parser/MyPatient.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/parser/MyPatient.java
index b3c9b635b2c..61939f94258 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/parser/MyPatient.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/parser/MyPatient.java
@@ -14,49 +14,70 @@ import ca.uhn.fhir.model.primitive.StringDt;
@ResourceDef()
public class MyPatient extends Patient {
-
- @Child(name="petName")
- @Extension(url="http://example.com/dontuse#petname", definedLocally=false, isModifier=false)
- @Description(shortDefinition="The name of the patient's favourite pet")
- private StringDt myPetName;
-
- @Child(name="importantDates", max=Child.MAX_UNLIMITED)
- @Extension(url="http://example.com/dontuse#importantDates", definedLocally=false, isModifier=true)
- @Description(shortDefinition="Some dates of note for the patient")
+
+ @Child(name = "importantDates", max = Child.MAX_UNLIMITED)
+ @Extension(url = "http://example.com/dontuse#importantDates", definedLocally = false, isModifier = true)
+ @Description(shortDefinition = "Some dates of note for the patient")
private List myImportantDates;
-
- @Child(name="managingOrganization", order=Child.REPLACE_PARENT, min=0, max=1, type={
- MyOrganization.class })
- @Description(
- shortDefinition="Organization that is the custodian of the patient record",
- formalDefinition="Organization that is the custodian of the patient record"
- )
+
+ @Child(name = "managingOrganization", order = Child.REPLACE_PARENT, min = 0, max = 1, type = { MyOrganization.class })
+ @Description(shortDefinition = "Organization that is the custodian of the patient record", formalDefinition = "Organization that is the custodian of the patient record")
private ResourceReferenceDt myManagingOrganization;
-
-
- @Override
- public boolean isEmpty() {
- return super.isEmpty() && myPetName.isEmpty();
- }
-
-
+
+ @Child(name = "petName")
+ @Extension(url = "http://example.com/dontuse#petname", definedLocally = false, isModifier = false)
+ @Description(shortDefinition = "The name of the patient's favourite pet")
+ private StringDt myPetName;
+
+ @Child(name = "someOrganization", min = 0, max = 1, type = { MyOrganization.class })
+ @Extension(definedLocally = true, isModifier = false, url = "http://foo/someOrg")
+ private ResourceReferenceDt mySomeOrganization;
+
public List getImportantDates() {
- if (myImportantDates==null) {
+ if (myImportantDates == null) {
myImportantDates = new ArrayList();
}
return myImportantDates;
}
+ public ResourceReferenceDt getManagingOrganization() {
+ if (myManagingOrganization == null) {
+ myManagingOrganization = new ResourceReferenceDt();
+ }
+ return myManagingOrganization;
+ }
+
public StringDt getPetName() {
return myPetName;
}
+ public ResourceReferenceDt getSomeOrganization() {
+ if (mySomeOrganization == null) {
+ mySomeOrganization = new ResourceReferenceDt();
+ }
+ return mySomeOrganization;
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return super.isEmpty() && myPetName.isEmpty();
+ }
+
public void setImportantDates(List theImportantDates) {
myImportantDates = theImportantDates;
}
+ public MyPatient setManagingOrganization(ResourceReferenceDt theManagingOrganization) {
+ myManagingOrganization = theManagingOrganization;
+ return this;
+ }
+
public void setPetName(StringDt thePetName) {
myPetName = thePetName;
}
-
+
+ public void setSomeOrganization(ResourceReferenceDt theSomeOrganization) {
+ mySomeOrganization = theSomeOrganization;
+ }
+
}
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/parser/XmlParserTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/parser/XmlParserTest.java
index c607d942166..a60f12dfa1d 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/parser/XmlParserTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/parser/XmlParserTest.java
@@ -3,13 +3,7 @@ package ca.uhn.fhir.parser;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.stringContainsInOrder;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -27,6 +21,7 @@ import java.util.UUID;
import org.apache.commons.io.IOUtils;
import org.custommonkey.xmlunit.Diff;
import org.custommonkey.xmlunit.XMLUnit;
+import org.hamcrest.Matchers;
import org.hamcrest.core.IsNot;
import org.hamcrest.core.StringContains;
import org.hamcrest.text.StringContainsInOrder;
@@ -739,7 +734,7 @@ public class XmlParserTest {
}
@Test
- public void testExtensions() throws DataFormatException {
+ public void testExtensionsWithDatatypes() throws DataFormatException {
MyPatient patient = new MyPatient();
patient.setPetName(new StringDt("Fido"));
@@ -761,6 +756,52 @@ public class XmlParserTest {
}
+ /**
+ * Test for #82 - Not yet enabled because the test won't pass
+ */
+// @Test
+ public void testCustomTypeInReplaceParent() throws DataFormatException {
+
+ MyPatient patient = new MyPatient();
+ patient.addName().addFamily("PatientName");
+
+ MyOrganization org = new MyOrganization();
+ org.setName("OrgName");
+ patient.getManagingOrganization().setResource(org);
+
+ String str = ourCtx.newXmlParser().encodeResourceToString(patient);
+ ourLog.info(str);
+
+ assertThat(str, Matchers.stringContainsInOrder(""));
+
+ MyPatient parse = ourCtx.newXmlParser().parseResource(MyPatient.class, str);
+ assertEquals("PatientName", parse.getNameFirstRep().getFamilyAsSingleString());
+ assertEquals("OrgName", ((MyOrganization)parse.getManagingOrganization().getResource()).getName().getValue());
+ }
+
+ /**
+ * Test for #82 - Not yet enabled because the test won't pass
+ */
+// @Test
+ public void testCustomTypeInExtension() throws DataFormatException {
+
+ MyPatient patient = new MyPatient();
+ patient.addName().addFamily("PatientName");
+
+ MyOrganization org = new MyOrganization();
+ org.setName("OrgName");
+ patient.getSomeOrganization().setResource(org);
+
+ String str = ourCtx.newXmlParser().encodeResourceToString(patient);
+ ourLog.info(str);
+
+ assertThat(str, Matchers.stringContainsInOrder(""));
+
+ MyPatient parse = ourCtx.newXmlParser().parseResource(MyPatient.class, str);
+ assertEquals("PatientName", parse.getNameFirstRep().getFamilyAsSingleString());
+ assertEquals("OrgName", ((MyOrganization)parse.getSomeOrganization().getResource()).getName().getValue());
+ }
+
@Test
public void testLoadAndAncodeMessage() throws SAXException, IOException {
diff --git a/hapi-fhir-structures-hl7org-dev/pom.xml b/hapi-fhir-structures-hl7org-dev/pom.xml
index c9291229ed9..c1b10957cfa 100644
--- a/hapi-fhir-structures-hl7org-dev/pom.xml
+++ b/hapi-fhir-structures-hl7org-dev/pom.xml
@@ -157,7 +157,7 @@
org.hamcrest
- hamcrest-all
+ java-hamcrest
${hamcrest_version}
test
diff --git a/hapi-fhir-testpage-overlay/pom.xml b/hapi-fhir-testpage-overlay/pom.xml
index 5cae16d31ac..230b8c96d8a 100644
--- a/hapi-fhir-testpage-overlay/pom.xml
+++ b/hapi-fhir-testpage-overlay/pom.xml
@@ -78,7 +78,7 @@
org.hamcrest
- hamcrest-all
+ java-hamcrest
${hamcrest_version}
test
diff --git a/pom.xml b/pom.xml
index 6412fa3db34..6bc70ce8f44 100644
--- a/pom.xml
+++ b/pom.xml
@@ -143,7 +143,7 @@
1.10
10.11.1.1
18.0
- 1.3
+ 2.0.0.0