Deprecate a bad setter on RetfulServer, fix a paging issue, and add a

disabled unit test to the subscription matcher
This commit is contained in:
James Agnew 2019-01-21 14:46:17 -05:00
parent 17f03ac843
commit 9cf64f78d0
7 changed files with 73 additions and 4 deletions

View File

@ -198,6 +198,34 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
}
@Test
public void testSearchFetchPageBeyondEnd() {
for (int i = 0; i < 10; i++) {
Organization o = new Organization();
o.setId("O" + i);
o.setName("O" + i);
IIdType oid = ourClient.update().resource(o).execute().getId().toUnqualifiedVersionless();
}
Bundle output = ourClient
.search()
.forResource("Organization")
.count(3)
.returnBundle(Bundle.class)
.execute();
String nextPageUrl = output.getLink("next").getUrl();
String url = nextPageUrl.replace("_getpagesoffset=3", "_getpagesoffset=999");
ourLog.info("Going to request URL: {}", url);
output = ourClient
.loadPage()
.byUrl(url)
.andReturnBundle(Bundle.class)
.execute();
assertEquals(0, output.getEntry().size());
}
@Test
public void testDeleteConditional() {

View File

@ -7,6 +7,7 @@ import org.hl7.fhir.dstu3.model.*;
import org.hl7.fhir.dstu3.model.codesystems.MedicationRequestCategory;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
@ -37,6 +38,25 @@ public class InMemorySubscriptionMatcherTestR3 extends BaseSubscriptionDstu3Test
assertFalse(result.matched());
}
@Test
@Ignore
public void testResourceById() {
ProcedureRequest pr = new ProcedureRequest();
pr.setId("ProcedureRequest/123");
pr.setIntent(ProcedureRequest.ProcedureRequestIntent.ORIGINALORDER);
assertMatched(pr, "ProcedureRequest?_id=123");
assertMatched(pr, "ProcedureRequest?_id=Patient/123");
assertMatched(pr, "ProcedureRequest?_id=Patient/123,Patient/999");
assertMatched(pr, "ProcedureRequest?_id=Patient/123&_id=Patient/123");
assertNotMatched(pr, "ProcedureRequest?_id=Patient/888");
assertNotMatched(pr, "ProcedureRequest?_id=Patient/888,Patient/999");
assertNotMatched(pr, "ProcedureRequest?_id=Patient/123&_id=Patient/888");
}
/*
The following tests are copied from an e-mail from a site using HAPI FHIR
*/

View File

@ -599,7 +599,9 @@ public class RestfulServer extends HttpServlet implements IRestfulServer<Servlet
* Sets the non-resource specific providers which implement method calls on this server.
*
* @see #setResourceProviders(Collection)
* @deprecated This method causes inconsistent behaviour depending on the order it is called in. Use {@link #registerProviders(Object...)} instead.
*/
@Deprecated
public void setPlainProviders(Object... theProv) {
setPlainProviders(Arrays.asList(theProv));
}
@ -608,7 +610,9 @@ public class RestfulServer extends HttpServlet implements IRestfulServer<Servlet
* Sets the non-resource specific providers which implement method calls on this server.
*
* @see #setResourceProviders(Collection)
* @deprecated This method causes inconsistent behaviour depending on the order it is called in. Use {@link #registerProviders(Object...)} instead.
*/
@Deprecated
public void setPlainProviders(Collection<Object> theProviders) {
Validate.noNullElements(theProviders, "theProviders must not contain any null elements");
@ -1359,6 +1363,16 @@ public class RestfulServer extends HttpServlet implements IRestfulServer<Servlet
}
}
/**
* Register a group of providers. These could be Resource Providers (classes implementing {@link IResourceProvider}) or "plain" providers, or a mixture of the two.
*
* @param theProviders a {@code Collection} of theProviders. The parameter could be null or an empty {@code Collection}
*/
public void registerProviders(Object... theProviders) {
Validate.noNullElements(theProviders);
registerProviders(Arrays.asList(theProviders));
}
/**
* Register a group of theProviders. These could be Resource Providers, "plain" theProviders or a mixture of the two.
*

View File

@ -118,7 +118,7 @@ public class PageMethodBinding extends BaseResourceReturningMethodBinding {
Integer totalNum = resultList.size();
start = offsetI;
if (totalNum != null) {
start = Math.min(start, totalNum - 1);
start = Math.min(start, totalNum);
}
}

View File

@ -28,6 +28,7 @@ import org.junit.Test;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
@ -64,7 +65,7 @@ public class GraphQLR4RawTest {
servlet.setDefaultResponseEncoding(EncodingEnum.JSON);
servlet.setPagingProvider(new FifoMemoryPagingProvider(10));
servlet.registerProvider(new MyGraphQLProvider());
servlet.registerProviders(Collections.singletonList(new MyGraphQLProvider()));
servlet.registerProvider(new MyPatientResourceProvider());
ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");

View File

@ -187,8 +187,7 @@ public class HistoryR4Test {
ServletHandler proxyHandler = new ServletHandler();
RestfulServer servlet = new RestfulServer(ourCtx);
servlet.setPlainProviders(plainProvider);
servlet.setResourceProviders(patientProvider);
servlet.registerProviders(plainProvider, patientProvider);
ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
ourServer.setHandler(proxyHandler);

View File

@ -313,6 +313,13 @@
HAPI FHIR will now log the Git revision when it first starts up (on the ame line as the version number
that it already logs).
</action>
<action type="fix">
When fetching a page of search results, if a page offset beyond the total number
of available result was requested, a single result was still returned (e.g.
requesting a page beginning at index 1000 when there are only 10 results would
result in the 10th result being returned). This will now result in an empty
response Bundle as would be expected.
</action>
</release>
<release version="3.6.0" date="2018-11-12" description="Food">
<action type="add">