diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/GenericClient.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/GenericClient.java index 622f060741a..772adc52f46 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/GenericClient.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/GenericClient.java @@ -68,6 +68,7 @@ import ca.uhn.fhir.rest.gclient.IDeleteWithQueryTyped; import ca.uhn.fhir.rest.gclient.IGetPage; import ca.uhn.fhir.rest.gclient.IGetPageTyped; import ca.uhn.fhir.rest.gclient.IGetTags; +import ca.uhn.fhir.rest.gclient.IOperation; import ca.uhn.fhir.rest.gclient.IParam; import ca.uhn.fhir.rest.gclient.IQuery; import ca.uhn.fhir.rest.gclient.IRead; @@ -1440,4 +1441,10 @@ public class GenericClient extends BaseClient implements IGenericClient { } + @Override + public IOperation operation() { + // TODO Auto-generated method stub + return null; + } + } diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/IGenericClient.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/IGenericClient.java index 4116438a23b..0479387a149 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/IGenericClient.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/IGenericClient.java @@ -38,6 +38,7 @@ import ca.uhn.fhir.rest.gclient.ICreate; import ca.uhn.fhir.rest.gclient.IDelete; import ca.uhn.fhir.rest.gclient.IGetPage; import ca.uhn.fhir.rest.gclient.IGetTags; +import ca.uhn.fhir.rest.gclient.IOperation; import ca.uhn.fhir.rest.gclient.IRead; import ca.uhn.fhir.rest.gclient.ITransaction; import ca.uhn.fhir.rest.gclient.IUntypedQuery; @@ -342,4 +343,9 @@ public interface IGenericClient { */ T vread(Class theType, String theId, String theVersionId); + /** + * Implementation of the FHIR "extended operations" action + */ + IOperation operation(); + } diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperation.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperation.java new file mode 100644 index 00000000000..edf43c693ff --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperation.java @@ -0,0 +1,5 @@ +package ca.uhn.fhir.rest.gclient; + +public interface IOperation { + +} diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/narrative/CustomThymeleafNarrativeGeneratorTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/narrative/CustomThymeleafNarrativeGeneratorTest.java index 9c07e41c2ed..f7868e25add 100644 --- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/narrative/CustomThymeleafNarrativeGeneratorTest.java +++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/narrative/CustomThymeleafNarrativeGeneratorTest.java @@ -12,11 +12,14 @@ import ca.uhn.fhir.model.dstu.resource.Practitioner; public class CustomThymeleafNarrativeGeneratorTest { private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(CustomThymeleafNarrativeGeneratorTest.class); + + private static FhirContext ourCtx = FhirContext.forDstu1(); @Test public void testGenerator() { CustomThymeleafNarrativeGenerator gen = new CustomThymeleafNarrativeGenerator("file:src/test/resources/narrative/customnarrative.properties"); + gen.setFhirContext(ourCtx); Practitioner p = new Practitioner(); p.addIdentifier("sys", "val1"); diff --git a/hapi-fhir-structures-dstu2/.gitignore b/hapi-fhir-structures-dstu2/.gitignore index 3b27a3b49fd..3f6aa3cd273 100644 --- a/hapi-fhir-structures-dstu2/.gitignore +++ b/hapi-fhir-structures-dstu2/.gitignore @@ -9,3 +9,4 @@ /target/ /target/ /target/ +/target/ diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/client/GenericClientTestDstu2.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/client/GenericClientTestDstu2.java index 73e38b6cc45..676f7d8b741 100644 --- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/client/GenericClientTestDstu2.java +++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/client/GenericClientTestDstu2.java @@ -5,6 +5,7 @@ import static org.junit.Assert.*; import static org.mockito.Mockito.*; import java.io.IOException; +import java.io.Reader; import java.io.StringReader; import java.nio.charset.Charset; import java.util.ArrayList; @@ -31,9 +32,11 @@ import org.mockito.stubbing.Answer; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.model.api.Bundle; import ca.uhn.fhir.model.api.IResource; +import ca.uhn.fhir.model.dstu2.resource.Parameters; import ca.uhn.fhir.model.dstu2.resource.Patient; import ca.uhn.fhir.model.dstu2.valueset.HTTPVerbEnum; import ca.uhn.fhir.model.primitive.IdDt; +import ca.uhn.fhir.model.primitive.StringDt; import ca.uhn.fhir.rest.server.Constants; import ca.uhn.fhir.rest.server.EncodingEnum; @@ -79,6 +82,32 @@ public class GenericClientTestDstu2 { } + @Test + public void testOperationWithListOfParameters() throws Exception { + Parameters inParams = new Parameters(); + inParams.addParameter().setValue(new StringDt("STRINGVALIN1")); + inParams.addParameter().setValue(new StringDt("STRINGVALIN2")); + String reqString = ourCtx.newXmlParser().encodeResourceToString(inParams); + + Parameters outParams = new Parameters(); + outParams.addParameter().setValue(new StringDt("STRINGVALOUT1")); + outParams.addParameter().setValue(new StringDt("STRINGVALOUT2")); + final String respString = ourCtx.newXmlParser().encodeResourceToString(outParams); + + ArgumentCaptor capt = ArgumentCaptor.forClass(HttpUriRequest.class); + when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse); + when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK")); + when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_JSON + "; charset=UTF-8")); + when(myHttpResponse.getEntity().getContent()).thenAnswer(new Answer() { + @Override + public ReaderInputStream answer(InvocationOnMock theInvocation) throws Throwable { + return new ReaderInputStream(new StringReader(respString), Charset.forName("UTF-8")); }}); + + IGenericClient client = ourCtx.newRestfulGenericClient("http://example.com/fhir"); + +// client.operation().onServer().withParameters(inParams); + } + @Test public void testTransactionWithListOfResources() throws Exception { @@ -122,14 +151,14 @@ public class GenericClientTestDstu2 { assertEquals("POST", requestBundle.getEntry().get(0).getTransaction().getMethod()); assertEquals("PUT", requestBundle.getEntry().get(1).getTransaction().getMethod()); assertEquals("Patient/2", requestBundle.getEntry().get(1).getTransaction().getUrl()); - + p1 = (Patient) response.get(0); assertEquals(new IdDt("Patient/1/_history/1"), p1.getId().toUnqualified()); -// assertEquals("PATIENT1", p1.getName().get(0).getFamily().get(0).getValue()); + // assertEquals("PATIENT1", p1.getName().get(0).getFamily().get(0).getValue()); p2 = (Patient) response.get(1); assertEquals(new IdDt("Patient/2/_history/2"), p2.getId().toUnqualified()); -// assertEquals("PATIENT2", p2.getName().get(0).getFamily().get(0).getValue()); + // assertEquals("PATIENT2", p2.getName().get(0).getFamily().get(0).getValue()); } @Test diff --git a/hapi-tinder-test/.gitignore b/hapi-tinder-test/.gitignore index 5c7c9bd2ee2..13c832979f6 100644 --- a/hapi-tinder-test/.gitignore +++ b/hapi-tinder-test/.gitignore @@ -2,3 +2,4 @@ target/ /target *.log *.log* +/target/