From 6eb8d3e236fb116cb10c389f69d21e2e415b46d3 Mon Sep 17 00:00:00 2001 From: leif stawnyczy Date: Fri, 9 Aug 2024 14:12:44 -0400 Subject: [PATCH] fixing tests --- .../java/ca/uhn/fhir/rest/client/api/IHttpClient.java | 6 ++++-- .../ca/uhn/fhir/okhttp/client/OkHttpRestfulClient.java | 4 +++- .../ca/uhn/fhir/rest/client/apache/BaseHttpClient.java | 8 +++++--- .../fhir/rest/client/impl/BaseHttpClientInvocation.java | 2 +- .../method/BaseHttpClientInvocationWithContents.java | 2 +- .../java/ca/uhn/fhir/jaxrs/client/JaxRsHttpClient.java | 4 +++- 6 files changed, 17 insertions(+), 9 deletions(-) diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/api/IHttpClient.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/api/IHttpClient.java index 371bf5d31fb..0e158b43e05 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/api/IHttpClient.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/api/IHttpClient.java @@ -73,7 +73,9 @@ public interface IHttpClient { void addHeadersToRequest(IHttpRequest theRequest, EncodingEnum theEncodingEnum, FhirContext theContext); /** - * Updates the client's url; + * Updates the client's url, as well as the conditional create/update strings/params + * (ie, the "if None Exists" stuff) + * * This is used when we reuse a client for multiple different requests * (ex, searches, or fetching the /metadata endpoint followed by whatever * the actual endpoint is, etc). @@ -81,5 +83,5 @@ public interface IHttpClient { * Deprecated / Legacy clients do not use this (they create new clients for * every request) */ - void setNewUrl(StringBuilder theUrl); + void setNewUrl(StringBuilder theUrl, String theIfNoneExistsString, Map> theIfNoneExistsParams); } diff --git a/hapi-fhir-client-okhttp/src/main/java/ca/uhn/fhir/okhttp/client/OkHttpRestfulClient.java b/hapi-fhir-client-okhttp/src/main/java/ca/uhn/fhir/okhttp/client/OkHttpRestfulClient.java index 78b69d709c9..57e1c823562 100644 --- a/hapi-fhir-client-okhttp/src/main/java/ca/uhn/fhir/okhttp/client/OkHttpRestfulClient.java +++ b/hapi-fhir-client-okhttp/src/main/java/ca/uhn/fhir/okhttp/client/OkHttpRestfulClient.java @@ -143,8 +143,10 @@ public class OkHttpRestfulClient implements IHttpClient { } @Override - public void setNewUrl(StringBuilder theUrl) { + public void setNewUrl(StringBuilder theUrl, String theIfNoneExistString, Map> theIfNoneExistParams) { myUrl = theUrl; + myIfNoneExistString = theIfNoneExistString; + myIfNoneExistParams = theIfNoneExistParams; } private void addHeadersToRequest( diff --git a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/apache/BaseHttpClient.java b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/apache/BaseHttpClient.java index 8605a463599..dfaf13aeed0 100644 --- a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/apache/BaseHttpClient.java +++ b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/apache/BaseHttpClient.java @@ -38,8 +38,8 @@ import java.util.Map; public abstract class BaseHttpClient implements IHttpClient { private final List
myHeaders; - private final Map> myIfNoneExistParams; - private final String myIfNoneExistString; + private Map> myIfNoneExistParams; + private String myIfNoneExistString; protected RequestTypeEnum myRequestType; protected StringBuilder myUrl; @@ -60,8 +60,10 @@ public abstract class BaseHttpClient implements IHttpClient { } @Override - public void setNewUrl(StringBuilder theUrl) { + public void setNewUrl(StringBuilder theUrl, String theIfNoneExistString, Map> theIfNoneExistParams) { myUrl = theUrl; + myIfNoneExistString = theIfNoneExistString; + myIfNoneExistParams = theIfNoneExistParams; } private void addHeaderIfNoneExist(IHttpRequest result) { diff --git a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/BaseHttpClientInvocation.java b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/BaseHttpClientInvocation.java index 8d787e5bf93..42fd870e3d1 100644 --- a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/BaseHttpClientInvocation.java +++ b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/BaseHttpClientInvocation.java @@ -99,7 +99,7 @@ public abstract class BaseHttpClientInvocation { if (theParameters.getClient() != null) { // reuse existing client httpClient = theParameters.getClient(); - httpClient.setNewUrl(new StringBuilder(theParameters.getUrl())); + httpClient.setNewUrl(new StringBuilder(theParameters.getUrl()), null, null); } else { // make a new client httpClient = getRestfulClientFactory() diff --git a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/BaseHttpClientInvocationWithContents.java b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/BaseHttpClientInvocationWithContents.java index 62c024f28af..98a1ec0c2e8 100644 --- a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/BaseHttpClientInvocationWithContents.java +++ b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/BaseHttpClientInvocationWithContents.java @@ -145,7 +145,7 @@ abstract class BaseHttpClientInvocationWithContents extends BaseHttpClientInvoca httpClient = theParams.getClient(); // update the url to the one we want (in case the // previous client did not have the correct one - httpClient.setNewUrl(url); + httpClient.setNewUrl(url, myIfNoneExistString, myIfNoneExistParams); } else { // make a new one httpClient = getRestfulClientFactory() diff --git a/hapi-fhir-jaxrsserver-base/src/main/java/ca/uhn/fhir/jaxrs/client/JaxRsHttpClient.java b/hapi-fhir-jaxrsserver-base/src/main/java/ca/uhn/fhir/jaxrs/client/JaxRsHttpClient.java index 83fcc7498fb..5684f34b1f7 100644 --- a/hapi-fhir-jaxrsserver-base/src/main/java/ca/uhn/fhir/jaxrs/client/JaxRsHttpClient.java +++ b/hapi-fhir-jaxrsserver-base/src/main/java/ca/uhn/fhir/jaxrs/client/JaxRsHttpClient.java @@ -166,8 +166,10 @@ public class JaxRsHttpClient implements IHttpClient { } @Override - public void setNewUrl(StringBuilder theUrl) { + public void setNewUrl(StringBuilder theUrl, String theIfNoneExistString, Map> theIfNoneExistParams) { myUrl = theUrl; + myIfNoneExistString = theIfNoneExistString; + myIfNoneExistParams = theIfNoneExistParams; } public void addHeadersToRequest(JaxRsHttpRequest theHttpRequest, EncodingEnum theEncoding, FhirContext theContext) {