|
|
|
@ -1,14 +1,21 @@
|
|
|
|
|
package ca.uhn.fhir.rest.client;
|
|
|
|
|
|
|
|
|
|
import ca.uhn.fhir.context.ConfigurationException;
|
|
|
|
|
import ca.uhn.fhir.context.FhirContext;
|
|
|
|
|
import ca.uhn.fhir.model.api.Include;
|
|
|
|
|
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
|
|
|
|
import ca.uhn.fhir.rest.annotation.*;
|
|
|
|
|
import ca.uhn.fhir.rest.annotation.Elements;
|
|
|
|
|
import ca.uhn.fhir.rest.annotation.IdParam;
|
|
|
|
|
import ca.uhn.fhir.rest.annotation.IncludeParam;
|
|
|
|
|
import ca.uhn.fhir.rest.annotation.OptionalParam;
|
|
|
|
|
import ca.uhn.fhir.rest.annotation.RequiredParam;
|
|
|
|
|
import ca.uhn.fhir.rest.annotation.Search;
|
|
|
|
|
import ca.uhn.fhir.rest.api.Constants;
|
|
|
|
|
import ca.uhn.fhir.rest.api.EncodingEnum;
|
|
|
|
|
import ca.uhn.fhir.rest.api.MethodOutcome;
|
|
|
|
|
import ca.uhn.fhir.rest.api.SummaryEnum;
|
|
|
|
|
import ca.uhn.fhir.rest.client.apache.ApacheHttpRequest;
|
|
|
|
|
import ca.uhn.fhir.rest.client.apache.ResourceEntity;
|
|
|
|
|
import ca.uhn.fhir.rest.client.api.IBasicClient;
|
|
|
|
|
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
|
|
|
|
import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum;
|
|
|
|
@ -47,13 +54,24 @@ import org.mockito.internal.stubbing.defaultanswers.ReturnsDeepStubs;
|
|
|
|
|
import org.mockito.invocation.InvocationOnMock;
|
|
|
|
|
import org.mockito.stubbing.Answer;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
import java.io.StringReader;
|
|
|
|
|
import java.nio.charset.Charset;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
|
|
import static org.hamcrest.Matchers.*;
|
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
|
import static org.hamcrest.Matchers.containsString;
|
|
|
|
|
import static org.hamcrest.Matchers.either;
|
|
|
|
|
import static org.hamcrest.Matchers.equalTo;
|
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
|
import static org.junit.Assert.assertNotNull;
|
|
|
|
|
import static org.junit.Assert.assertNull;
|
|
|
|
|
import static org.junit.Assert.assertThat;
|
|
|
|
|
import static org.junit.Assert.fail;
|
|
|
|
|
import static org.mockito.Mockito.mock;
|
|
|
|
|
import static org.mockito.Mockito.when;
|
|
|
|
|
|
|
|
|
@ -144,7 +162,7 @@ public class ClientR4Test {
|
|
|
|
|
when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
|
|
|
|
|
when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 201, "OK"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_TEXT + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), StandardCharsets.UTF_8));
|
|
|
|
|
when(myHttpResponse.getAllHeaders()).thenReturn(toHeaderArray("Location", "http://example.com/fhir/Patient/100/_history/200"));
|
|
|
|
|
|
|
|
|
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
|
|
|
@ -173,7 +191,7 @@ public class ClientR4Test {
|
|
|
|
|
when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
|
|
|
|
|
when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 400, "foobar"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_TEXT + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader("foobar"), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader("foobar"), StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
ourCtx.newRestfulClient(ITestClient.class, "http://foo").createPatient(patient);
|
|
|
|
@ -197,7 +215,7 @@ public class ClientR4Test {
|
|
|
|
|
when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
|
|
|
|
|
when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 201, "OK"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(ourCtx.newXmlParser().encodeResourceToString(patient)), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(ourCtx.newXmlParser().encodeResourceToString(patient)), StandardCharsets.UTF_8));
|
|
|
|
|
when(myHttpResponse.getAllHeaders()).thenReturn(toHeaderArray("Location", "http://example.com/fhir/Patient/100/_history/200"));
|
|
|
|
|
|
|
|
|
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
|
|
|
@ -221,7 +239,7 @@ public class ClientR4Test {
|
|
|
|
|
when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
|
|
|
|
|
when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 201, "OK"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(resp), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(resp), StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
|
|
|
|
MethodOutcome response = client.deletePatient(new IdType("1234"));
|
|
|
|
@ -238,7 +256,7 @@ public class ClientR4Test {
|
|
|
|
|
when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
|
|
|
|
|
when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 204, "OK"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_TEXT + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
|
|
|
|
client.deleteDiagnosticReport(new IdType("1234"));
|
|
|
|
@ -259,7 +277,7 @@ public class ClientR4Test {
|
|
|
|
|
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_XML + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
|
|
|
|
CapabilityStatement response = (CapabilityStatement) client.getServerConformanceStatement();
|
|
|
|
@ -278,7 +296,7 @@ public class ClientR4Test {
|
|
|
|
|
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_XML_NEW + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
|
|
|
|
Bundle response = client.getHistoryPatientInstance(new IdType("111"));
|
|
|
|
@ -298,7 +316,7 @@ public class ClientR4Test {
|
|
|
|
|
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_XML_NEW + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
|
|
|
|
Bundle response = client.getHistoryPatientType();
|
|
|
|
@ -316,7 +334,7 @@ public class ClientR4Test {
|
|
|
|
|
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_XML_NEW + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
|
|
|
|
Bundle response = client.getHistoryServer();
|
|
|
|
@ -340,7 +358,7 @@ public class ClientR4Test {
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenAnswer(new Answer<InputStream>() {
|
|
|
|
|
@Override
|
|
|
|
|
public InputStream answer(InvocationOnMock theInvocation) throws Throwable {
|
|
|
|
|
return new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8"));
|
|
|
|
|
return new ReaderInputStream(new StringReader(msg), StandardCharsets.UTF_8);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -410,7 +428,7 @@ public class ClientR4Test {
|
|
|
|
|
|
|
|
|
|
when(myHttpResponse.getAllHeaders()).thenReturn(headers);
|
|
|
|
|
when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
|
|
|
|
// Patient response = client.findPatientByMrn(new
|
|
|
|
@ -422,7 +440,7 @@ public class ClientR4Test {
|
|
|
|
|
|
|
|
|
|
assertEquals("http://foo.com/Patient/123/_history/2333", response.getId());
|
|
|
|
|
|
|
|
|
|
InstantType lm = (InstantType) response.getMeta().getLastUpdatedElement();
|
|
|
|
|
InstantType lm = response.getMeta().getLastUpdatedElement();
|
|
|
|
|
lm.setTimeZoneZulu(true);
|
|
|
|
|
assertEquals("1995-11-15T04:58:08.000Z", lm.getValueAsString());
|
|
|
|
|
|
|
|
|
@ -447,7 +465,7 @@ public class ClientR4Test {
|
|
|
|
|
headers[0] = new BasicHeader(Constants.HEADER_LAST_MODIFIED, "2011-01-02T22:01:02");
|
|
|
|
|
when(myHttpResponse.getAllHeaders()).thenReturn(headers);
|
|
|
|
|
when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_TEXT));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader("Internal Failure"), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader("Internal Failure"), StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
|
|
|
|
try {
|
|
|
|
@ -474,7 +492,7 @@ public class ClientR4Test {
|
|
|
|
|
headers[0] = new BasicHeader(Constants.HEADER_LAST_MODIFIED, "2011-01-02T22:01:02");
|
|
|
|
|
when(myHttpResponse.getAllHeaders()).thenReturn(headers);
|
|
|
|
|
when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
|
|
|
|
try {
|
|
|
|
@ -498,7 +516,7 @@ public class ClientR4Test {
|
|
|
|
|
headers[0] = new BasicHeader(Constants.HEADER_LAST_MODIFIED, "Wed, 15 Nov 1995 04:58:08 GMT");
|
|
|
|
|
when(myHttpResponse.getAllHeaders()).thenReturn(headers);
|
|
|
|
|
when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
|
|
|
|
// Patient response = client.findPatientByMrn(new
|
|
|
|
@ -508,7 +526,7 @@ public class ClientR4Test {
|
|
|
|
|
assertEquals("http://foo/Patient/111", capt.getValue().getURI().toString());
|
|
|
|
|
assertEquals("PRP1660", response.getIdentifier().get(0).getValueElement().getValue());
|
|
|
|
|
|
|
|
|
|
InstantType lm = (InstantType) response.getMeta().getLastUpdatedElement();
|
|
|
|
|
InstantType lm = response.getMeta().getLastUpdatedElement();
|
|
|
|
|
lm.setTimeZoneZulu(true);
|
|
|
|
|
assertEquals("1995-11-15T04:58:08.000Z", lm.getValueAsString());
|
|
|
|
|
|
|
|
|
@ -523,7 +541,7 @@ public class ClientR4Test {
|
|
|
|
|
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", "application/fhir+xml; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
|
|
|
|
// Patient response = client.findPatientByMrn(new
|
|
|
|
@ -544,7 +562,7 @@ public class ClientR4Test {
|
|
|
|
|
|
|
|
|
|
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_XML + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
|
|
|
|
|
|
|
|
|
@ -572,7 +590,7 @@ public class ClientR4Test {
|
|
|
|
|
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_XML + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
|
|
|
|
StringParam str = new StringParam("FOO$BAR");
|
|
|
|
@ -592,7 +610,7 @@ public class ClientR4Test {
|
|
|
|
|
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_XML + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
|
|
|
|
DateRangeParam param = new DateRangeParam();
|
|
|
|
@ -613,7 +631,7 @@ public class ClientR4Test {
|
|
|
|
|
|
|
|
|
|
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_XML + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
// httpResponse = new BasicHttpResponse(statusline, catalog, locale)
|
|
|
|
|
when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
|
|
|
|
@ -635,7 +653,7 @@ public class ClientR4Test {
|
|
|
|
|
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_XML + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
|
|
|
|
Patient response = client.findPatientQuantity(new QuantityParam(ParamPrefixEnum.GREATERTHAN, 123L, "foo", "bar"));
|
|
|
|
@ -654,7 +672,7 @@ public class ClientR4Test {
|
|
|
|
|
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_XML + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
|
|
|
|
Patient response = client.findPatientByMrn(new TokenParam("urn:foo", "123"));
|
|
|
|
@ -673,7 +691,7 @@ public class ClientR4Test {
|
|
|
|
|
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_XML + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
|
|
|
|
client.getPatientNoParams();
|
|
|
|
@ -691,7 +709,7 @@ public class ClientR4Test {
|
|
|
|
|
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_XML + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
|
|
|
|
client.getPatientOneParam(new StringParam("BB"));
|
|
|
|
@ -709,7 +727,7 @@ public class ClientR4Test {
|
|
|
|
|
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_XML + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
|
|
|
|
TokenOrListParam identifiers = new TokenOrListParam();
|
|
|
|
@ -730,7 +748,7 @@ public class ClientR4Test {
|
|
|
|
|
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_XML + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
ITestClientWithCustomType client = ourCtx.newRestfulClient(ITestClientWithCustomType.class, "http://foo");
|
|
|
|
|
CustomPatient response = client.getPatientByDob(new DateParam(ParamPrefixEnum.GREATERTHAN_OR_EQUALS, "2011-01-02"));
|
|
|
|
@ -749,7 +767,7 @@ public class ClientR4Test {
|
|
|
|
|
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_XML + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
ITestClientWithCustomTypeList client = ourCtx.newRestfulClient(ITestClientWithCustomTypeList.class, "http://foo");
|
|
|
|
|
List<CustomPatient> response = client.getPatientByDob(new DateParam(ParamPrefixEnum.GREATERTHAN_OR_EQUALS, "2011-01-02"));
|
|
|
|
@ -771,7 +789,7 @@ public class ClientR4Test {
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenAnswer(new Answer<InputStream>() {
|
|
|
|
|
@Override
|
|
|
|
|
public InputStream answer(InvocationOnMock theInvocation) throws Throwable {
|
|
|
|
|
return new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8"));
|
|
|
|
|
return new ReaderInputStream(new StringReader(msg), StandardCharsets.UTF_8);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -813,7 +831,7 @@ public class ClientR4Test {
|
|
|
|
|
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_XML + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
|
|
|
|
StringAndListParam andListParam = new StringAndListParam();
|
|
|
|
@ -837,7 +855,7 @@ public class ClientR4Test {
|
|
|
|
|
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_XML + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
// TODO: document this
|
|
|
|
|
|
|
|
|
@ -845,13 +863,13 @@ public class ClientR4Test {
|
|
|
|
|
client.getPatientByDob(new DateParam(ParamPrefixEnum.GREATERTHAN_OR_EQUALS, "2011-01-02"));
|
|
|
|
|
assertEquals("http://foo/Patient?birthdate=ge2011-01-02", capt.getAllValues().get(0).getURI().toString());
|
|
|
|
|
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), StandardCharsets.UTF_8));
|
|
|
|
|
client.setEncoding(EncodingEnum.JSON); // this needs to be actually
|
|
|
|
|
// implemented
|
|
|
|
|
client.getPatientByDob(new DateParam(ParamPrefixEnum.GREATERTHAN_OR_EQUALS, "2011-01-02"));
|
|
|
|
|
assertEquals("http://foo/Patient?birthdate=ge2011-01-02&_format=json", capt.getAllValues().get(1).getURI().toString());
|
|
|
|
|
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), StandardCharsets.UTF_8));
|
|
|
|
|
client.setPrettyPrint(true);
|
|
|
|
|
client.getPatientByDob(new DateParam(ParamPrefixEnum.GREATERTHAN_OR_EQUALS, "2011-01-02"));
|
|
|
|
|
assertEquals("http://foo/Patient?birthdate=ge2011-01-02&_format=json&_pretty=true", capt.getAllValues().get(2).getURI().toString());
|
|
|
|
@ -877,7 +895,7 @@ public class ClientR4Test {
|
|
|
|
|
|
|
|
|
|
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_XML + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
// httpResponse = new BasicHttpResponse(statusline, catalog, locale)
|
|
|
|
|
when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
|
|
|
|
@ -900,7 +918,7 @@ public class ClientR4Test {
|
|
|
|
|
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_XML + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
|
|
|
|
client.setSummary(SummaryEnum.DATA);
|
|
|
|
@ -919,10 +937,10 @@ public class ClientR4Test {
|
|
|
|
|
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_XML + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
|
|
|
|
client.getPatientWithIncludes(new StringParam("aaa"), Arrays.asList(new Include[]{new Include("inc1"), new Include("inc2", true), new Include("inc3", true)}));
|
|
|
|
|
client.getPatientWithIncludes(new StringParam("aaa"), Arrays.asList(new Include("inc1"), new Include("inc2", true), new Include("inc3", true)));
|
|
|
|
|
|
|
|
|
|
assertEquals("http://foo/Patient?withIncludes=aaa&_include=inc1&_include%3Aiterate=inc2&_include%3Aiterate=inc3", capt.getValue().getURI().toString());
|
|
|
|
|
|
|
|
|
@ -937,7 +955,7 @@ public class ClientR4Test {
|
|
|
|
|
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_XML + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
|
|
|
|
Bundle response = client.findPatientByName(new StringParam("AAA"), null);
|
|
|
|
@ -950,7 +968,7 @@ public class ClientR4Test {
|
|
|
|
|
* Now with a first name
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), StandardCharsets.UTF_8));
|
|
|
|
|
client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
|
|
|
|
response = client.findPatientByName(new StringParam("AAA"), new StringParam("BBB"));
|
|
|
|
|
|
|
|
|
@ -970,7 +988,7 @@ public class ClientR4Test {
|
|
|
|
|
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_XML + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
ITestClientWithStringIncludes client = ourCtx.newRestfulClient(ITestClientWithStringIncludes.class, "http://foo");
|
|
|
|
|
client.getPatientWithIncludes(new StringParam("aaa"), "inc1");
|
|
|
|
@ -991,7 +1009,7 @@ public class ClientR4Test {
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenAnswer(new Answer<InputStream>() {
|
|
|
|
|
@Override
|
|
|
|
|
public InputStream answer(InvocationOnMock theInvocation) throws Throwable {
|
|
|
|
|
return new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8"));
|
|
|
|
|
return new ReaderInputStream(new StringReader(msg), StandardCharsets.UTF_8);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -1037,7 +1055,7 @@ public class ClientR4Test {
|
|
|
|
|
when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
|
|
|
|
|
when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 201, "OK"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_TEXT + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), StandardCharsets.UTF_8));
|
|
|
|
|
when(myHttpResponse.getAllHeaders()).thenReturn(toHeaderArray("Location", "http://example.com/fhir/Patient/100/_history/200"));
|
|
|
|
|
|
|
|
|
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
|
|
|
@ -1065,7 +1083,7 @@ public class ClientR4Test {
|
|
|
|
|
when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
|
|
|
|
|
when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 201, "OK"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), StandardCharsets.UTF_8));
|
|
|
|
|
when(myHttpResponse.getAllHeaders()).thenReturn(toHeaderArray(Constants.HEADER_LOCATION, "http://example.com/fhir/Patient/100/_history/200"));
|
|
|
|
|
|
|
|
|
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
|
|
|
@ -1088,7 +1106,7 @@ public class ClientR4Test {
|
|
|
|
|
ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
|
|
|
|
|
when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
|
|
|
|
|
when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), StandardCharsets.UTF_8));
|
|
|
|
|
when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), Constants.STATUS_HTTP_409_CONFLICT, "Conflict"));
|
|
|
|
|
|
|
|
|
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
|
|
|
@ -1105,7 +1123,7 @@ public class ClientR4Test {
|
|
|
|
|
when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
|
|
|
|
|
when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 201, "OK"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_TEXT + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), StandardCharsets.UTF_8));
|
|
|
|
|
when(myHttpResponse.getAllHeaders()).thenReturn(toHeaderArray("Location", "http://example.com/fhir/Patient/100/_history/200"));
|
|
|
|
|
|
|
|
|
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
|
|
|
@ -1129,7 +1147,7 @@ public class ClientR4Test {
|
|
|
|
|
when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
|
|
|
|
|
when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), Constants.STATUS_HTTP_204_NO_CONTENT, "OK"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_TEXT + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), StandardCharsets.UTF_8));
|
|
|
|
|
when(myHttpResponse.getAllHeaders()).thenReturn(toHeaderArray("Location", "http://example.com/fhir/Patient/100/_history/200"));
|
|
|
|
|
|
|
|
|
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
|
|
|
@ -1152,7 +1170,7 @@ public class ClientR4Test {
|
|
|
|
|
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_XML + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(response), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(response), StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.ONCE);
|
|
|
|
|
IGenericClient client = ourCtx.newRestfulGenericClient("http://testValidateServerBaseWithInvalidResponse");
|
|
|
|
@ -1180,7 +1198,7 @@ public class ClientR4Test {
|
|
|
|
|
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_NEW + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(resp), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(resp), StandardCharsets.UTF_8));
|
|
|
|
|
when(myHttpResponse.getAllHeaders()).thenReturn(toHeaderArray("Location", "http://example.com/fhir/Patient/100/_history/200"));
|
|
|
|
|
|
|
|
|
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
|
|
|
@ -1215,7 +1233,7 @@ public class ClientR4Test {
|
|
|
|
|
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_XML + "; charset=UTF-8"));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
|
|
|
|
|
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
|
|
ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
|
|
|
|
|
// Patient response = client.findPatientByMrn(new
|
|
|
|
@ -1227,6 +1245,67 @@ public class ClientR4Test {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testClientWithAndOrList() throws IOException {
|
|
|
|
|
|
|
|
|
|
Bundle response = new Bundle().setType(Bundle.BundleType.SEARCHSET);
|
|
|
|
|
|
|
|
|
|
ArgumentCaptor<HttpUriRequest> 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()).thenReturn(new ResourceEntity(ourCtx, response));
|
|
|
|
|
|
|
|
|
|
ITestClientWithAndOr client = ourCtx.newRestfulClient(ITestClientWithAndOr.class, "http://foo");
|
|
|
|
|
StringAndListParam andList = new StringAndListParam();
|
|
|
|
|
StringOrListParam orListA = new StringOrListParam();
|
|
|
|
|
orListA.add(new StringParam("A1"));
|
|
|
|
|
orListA.add(new StringParam("A2"));
|
|
|
|
|
andList.addAnd(orListA);
|
|
|
|
|
StringOrListParam orListB = new StringOrListParam();
|
|
|
|
|
orListB.add(new StringParam("B1"));
|
|
|
|
|
orListB.add(new StringParam("B2"));
|
|
|
|
|
andList.addAnd(orListB);
|
|
|
|
|
client.search(andList);
|
|
|
|
|
|
|
|
|
|
assertEquals("http://foo/Patient?foo=A1%2CA2&foo=B1%2CB2", capt.getValue().getURI().toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testClientWithAndOrList2() throws IOException {
|
|
|
|
|
|
|
|
|
|
Bundle response = new Bundle().setType(Bundle.BundleType.SEARCHSET);
|
|
|
|
|
|
|
|
|
|
ArgumentCaptor<HttpUriRequest> 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()).thenReturn(new ResourceEntity(ourCtx, response));
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
ourCtx.newRestfulClient(ITestClientWithAndOr2.class, "http://foo");
|
|
|
|
|
} catch (ConfigurationException e) {
|
|
|
|
|
assertEquals("Argument #0 of Method 'search' in type 'ca.uhn.fhir.rest.client.ClientR4Test.ITestClientWithAndOr2' is of an invalid generic type (can not be a collection of a collection of a collection)", e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testClientWithAndOrList3() throws IOException {
|
|
|
|
|
|
|
|
|
|
Bundle response = new Bundle().setType(Bundle.BundleType.SEARCHSET);
|
|
|
|
|
|
|
|
|
|
ArgumentCaptor<HttpUriRequest> 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()).thenReturn(new ResourceEntity(ourCtx, response));
|
|
|
|
|
|
|
|
|
|
ITestClientWithAndOr3 client = ourCtx.newRestfulClient(ITestClientWithAndOr3.class, "http://foo");
|
|
|
|
|
Set<Include> orListA = new HashSet<>();
|
|
|
|
|
orListA.add(new Include("a"));
|
|
|
|
|
orListA.add(new Include("b"));
|
|
|
|
|
client.search(orListA);
|
|
|
|
|
|
|
|
|
|
assertEquals("http://foo/Patient?_include=a&_include=b", capt.getValue().getURI().toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Header[] toHeaderArray(String theName, String theValue) {
|
|
|
|
|
return new Header[]{new BasicHeader(theName, theValue)};
|
|
|
|
|
}
|
|
|
|
@ -1245,40 +1324,61 @@ public class ClientR4Test {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface ITestClientWithAndOr extends IBasicClient {
|
|
|
|
|
|
|
|
|
|
@Search()
|
|
|
|
|
List<Patient> search(@OptionalParam(name = "foo") StringAndListParam theParam);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface ITestClientWithAndOr2 extends IBasicClient {
|
|
|
|
|
|
|
|
|
|
@Search()
|
|
|
|
|
List<Patient> search(@OptionalParam(name = "foo") List<List<String>> theParam);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public interface ITestClientWithAndOr3 extends IBasicClient {
|
|
|
|
|
|
|
|
|
|
@Search()
|
|
|
|
|
List<Patient> search(@IncludeParam Set<Include> theParam);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private interface ClientWithoutAnnotation extends IBasicClient {
|
|
|
|
|
Patient read(@IdParam IdType theId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public interface ITestClientWithCustomType extends IBasicClient {
|
|
|
|
|
@Search()
|
|
|
|
|
public CustomPatient getPatientByDob(@RequiredParam(name = Patient.SP_BIRTHDATE) DateParam theBirthDate);
|
|
|
|
|
CustomPatient getPatientByDob(@RequiredParam(name = Patient.SP_BIRTHDATE) DateParam theBirthDate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public interface ITestClientWithCustomTypeList extends IBasicClient {
|
|
|
|
|
@Search()
|
|
|
|
|
public List<CustomPatient> getPatientByDob(@RequiredParam(name = Patient.SP_BIRTHDATE) DateParam theBirthDate);
|
|
|
|
|
List<CustomPatient> getPatientByDob(@RequiredParam(name = Patient.SP_BIRTHDATE) DateParam theBirthDate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public interface ITestClientWithElements extends IBasicClient {
|
|
|
|
|
@Search()
|
|
|
|
|
public List<Patient> getPatientWithIncludes(@Elements Set<String> theElements);
|
|
|
|
|
List<Patient> getPatientWithIncludes(@Elements Set<String> theElements);
|
|
|
|
|
|
|
|
|
|
@Search()
|
|
|
|
|
public List<Patient> getPatientWithIncludes(@Elements String theElements);
|
|
|
|
|
List<Patient> getPatientWithIncludes(@Elements String theElements);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public interface ITestClientWithStringIncludes extends IBasicClient {
|
|
|
|
|
@Search()
|
|
|
|
|
public Patient getPatientWithIncludes(@RequiredParam(name = "withIncludes") StringParam theString, @IncludeParam String theInclude);
|
|
|
|
|
Patient getPatientWithIncludes(@RequiredParam(name = "withIncludes") StringParam theString, @IncludeParam String theInclude);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public interface ITestClientWithSummary extends IBasicClient {
|
|
|
|
|
@Search()
|
|
|
|
|
public List<Patient> getPatientWithIncludes(List<SummaryEnum> theSummary);
|
|
|
|
|
List<Patient> getPatientWithIncludes(List<SummaryEnum> theSummary);
|
|
|
|
|
|
|
|
|
|
@Search()
|
|
|
|
|
public List<Patient> getPatientWithIncludes(SummaryEnum theSummary);
|
|
|
|
|
List<Patient> getPatientWithIncludes(SummaryEnum theSummary);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|