3986: Remove validation of max parameter lastn and add tests (#5737)
* 3986: Remove validation of max parameter lastn and add tests * 3986: Add bug fix to changelog * 3986: Re-add removed import * Prepare for merge * Spotless --------- Co-authored-by: James Agnew <jamesagnew@gmail.com>
This commit is contained in:
parent
a91490f1ef
commit
22d7731d41
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
type: fix
|
||||
issue: 3986
|
||||
title: "Removed the validation error of the `max` query parameter on the $lastn operation. Now, the $lastn operation can be invoked with the `max` query parameter. Contribution by Gijs Groenewegen (@thetrueoneshots)."
|
|
@ -84,6 +84,13 @@ public abstract class BaseJpaResourceProviderObservation<T extends IBaseResource
|
|||
}
|
||||
if (theMax != null) {
|
||||
paramMap.setLastNMax(theMax.getValue());
|
||||
|
||||
/**
|
||||
* The removal of the original raw parameter is required as every implementing class
|
||||
* has the "Observation" resource class defined. For this resource, the max parameter
|
||||
* is not supported and thus has to be removed before the use of "translateRawParameters".
|
||||
*/
|
||||
theAdditionalRawParams.remove("max");
|
||||
}
|
||||
if (theCount != null) {
|
||||
paramMap.setCount(theCount.getValue());
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package ca.uhn.fhir.jpa.provider.dstu3;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import java.io.IOException;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
|
||||
public class ObservationLastnDstu3Test extends BaseResourceProviderDstu3Test {
|
||||
|
||||
/**
|
||||
* See #3986. Verifies that supplying the max parameter in the $lastn does not cause a validation error.
|
||||
*/
|
||||
@Test
|
||||
public void testSupplyingMaxToTheLastNOPerationDoesNotCauseAValidationError() throws Exception {
|
||||
String outcome = executeApiCall(myServerBase + "/Observation/$lastn?max=1");
|
||||
assertThat(outcome, not(containsString("HAPI-524")));
|
||||
}
|
||||
|
||||
private String executeApiCall(String theUrl) throws IOException {
|
||||
String outcome;
|
||||
HttpGet get = new HttpGet(theUrl);
|
||||
CloseableHttpResponse resp = ourHttpClient.execute(get);
|
||||
try {
|
||||
outcome = IOUtils.toString(resp.getEntity().getContent(), Charsets.UTF_8);
|
||||
} finally {
|
||||
IOUtils.closeQuietly(resp);
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue