diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperationUntyped.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperationUntyped.java index dff17e286e1..40155444efc 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperationUntyped.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperationUntyped.java @@ -34,7 +34,7 @@ public interface IOperationUntyped { * @param theParameters The parameters to use as input. May also be null if the operation * does not require any input parameters. */ - IOperationUntypedWithInput withParameters(T theParameters); + IOperationUntypedWithInputAndPartialOutput withParameters(T theParameters); /** * The operation does not require any input parameters diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperationUntypedWithInputAndPartialOutput.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperationUntypedWithInputAndPartialOutput.java index ace3562a8c9..71594f48c47 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperationUntypedWithInputAndPartialOutput.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperationUntypedWithInputAndPartialOutput.java @@ -38,6 +38,8 @@ public interface IOperationUntypedWithInputAndPartialOutput andParameter(String theName, IBase theValue); /** + * Adds a URL parameter to the request. + * * Use chained method calls to construct a Parameters input. This form is a convenience * in order to allow simple method chaining to be used to build up a parameters * resource for the input of an operation without needing to manually construct one. diff --git a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/GenericClient.java b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/GenericClient.java index 991e87f6907..b9705fc3534 100644 --- a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/GenericClient.java +++ b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/GenericClient.java @@ -1276,7 +1276,7 @@ public class GenericClient extends BaseClient implements IGenericClient { @SuppressWarnings("unchecked") @Override - public IOperationUntypedWithInput withNoParameters(Class theOutputParameterType) { + public IOperationUntypedWithInputAndPartialOutput withNoParameters(Class theOutputParameterType) { Validate.notNull(theOutputParameterType, "theOutputParameterType may not be null"); RuntimeResourceDefinition def = myContext.getResourceDefinition(theOutputParameterType); if (def == null) { @@ -1307,9 +1307,10 @@ public class GenericClient extends BaseClient implements IGenericClient { @SuppressWarnings({"unchecked"}) @Override - public IOperationUntypedWithInput withParameters(IBaseParameters theParameters) { + public IOperationUntypedWithInputAndPartialOutput withParameters(IBaseParameters theParameters) { Validate.notNull(theParameters, "theParameters can not be null"); myParameters = theParameters; + myParametersDef = myContext.getResourceDefinition(theParameters.getClass()); return this; } @@ -1445,7 +1446,7 @@ public class GenericClient extends BaseClient implements IGenericClient { OutcomeResponseHandler binding = new OutcomeResponseHandler(myPrefer); - Map> params = new HashMap>(); + Map> params = new HashMap<>(); return invoke(params, binding, invocation); } diff --git a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/client/OperationClientR4Test.java b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/client/OperationClientR4Test.java index b485105735b..6f658fe5ec6 100644 --- a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/client/OperationClientR4Test.java +++ b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/rest/client/OperationClientR4Test.java @@ -123,6 +123,24 @@ public class OperationClientR4Test { assertEquals("http://foo/$nonrepeating?valstr=str&valtok=sys2%7Cval2", value.getURI().toASCIIString()); } + @Test + public void testNonRepeatingGenericUsingUrl2() { + ourGenClient + .operation() + .onServer() + .named("nonrepeating") + .withParameters(new Parameters()) + .andSearchParameter("valstr", new StringParam("str")) + .andSearchParameter("valtok", new TokenParam("sys2", "val2")) + .useHttpGet() + .execute(); + Parameters response = ourAnnClient.nonrepeating(new StringParam("str"), new TokenParam("sys", "val")); + assertEquals("FOO", response.getParameter().get(0).getName()); + + HttpGet value = (HttpGet) capt.getAllValues().get(0); + assertEquals("http://foo/$nonrepeating?valstr=str&valtok=sys2%7Cval2", value.getURI().toASCIIString()); + } + @Test public void testOperationOnInstanceWithIncompleteInstanceId() { try {