cleanup
This commit is contained in:
parent
478d7a1257
commit
ab8b1ca277
|
@ -334,7 +334,7 @@ public class SearchTask implements Callable<Void> {
|
||||||
|
|
||||||
if (theResultIter.hasNext() == false) {
|
if (theResultIter.hasNext() == false) {
|
||||||
int skippedCount = theResultIter.getSkippedCount();
|
int skippedCount = theResultIter.getSkippedCount();
|
||||||
ourLog.info(
|
ourLog.trace(
|
||||||
"MaxToFetch[{}] SkippedCount[{}] CountSavedThisPass[{}] CountSavedThisTotal[{}] AdditionalPrefetchRemaining[{}]",
|
"MaxToFetch[{}] SkippedCount[{}] CountSavedThisPass[{}] CountSavedThisTotal[{}] AdditionalPrefetchRemaining[{}]",
|
||||||
myMaxResultsToFetch,
|
myMaxResultsToFetch,
|
||||||
skippedCount,
|
skippedCount,
|
||||||
|
|
|
@ -30,7 +30,6 @@ import java.util.Set;
|
||||||
import static org.hl7.fhir.instance.model.api.IBaseBundle.LINK_NEXT;
|
import static org.hl7.fhir.instance.model.api.IBaseBundle.LINK_NEXT;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
@SuppressWarnings("Duplicates")
|
@SuppressWarnings("Duplicates")
|
||||||
|
@ -101,59 +100,64 @@ public class PatientEverythingPaginationR4Test extends BaseResourceProviderR4Tes
|
||||||
@ValueSource(booleans = { true, false })
|
@ValueSource(booleans = { true, false })
|
||||||
public void testEverythingPagination_LastPage(boolean theProvideCountBool) throws IOException {
|
public void testEverythingPagination_LastPage(boolean theProvideCountBool) throws IOException {
|
||||||
// setup
|
// setup
|
||||||
List<Integer> prefetchThreshold = Arrays.asList(10, 50,-1);
|
List<Integer> previousPrefetchThreshold = myStorageSettings.getSearchPreFetchThresholds();
|
||||||
myStorageSettings.setSearchPreFetchThresholds(prefetchThreshold);
|
try {
|
||||||
|
List<Integer> prefetchThreshold = Arrays.asList(10, 50, -1);
|
||||||
|
myStorageSettings.setSearchPreFetchThresholds(prefetchThreshold);
|
||||||
|
|
||||||
// 3 pages @ 50
|
// 3 pages @ 50
|
||||||
int total = 154;
|
int total = 154;
|
||||||
createPatients(total);
|
createPatients(total);
|
||||||
Set<String> ids = new HashSet<>();
|
Set<String> ids = new HashSet<>();
|
||||||
|
|
||||||
String url = myServerBase + "/Patient/$everything?_format=json";
|
String url = myServerBase + "/Patient/$everything?_format=json";
|
||||||
if (theProvideCountBool) {
|
if (theProvideCountBool) {
|
||||||
url += "&_count=" + BasePagingProvider.DEFAULT_MAX_PAGE_SIZE;
|
url += "&_count=" + BasePagingProvider.DEFAULT_MAX_PAGE_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
String nextUrl;
|
String nextUrl;
|
||||||
|
|
||||||
// test
|
// test
|
||||||
Bundle bundle = fetchBundle(url);
|
Bundle bundle = fetchBundle(url);
|
||||||
|
|
||||||
// first page
|
// first page
|
||||||
List<Patient> patientsPage = BundleUtil.toListOfResourcesOfType(myFhirContext, bundle, Patient.class);
|
List<Patient> patientsPage = BundleUtil.toListOfResourcesOfType(myFhirContext, bundle, Patient.class);
|
||||||
if (theProvideCountBool) {
|
if (theProvideCountBool) {
|
||||||
assertEquals(50, patientsPage.size());
|
assertEquals(50, patientsPage.size());
|
||||||
} else {
|
} else {
|
||||||
assertEquals(10, patientsPage.size());
|
assertEquals(10, patientsPage.size());
|
||||||
}
|
}
|
||||||
for (Patient p : patientsPage) {
|
|
||||||
assertTrue(ids.add(p.getId()));
|
|
||||||
}
|
|
||||||
nextUrl = BundleUtil.getLinkUrlOfType(myFhirContext, bundle, LINK_NEXT);
|
|
||||||
assertNotNull(nextUrl);
|
|
||||||
|
|
||||||
// all future pages
|
|
||||||
do {
|
|
||||||
bundle = fetchBundle(nextUrl);
|
|
||||||
assertNotNull(bundle);
|
|
||||||
patientsPage = BundleUtil.toListOfResourcesOfType(myFhirContext, bundle, Patient.class);
|
|
||||||
for (Patient p : patientsPage) {
|
for (Patient p : patientsPage) {
|
||||||
assertTrue(ids.add(p.getId()));
|
assertTrue(ids.add(p.getId()));
|
||||||
}
|
}
|
||||||
nextUrl = BundleUtil.getLinkUrlOfType(myFhirContext, bundle, LINK_NEXT);
|
nextUrl = BundleUtil.getLinkUrlOfType(myFhirContext, bundle, LINK_NEXT);
|
||||||
if (nextUrl != null) {
|
assertNotNull(nextUrl);
|
||||||
if (theProvideCountBool) {
|
|
||||||
assertEquals(50, patientsPage.size());
|
|
||||||
} else {
|
|
||||||
assertEquals(10, patientsPage.size());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
assertEquals(4, patientsPage.size());
|
|
||||||
}
|
|
||||||
} while (nextUrl != null);
|
|
||||||
assertNull(nextUrl);
|
|
||||||
|
|
||||||
assertEquals(total, ids.size());
|
// all future pages
|
||||||
|
do {
|
||||||
|
bundle = fetchBundle(nextUrl);
|
||||||
|
assertNotNull(bundle);
|
||||||
|
patientsPage = BundleUtil.toListOfResourcesOfType(myFhirContext, bundle, Patient.class);
|
||||||
|
for (Patient p : patientsPage) {
|
||||||
|
assertTrue(ids.add(p.getId()));
|
||||||
|
}
|
||||||
|
nextUrl = BundleUtil.getLinkUrlOfType(myFhirContext, bundle, LINK_NEXT);
|
||||||
|
if (nextUrl != null) {
|
||||||
|
if (theProvideCountBool) {
|
||||||
|
assertEquals(50, patientsPage.size());
|
||||||
|
} else {
|
||||||
|
assertEquals(10, patientsPage.size());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
assertEquals(4, patientsPage.size());
|
||||||
|
}
|
||||||
|
} while (nextUrl != null);
|
||||||
|
|
||||||
|
assertEquals(total, ids.size());
|
||||||
|
} finally {
|
||||||
|
// set it back, just in case
|
||||||
|
myStorageSettings.setSearchPreFetchThresholds(previousPrefetchThreshold);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue