() {
@Override
public ReaderInputStream answer(InvocationOnMock theInvocation) throws Throwable {
- return new ReaderInputStream(new StringReader(respString), Charset.forName("UTF-8")); }});
+ return new ReaderInputStream(new StringReader(respString), Charset.forName("UTF-8"));
+ }
+ });
IGenericClient client = ourCtx.newRestfulGenericClient("http://example.com/fhir");
-// client.operation().onServer().withParameters(inParams);
+ int idx = 0;
+
+ Parameters resp = client.operation().ofServer().named("$SOMEOPERATION").withParameters(inParams).execute();
+ assertEquals(respString, p.encodeResourceToString(resp));
+ assertEquals(1, capt.getAllValues().get(idx).getHeaders(Constants.HEADER_CONTENT_TYPE).length);
+ assertEquals(EncodingEnum.XML.getResourceContentType() + Constants.HEADER_SUFFIX_CT_UTF_8, capt.getAllValues().get(idx).getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue());
+ assertEquals(extractBody(capt, idx), reqString);
+ assertEquals("POST", capt.getAllValues().get(idx).getRequestLine().getMethod());
+ idx++;
+
}
@Test
diff --git a/hapi-fhir-structures-hl7org-dstu2/src/main/java/org/hl7/fhir/instance/model/Binary.java b/hapi-fhir-structures-hl7org-dstu2/src/main/java/org/hl7/fhir/instance/model/Binary.java
index 718db72ffc7..0d3e4c858ab 100644
--- a/hapi-fhir-structures-hl7org-dstu2/src/main/java/org/hl7/fhir/instance/model/Binary.java
+++ b/hapi-fhir-structures-hl7org-dstu2/src/main/java/org/hl7/fhir/instance/model/Binary.java
@@ -39,11 +39,12 @@ import org.hl7.fhir.instance.model.annotations.SearchParamDefinition;
import org.hl7.fhir.instance.model.annotations.Block;
import org.hl7.fhir.instance.model.annotations.Child;
import org.hl7.fhir.instance.model.annotations.Description;
+import org.hl7.fhir.instance.model.api.IBaseBinary;
/**
* A binary resource can contain any content, whether text, image, pdf, zip archive, etc.
*/
@ResourceDef(name="Binary", profile="http://hl7.org/fhir/Profile/Binary")
-public class Binary extends Resource {
+public class Binary extends Resource implements IBaseBinary {
/**
* MimeType of the binary content represented as a standard MimeType (BCP 13).
@@ -212,5 +213,20 @@ public class Binary extends Resource {
@SearchParamDefinition(name="contenttype", path="Binary.contentType", description="MimeType of the binary content", type="token" )
public static final String SP_CONTENTTYPE = "contenttype";
+@Override
+public String getContentAsBase64() {
+ return getContentElement().getValueAsString();
+}
+
+@Override
+public Binary setContentAsBase64(String theContent) {
+ if (theContent != null) {
+ getContentElement().setValueAsString(theContent);
+ } else {
+ setContent(null);
+ }
+ return this;
+}
+
}
diff --git a/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/model/ModelInheritanceTest.java b/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/model/ModelInheritanceTest.java
index 32b078bbb7d..85340e98add 100644
--- a/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/model/ModelInheritanceTest.java
+++ b/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/model/ModelInheritanceTest.java
@@ -1,12 +1,11 @@
package ca.uhn.fhir.model;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
import org.hl7.fhir.instance.model.Address;
import org.hl7.fhir.instance.model.BackboneElement;
import org.hl7.fhir.instance.model.Base;
+import org.hl7.fhir.instance.model.Binary;
import org.hl7.fhir.instance.model.BooleanType;
import org.hl7.fhir.instance.model.Bundle;
import org.hl7.fhir.instance.model.Coding;
@@ -19,6 +18,7 @@ import org.hl7.fhir.instance.model.ICompositeType;
import org.hl7.fhir.instance.model.IPrimitiveType;
import org.hl7.fhir.instance.model.IdType;
import org.hl7.fhir.instance.model.Identifier;
+import org.hl7.fhir.instance.model.Identifier.IdentifierUseEnumFactory;
import org.hl7.fhir.instance.model.IntegerType;
import org.hl7.fhir.instance.model.Meta;
import org.hl7.fhir.instance.model.Narrative;
@@ -27,11 +27,11 @@ import org.hl7.fhir.instance.model.Reference;
import org.hl7.fhir.instance.model.Resource;
import org.hl7.fhir.instance.model.Timing;
import org.hl7.fhir.instance.model.Type;
-import org.hl7.fhir.instance.model.Identifier.IdentifierUseEnumFactory;
import org.hl7.fhir.instance.model.annotations.Block;
import org.hl7.fhir.instance.model.annotations.Child;
import org.hl7.fhir.instance.model.api.IAnyResource;
import org.hl7.fhir.instance.model.api.IBackboneElement;
+import org.hl7.fhir.instance.model.api.IBaseBinary;
import org.hl7.fhir.instance.model.api.IBaseBooleanDatatype;
import org.hl7.fhir.instance.model.api.IBaseBundle;
import org.hl7.fhir.instance.model.api.IBaseDatatype;
@@ -49,8 +49,7 @@ import org.hl7.fhir.instance.model.api.IReference;
import org.junit.Test;
public class ModelInheritanceTest {
-
- /**
+ /*
*
* Other changes:
*
@@ -71,11 +70,6 @@ public class ModelInheritanceTest {
*
*/
- @Test
- public void testType() {
- assertTrue(IBaseDatatype.class.isAssignableFrom(Type.class));
- }
-
/**
* This one should apply to all composite types
*/
@@ -84,76 +78,6 @@ public class ModelInheritanceTest {
assertTrue(ICompositeType.class.isAssignableFrom(Address.class));
}
- @Test
- public void testBase() {
- assertTrue(IBase.class.isAssignableFrom(Base.class));
- }
-
- public void testIdentifierUse() throws Exception {
- Child child = Identifier.class.getField("use").getAnnotation(Child.class);
- assertEquals(IdentifierUseEnumFactory.class, child.enumFactory());
- }
-
-
- /**
- * Should be "implements IBaseExtension"
- */
- @Test
- public void testExtension() {
- assertTrue(IBaseExtension.class.isAssignableFrom(Extension.class));
- assertTrue(IBaseHasExtensions.class.isAssignableFrom(Extension.class));
- }
-
- @Test
- public void testNarrative() {
- assertTrue(INarrative.class.isAssignableFrom(Narrative.class));
- }
-
- @Test
- public void testBooleanType() {
- assertTrue(IBaseBooleanDatatype.class.isAssignableFrom(BooleanType.class));
- }
-
- @Test
- public void testDecimalType() {
- assertTrue(IBaseDecimalDatatype.class.isAssignableFrom(DecimalType.class));
- }
-
- @Test
- public void testIntegerType() {
- assertTrue(IBaseIntegerDatatype.class.isAssignableFrom(IntegerType.class));
- }
-
- @Test
- public void testPrimitiveType() {
- assertTrue(IPrimitiveType.class.isAssignableFrom(PrimitiveType.class));
- assertTrue(IBaseHasExtensions.class.isAssignableFrom(PrimitiveType.class));
- }
-
- @Test
- public void testResource() {
- assertTrue(IAnyResource.class.isAssignableFrom(Resource.class));
- }
-
- @Test
- public void testBundle() {
- assertTrue(IBaseBundle.class.isAssignableFrom(Bundle.class));
- }
-
- public void testIdType() {
- assertTrue(IIdType.class.isAssignableFrom(IdType.class));
- }
-
- @Test
- public void testReference() {
- assertTrue(IReference.class.isAssignableFrom(Reference.class));
- }
-
- @Test
- public void testMeta() {
- assertTrue(IMetaType.class.isAssignableFrom(Meta.class));
- }
-
@Test
public void testBackboneElement() {
assertTrue(IBackboneElement.class.isAssignableFrom(BackboneElement.class));
@@ -162,8 +86,36 @@ public class ModelInheritanceTest {
}
@Test
- public void testElement() {
- assertTrue(IBaseHasExtensions.class.isAssignableFrom(Element.class));
+ public void testBase() {
+ assertTrue(IBase.class.isAssignableFrom(Base.class));
+ }
+
+
+ @Test
+ public void testBinary() {
+ assertTrue(IBaseBinary.class.isAssignableFrom(Binary.class));
+ }
+
+
+ @Test
+ public void testBooleanType() {
+ assertTrue(IBaseBooleanDatatype.class.isAssignableFrom(BooleanType.class));
+ }
+
+
+ @Test
+ public void testBundle() {
+ assertTrue(IBaseBundle.class.isAssignableFrom(Bundle.class));
+ }
+
+ @Test
+ public void testCoding() {
+ assertTrue(ICoding.class.isAssignableFrom(Coding.class));
+ }
+
+ @Test
+ public void testDecimalType() {
+ assertTrue(IBaseDecimalDatatype.class.isAssignableFrom(DecimalType.class));
}
@Test
@@ -173,8 +125,57 @@ public class ModelInheritanceTest {
}
@Test
- public void testCoding() {
- assertTrue(ICoding.class.isAssignableFrom(Coding.class));
+ public void testElement() {
+ assertTrue(IBaseHasExtensions.class.isAssignableFrom(Element.class));
+ }
+
+ /**
+ * Should be "implements IBaseExtension"
+ */
+ @Test
+ public void testExtension() {
+ assertTrue(IBaseExtension.class.isAssignableFrom(Extension.class));
+ assertTrue(IBaseHasExtensions.class.isAssignableFrom(Extension.class));
+ }
+
+ public void testIdentifierUse() throws Exception {
+ Child child = Identifier.class.getField("use").getAnnotation(Child.class);
+ assertEquals(IdentifierUseEnumFactory.class, child.enumFactory());
+ }
+
+ public void testIdType() {
+ assertTrue(IIdType.class.isAssignableFrom(IdType.class));
+ }
+
+ @Test
+ public void testIntegerType() {
+ assertTrue(IBaseIntegerDatatype.class.isAssignableFrom(IntegerType.class));
+ }
+
+ @Test
+ public void testMeta() {
+ assertTrue(IMetaType.class.isAssignableFrom(Meta.class));
+ }
+
+ @Test
+ public void testNarrative() {
+ assertTrue(INarrative.class.isAssignableFrom(Narrative.class));
+ }
+
+ @Test
+ public void testPrimitiveType() {
+ assertTrue(IPrimitiveType.class.isAssignableFrom(PrimitiveType.class));
+ assertTrue(IBaseHasExtensions.class.isAssignableFrom(PrimitiveType.class));
+ }
+
+ @Test
+ public void testReference() {
+ assertTrue(IReference.class.isAssignableFrom(Reference.class));
+ }
+
+ @Test
+ public void testResource() {
+ assertTrue(IAnyResource.class.isAssignableFrom(Resource.class));
}
@Test
@@ -183,4 +184,9 @@ public class ModelInheritanceTest {
assertNotNull(Timing.TimingRepeatComponent.class.getAnnotation(Block.class));
}
+ @Test
+ public void testType() {
+ assertTrue(IBaseDatatype.class.isAssignableFrom(Type.class));
+ }
+
}
diff --git a/hapi-tinder-plugin/src/main/resources/vm/resource.vm b/hapi-tinder-plugin/src/main/resources/vm/resource.vm
index 6daa7a427a5..888601d81b7 100644
--- a/hapi-tinder-plugin/src/main/resources/vm/resource.vm
+++ b/hapi-tinder-plugin/src/main/resources/vm/resource.vm
@@ -41,11 +41,8 @@ import ${import};
@ResourceDef(name="${elementName}", profile="${profile}", id="${id}")
public class ${className} extends ca.uhn.fhir.model.${version}.resource.BaseResource
implements #{if}( ${className}=="OperationOutcome" || ${className}=="Conformance" || ${className}=="SecurityEvent" ) ca.uhn.fhir.model.base.resource.Base${className} #{else} IResource #{end}
-#if ( ${className} == "Bundle" )
- , org.hl7.fhir.instance.model.api.IBaseBundle
-#end
-#if ( ${className}=="Binary" )
- , ca.uhn.fhir.model.base.resource.Base${className}
+#if ( ${className} == "Bundle" || ${className} == "Parameters" || ${className} == "Binary" )
+ , org.hl7.fhir.instance.model.api.IBase${className}
#end
{