One more test fix
This commit is contained in:
parent
796b12e33e
commit
6dc2dc1d6f
|
@ -153,7 +153,7 @@ public class DaoConfig {
|
|||
private int myReindexThreadCount;
|
||||
private Set<String> myBundleTypesAllowedForStorage;
|
||||
private boolean myValidateSearchParameterExpressionsOnSave = true;
|
||||
private List<Integer> myPreFetchThresholds = Arrays.asList(500, 2000, -1);
|
||||
private List<Integer> mySearchPreFetchThresholds = Arrays.asList(500, 2000, -1);
|
||||
private List<WarmCacheEntry> myWarmCacheEntries = new ArrayList<>();
|
||||
|
||||
/**
|
||||
|
@ -1363,7 +1363,7 @@ public class DaoConfig {
|
|||
Validate.isTrue(last != -1, "Prefetch thresholds must be sequential");
|
||||
last = nextInt;
|
||||
}
|
||||
myPreFetchThresholds = thePreFetchThresholds;
|
||||
mySearchPreFetchThresholds = thePreFetchThresholds;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1379,8 +1379,8 @@ public class DaoConfig {
|
|||
* given number.
|
||||
* </p>
|
||||
*/
|
||||
public List<Integer> getPreFetchThresholds() {
|
||||
return myPreFetchThresholds;
|
||||
public List<Integer> getSearchPreFetchThresholds() {
|
||||
return mySearchPreFetchThresholds;
|
||||
}
|
||||
|
||||
public enum IndexEnabledEnum {
|
||||
|
|
|
@ -54,13 +54,10 @@ import org.springframework.transaction.TransactionStatus;
|
|||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.support.TransactionCallbackWithoutResult;
|
||||
import org.springframework.transaction.support.TransactionSynchronization;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.transaction.TransactionManager;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
|
@ -736,7 +733,7 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc {
|
|||
/*
|
||||
* Figure out how many results we're actually going to fetch from the
|
||||
* database in this pass. This calculation takes into consideration the
|
||||
* "pre-fetch thresholds" specified in DaoConfig#getPreFetchThresholds()
|
||||
* "pre-fetch thresholds" specified in DaoConfig#getSearchPreFetchThresholds()
|
||||
* as well as the value of the _count parameter.
|
||||
*/
|
||||
int currentlyLoaded = defaultIfNull(mySearch.getNumFound(), 0);
|
||||
|
@ -747,7 +744,7 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc {
|
|||
minWanted += currentlyLoaded;
|
||||
}
|
||||
|
||||
for (Iterator<Integer> iter = myDaoConfig.getPreFetchThresholds().iterator(); iter.hasNext(); ) {
|
||||
for (Iterator<Integer> iter = myDaoConfig.getSearchPreFetchThresholds().iterator(); iter.hasNext(); ) {
|
||||
int next = iter.next();
|
||||
if (next != -1 && next <= currentlyLoaded) {
|
||||
continue;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package ca.uhn.fhir.jpa.dao.r4;
|
||||
|
||||
import ca.uhn.fhir.jpa.dao.DaoConfig;
|
||||
import ca.uhn.fhir.jpa.dao.SearchParameterMap;
|
||||
import ca.uhn.fhir.jpa.entity.Search;
|
||||
import ca.uhn.fhir.jpa.entity.SearchStatusEnum;
|
||||
|
@ -45,6 +46,7 @@ public class FhirResourceDaoR4SearchOptimizedTest extends BaseJpaR4Test {
|
|||
public final void after() {
|
||||
mySearchCoordinatorSvcImpl.setLoadingThrottleForUnitTests(null);
|
||||
mySearchCoordinatorSvcImpl.setSyncSizeForUnitTests(SearchCoordinatorSvcImpl.DEFAULT_SYNC_SIZE);
|
||||
myDaoConfig.setSearchPreFetchThresholds(new DaoConfig().getSearchPreFetchThresholds());
|
||||
}
|
||||
|
||||
@Before
|
||||
|
|
|
@ -47,6 +47,7 @@ public class PatientEverythingR4Test extends BaseResourceProviderR4Test {
|
|||
|
||||
myDaoConfig.setReuseCachedSearchResultsForMillis(new DaoConfig().getReuseCachedSearchResultsForMillis());
|
||||
myDaoConfig.setEverythingIncludesFetchPageSize(new DaoConfig().getEverythingIncludesFetchPageSize());
|
||||
myDaoConfig.setSearchPreFetchThresholds(new DaoConfig().getSearchPreFetchThresholds());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -58,10 +58,7 @@ import org.apache.http.entity.ContentType;
|
|||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hl7.fhir.instance.model.api.IBaseBundle;
|
||||
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.instance.model.api.*;
|
||||
import org.hl7.fhir.r4.hapi.validation.FhirInstanceValidator;
|
||||
import org.hl7.fhir.r4.model.*;
|
||||
import org.hl7.fhir.r4.model.Bundle.BundleEntryComponent;
|
||||
|
@ -142,6 +139,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
myDaoConfig.setAllowExternalReferences(new DaoConfig().isAllowExternalReferences());
|
||||
myDaoConfig.setReuseCachedSearchResultsForMillis(new DaoConfig().getReuseCachedSearchResultsForMillis());
|
||||
myDaoConfig.setCountSearchResultsUpTo(new DaoConfig().getCountSearchResultsUpTo());
|
||||
myDaoConfig.setSearchPreFetchThresholds(new DaoConfig().getSearchPreFetchThresholds());
|
||||
|
||||
mySearchCoordinatorSvcRaw.setLoadingThrottleForUnitTests(null);
|
||||
mySearchCoordinatorSvcRaw.setSyncSizeForUnitTests(SearchCoordinatorSvcImpl.DEFAULT_SYNC_SIZE);
|
||||
|
@ -158,7 +156,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
|
||||
myDaoConfig.setAllowMultipleDelete(true);
|
||||
ourClient.registerInterceptor(myCapturingInterceptor);
|
||||
myDaoConfig.setSearchPreFetchThresholds(new DaoConfig().getPreFetchThresholds());
|
||||
myDaoConfig.setSearchPreFetchThresholds(new DaoConfig().getSearchPreFetchThresholds());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -466,7 +464,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
theRequest.addHeader(Constants.HEADER_PREFER, Constants.HEADER_PREFER_RETURN + "=" + Constants.HEADER_PREFER_RETURN_OPERATION_OUTCOME);
|
||||
}
|
||||
@Override
|
||||
public void interceptResponse(IHttpResponse theResponse) throws IOException { // TODO Auto-generated method stu
|
||||
public void interceptResponse(IHttpResponse theResponse) { // TODO Auto-generated method stu
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -965,9 +963,9 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
sock.setSoTimeout(3000);
|
||||
try {
|
||||
sock.connect(new InetSocketAddress("localhost", ourPort));
|
||||
sock.getOutputStream().write(("DELETE /fhir/context/Patient?identifier=http://ghh.org/patient|" + methodName + " HTTP/1.1\n").getBytes("UTF-8"));
|
||||
sock.getOutputStream().write("Host: localhost\n".getBytes("UTF-8"));
|
||||
sock.getOutputStream().write("\n".getBytes("UTF-8"));
|
||||
sock.getOutputStream().write(("DELETE /fhir/context/Patient?identifier=http://ghh.org/patient|" + methodName + " HTTP/1.1\n").getBytes(StandardCharsets.UTF_8));
|
||||
sock.getOutputStream().write("Host: localhost\n".getBytes(StandardCharsets.UTF_8));
|
||||
sock.getOutputStream().write("\n".getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
BufferedReader socketInput = new BufferedReader(new InputStreamReader(sock.getInputStream()));
|
||||
|
||||
|
@ -2736,14 +2734,11 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
@Test
|
||||
public void testSearchBundleDoesntIncludeTextElement() throws Exception {
|
||||
HttpGet read = new HttpGet(ourServerBase + "/Patient?_format=json");
|
||||
CloseableHttpResponse response = ourHttpClient.execute(read);
|
||||
try {
|
||||
try (CloseableHttpResponse response = ourHttpClient.execute(read)) {
|
||||
String text = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||
ourLog.info(text);
|
||||
assertEquals(Constants.STATUS_HTTP_200_OK, response.getStatusLine().getStatusCode());
|
||||
assertThat(text, not(containsString("\"text\",\"type\"")));
|
||||
} finally {
|
||||
response.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2773,7 +2768,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
assertEquals("Jernelöv", p.getName().get(0).getFamily());
|
||||
|
||||
} finally {
|
||||
IOUtils.closeQuietly(resp.getEntity().getContent());
|
||||
resp.getEntity().getContent().close();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2798,7 +2793,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
found = ourClient
|
||||
.search()
|
||||
.forResource(Patient.class)
|
||||
.where(BaseResource.RES_ID.exactly().systemAndValues(null, id1.getIdPart(), id2.getIdPart()))
|
||||
.where(IAnyResource.RES_ID.exactly().systemAndValues(null, id1.getIdPart(), id2.getIdPart()))
|
||||
.returnBundle(Bundle.class)
|
||||
.execute();
|
||||
|
||||
|
@ -2807,7 +2802,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
found = ourClient
|
||||
.search()
|
||||
.forResource(Patient.class)
|
||||
.where(BaseResource.RES_ID.exactly().systemAndValues(null, Arrays.asList(id1.getIdPart(), id2.getIdPart(), "FOOOOO")))
|
||||
.where(IAnyResource.RES_ID.exactly().systemAndValues(null, Arrays.asList(id1.getIdPart(), id2.getIdPart(), "FOOOOO")))
|
||||
.returnBundle(Bundle.class)
|
||||
.execute();
|
||||
|
||||
|
@ -2816,7 +2811,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
found = ourClient
|
||||
.search()
|
||||
.forResource(Patient.class)
|
||||
.where(BaseResource.RES_ID.exactly().systemAndCode(null, id1.getIdPart()))
|
||||
.where(IAnyResource.RES_ID.exactly().systemAndCode(null, id1.getIdPart()))
|
||||
.returnBundle(Bundle.class)
|
||||
.execute();
|
||||
|
||||
|
@ -2825,8 +2820,8 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
found = ourClient
|
||||
.search()
|
||||
.forResource(Patient.class)
|
||||
.where(BaseResource.RES_ID.exactly().codes(id1.getIdPart(), id2.getIdPart()))
|
||||
.and(BaseResource.RES_ID.exactly().code(id1.getIdPart()))
|
||||
.where(IAnyResource.RES_ID.exactly().codes(id1.getIdPart(), id2.getIdPart()))
|
||||
.and(IAnyResource.RES_ID.exactly().code(id1.getIdPart()))
|
||||
.returnBundle(Bundle.class)
|
||||
.execute();
|
||||
|
||||
|
@ -2835,8 +2830,8 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
found = ourClient
|
||||
.search()
|
||||
.forResource(Patient.class)
|
||||
.where(BaseResource.RES_ID.exactly().codes(Arrays.asList(id1.getIdPart(), id2.getIdPart(), "FOOOOO")))
|
||||
.and(BaseResource.RES_ID.exactly().code(id1.getIdPart()))
|
||||
.where(IAnyResource.RES_ID.exactly().codes(Arrays.asList(id1.getIdPart(), id2.getIdPart(), "FOOOOO")))
|
||||
.and(IAnyResource.RES_ID.exactly().code(id1.getIdPart()))
|
||||
.returnBundle(Bundle.class)
|
||||
.execute();
|
||||
|
||||
|
@ -2845,7 +2840,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
found = ourClient
|
||||
.search()
|
||||
.forResource(Patient.class)
|
||||
.where(BaseResource.RES_ID.exactly().codes(id1.getIdPart(), id2.getIdPart(), "FOOO"))
|
||||
.where(IAnyResource.RES_ID.exactly().codes(id1.getIdPart(), id2.getIdPart(), "FOOO"))
|
||||
.returnBundle(Bundle.class)
|
||||
.execute();
|
||||
|
||||
|
@ -2854,7 +2849,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
found = ourClient
|
||||
.search()
|
||||
.forResource(Patient.class)
|
||||
.where(BaseResource.RES_ID.exactly().codes("FOOO"))
|
||||
.where(IAnyResource.RES_ID.exactly().codes("FOOO"))
|
||||
.returnBundle(Bundle.class)
|
||||
.execute();
|
||||
|
||||
|
@ -2872,7 +2867,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
Patient p2 = new Patient();
|
||||
p2.addIdentifier().setSystem("urn:system").setValue("testSearchByIdentifier02");
|
||||
p2.addName().setFamily("testSearchByIdentifierFamily01").addGiven("testSearchByIdentifierGiven02");
|
||||
ourClient.create().resource(p2).execute().getId();
|
||||
ourClient.create().resource(p2).execute();
|
||||
|
||||
//@formatter:off
|
||||
Bundle actual = ourClient
|
||||
|
@ -2934,7 +2929,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
try {
|
||||
assertEquals(200, response.getStatusLine().getStatusCode());
|
||||
String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||
IOUtils.closeQuietly(response.getEntity().getContent());
|
||||
response.getEntity().getContent().close();
|
||||
ourLog.info(output);
|
||||
List<IIdType> ids = toUnqualifiedVersionlessIds(myFhirCtx.newXmlParser().parseResource(Bundle.class, output));
|
||||
ourLog.info(ids.toString());
|
||||
|
@ -2948,7 +2943,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
try {
|
||||
assertEquals(200, response.getStatusLine().getStatusCode());
|
||||
String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||
IOUtils.closeQuietly(response.getEntity().getContent());
|
||||
response.getEntity().getContent().close();
|
||||
ourLog.info(output);
|
||||
List<IIdType> ids = toUnqualifiedVersionlessIds(myFhirCtx.newXmlParser().parseResource(Bundle.class, output));
|
||||
ourLog.info(ids.toString());
|
||||
|
@ -2987,7 +2982,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
try {
|
||||
assertEquals(200, response.getStatusLine().getStatusCode());
|
||||
String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||
IOUtils.closeQuietly(response.getEntity().getContent());
|
||||
response.getEntity().getContent().close();
|
||||
ourLog.info(output);
|
||||
List<String> ids = toUnqualifiedVersionlessIdValues(myFhirCtx.newXmlParser().parseResource(Bundle.class, output));
|
||||
ourLog.info(ids.toString());
|
||||
|
@ -3001,7 +2996,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
try {
|
||||
assertEquals(200, response.getStatusLine().getStatusCode());
|
||||
String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||
IOUtils.closeQuietly(response.getEntity().getContent());
|
||||
response.getEntity().getContent().close();
|
||||
ourLog.info(output);
|
||||
List<String> ids = toUnqualifiedVersionlessIdValues(myFhirCtx.newXmlParser().parseResource(Bundle.class, output));
|
||||
ourLog.info(ids.toString());
|
||||
|
@ -3039,10 +3034,10 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
.where(Patient.ORGANIZATION.hasAnyOfIds(Arrays.asList(o1id.getIdPart(), o2id.getIdPart())))
|
||||
.encodedJson().prettyPrint().returnBundle(Bundle.class).execute();
|
||||
//@formatter:on
|
||||
Set<String> expectedIds = new HashSet<String>();
|
||||
Set<String> expectedIds = new HashSet<>();
|
||||
expectedIds.add(p1Id.getIdPart());
|
||||
expectedIds.add(p2Id.getIdPart());
|
||||
Set<String> actualIds = new HashSet<String>();
|
||||
Set<String> actualIds = new HashSet<>();
|
||||
for (BundleEntryComponent ele : actual.getEntry()) {
|
||||
actualIds.add(ele.getResource().getIdElement().getIdPart());
|
||||
}
|
||||
|
@ -3099,7 +3094,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
assertThat(respString, containsString("Invalid parameter chain: subject.id"));
|
||||
assertEquals(400, resp.getStatusLine().getStatusCode());
|
||||
} finally {
|
||||
IOUtils.closeQuietly(resp.getEntity().getContent());
|
||||
resp.getEntity().getContent().close();
|
||||
}
|
||||
ourLog.info("Outgoing post: {}", httpPost);
|
||||
}
|
||||
|
@ -3217,14 +3212,11 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
IIdType moId = myMedicationAdministrationDao.create(ma).getId().toUnqualifiedVersionless();
|
||||
|
||||
HttpGet get = new HttpGet(ourServerBase + "/MedicationAdministration?medication.code=04823543");
|
||||
CloseableHttpResponse response = ourHttpClient.execute(get);
|
||||
try {
|
||||
try (CloseableHttpResponse response = ourHttpClient.execute(get)) {
|
||||
assertEquals(200, response.getStatusLine().getStatusCode());
|
||||
String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||
ourLog.info(responseString);
|
||||
assertThat(responseString, containsString(moId.getIdPart()));
|
||||
} finally {
|
||||
response.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3249,7 +3241,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
assertThat(ids, contains(oid1));
|
||||
assertThat(ids, not(contains(oid2)));
|
||||
} finally {
|
||||
IOUtils.closeQuietly(resp);
|
||||
resp.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3263,7 +3255,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
Patient patient = new Patient();
|
||||
patient.addIdentifier().setSystem("urn:system").setValue("0");
|
||||
patient.addName().setFamily(methodName).addGiven("Joe");
|
||||
pid1 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||
myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||
}
|
||||
|
||||
for (int i = 1; i <= 20; i++) {
|
||||
|
@ -3294,7 +3286,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
HttpGet get = new HttpGet(ourServerBase + search);
|
||||
CloseableHttpResponse response = ourHttpClient.execute(get);
|
||||
String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||
IOUtils.closeQuietly(response.getEntity().getContent());
|
||||
response.getEntity().getContent().close();
|
||||
ourLog.info(resp);
|
||||
Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, resp);
|
||||
matches = bundle.getTotal();
|
||||
|
@ -3331,7 +3323,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
|
||||
@Test
|
||||
public void testSearchReusesNoParams() {
|
||||
List<IBaseResource> resources = new ArrayList<IBaseResource>();
|
||||
List<IBaseResource> resources = new ArrayList<>();
|
||||
for (int i = 0; i < 50; i++) {
|
||||
Organization org = new Organization();
|
||||
org.setName("HELLO");
|
||||
|
@ -3362,7 +3354,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
|
||||
@Test
|
||||
public void testSearchReusesResultsDisabled() {
|
||||
List<IBaseResource> resources = new ArrayList<IBaseResource>();
|
||||
List<IBaseResource> resources = new ArrayList<>();
|
||||
for (int i = 0; i < 50; i++) {
|
||||
Organization org = new Organization();
|
||||
org.setName("HELLO");
|
||||
|
@ -3408,7 +3400,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
|
||||
@Test
|
||||
public void testSearchReusesResultsEnabled() throws Exception {
|
||||
List<IBaseResource> resources = new ArrayList<IBaseResource>();
|
||||
List<IBaseResource> resources = new ArrayList<>();
|
||||
for (int i = 0; i < 50; i++) {
|
||||
Organization org = new Organization();
|
||||
org.setName("HELLO");
|
||||
|
@ -3427,12 +3419,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
.execute();
|
||||
|
||||
final String uuid1 = toSearchUuidFromLinkNext(result1);
|
||||
Search search1 = newTxTemplate().execute(new TransactionCallback<Search>() {
|
||||
@Override
|
||||
public Search doInTransaction(TransactionStatus theStatus) {
|
||||
return mySearchEntityDao.findByUuid(uuid1);
|
||||
}
|
||||
});
|
||||
Search search1 = newTxTemplate().execute(theStatus -> mySearchEntityDao.findByUuid(uuid1));
|
||||
Date lastReturned1 = search1.getSearchLastReturned();
|
||||
|
||||
Bundle result2 = ourClient
|
||||
|
@ -3444,12 +3431,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
.execute();
|
||||
|
||||
final String uuid2 = toSearchUuidFromLinkNext(result2);
|
||||
Search search2 = newTxTemplate().execute(new TransactionCallback<Search>() {
|
||||
@Override
|
||||
public Search doInTransaction(TransactionStatus theStatus) {
|
||||
return mySearchEntityDao.findByUuid(uuid2);
|
||||
}
|
||||
});
|
||||
Search search2 = newTxTemplate().execute(theStatus -> mySearchEntityDao.findByUuid(uuid2));
|
||||
Date lastReturned2 = search2.getSearchLastReturned();
|
||||
|
||||
assertTrue(lastReturned2.getTime() > lastReturned1.getTime());
|
||||
|
@ -3472,7 +3454,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
|
||||
@Test
|
||||
public void testSearchReusesResultsEnabledNoParams() {
|
||||
List<IBaseResource> resources = new ArrayList<IBaseResource>();
|
||||
List<IBaseResource> resources = new ArrayList<>();
|
||||
for (int i = 0; i < 50; i++) {
|
||||
Organization org = new Organization();
|
||||
org.setName("HELLO");
|
||||
|
@ -3489,12 +3471,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
.execute();
|
||||
|
||||
final String uuid1 = toSearchUuidFromLinkNext(result1);
|
||||
Search search1 = newTxTemplate().execute(new TransactionCallback<Search>() {
|
||||
@Override
|
||||
public Search doInTransaction(TransactionStatus theStatus) {
|
||||
return mySearchEntityDao.findByUuid(uuid1);
|
||||
}
|
||||
});
|
||||
Search search1 = newTxTemplate().execute(theStatus -> mySearchEntityDao.findByUuid(uuid1));
|
||||
Date lastReturned1 = search1.getSearchLastReturned();
|
||||
|
||||
Bundle result2 = ourClient
|
||||
|
@ -3504,12 +3481,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
.execute();
|
||||
|
||||
final String uuid2 = toSearchUuidFromLinkNext(result2);
|
||||
Search search2 = newTxTemplate().execute(new TransactionCallback<Search>() {
|
||||
@Override
|
||||
public Search doInTransaction(TransactionStatus theStatus) {
|
||||
return mySearchEntityDao.findByUuid(uuid2);
|
||||
}
|
||||
});
|
||||
Search search2 = newTxTemplate().execute(theStatus -> mySearchEntityDao.findByUuid(uuid2));
|
||||
Date lastReturned2 = search2.getSearchLastReturned();
|
||||
|
||||
assertTrue(lastReturned2.getTime() > lastReturned1.getTime());
|
||||
|
@ -3606,10 +3578,8 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
ourLog.info("** Done searching in {}ms with count of 1", sw.getMillis());
|
||||
|
||||
ourLog.info(myCapturingInterceptor.getLastResponse().getAllHeaders().toString());
|
||||
assertThat(myCapturingInterceptor.getLastResponse().getHeaders(Constants.HEADER_X_CACHE), Matchers.<String>empty());
|
||||
assertThat(myCapturingInterceptor.getLastResponse().getHeaders(Constants.HEADER_X_CACHE.toLowerCase()), Matchers.<String>empty());
|
||||
|
||||
String msg = "Total is " + found.getTotalElement().getValue() + " and took " + sw.getMillis() + " millis";
|
||||
assertThat(myCapturingInterceptor.getLastResponse().getHeaders(Constants.HEADER_X_CACHE), Matchers.empty());
|
||||
assertThat(myCapturingInterceptor.getLastResponse().getHeaders(Constants.HEADER_X_CACHE.toLowerCase()), Matchers.empty());
|
||||
|
||||
// When we've only got one DB connection available, we are forced to wait for the
|
||||
// search to finish before returning
|
||||
|
@ -3672,8 +3642,8 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
.count(1)
|
||||
.execute();
|
||||
|
||||
assertThat(myCapturingInterceptor.getLastResponse().getHeaders(Constants.HEADER_X_CACHE), Matchers.<String>empty());
|
||||
assertThat(myCapturingInterceptor.getLastResponse().getHeaders(Constants.HEADER_X_CACHE.toLowerCase()), Matchers.<String>empty());
|
||||
assertThat(myCapturingInterceptor.getLastResponse().getHeaders(Constants.HEADER_X_CACHE), Matchers.empty());
|
||||
assertThat(myCapturingInterceptor.getLastResponse().getHeaders(Constants.HEADER_X_CACHE.toLowerCase()), Matchers.empty());
|
||||
|
||||
// WHen we've only got one DB connection available, we are forced to wait for the
|
||||
// search to finish before returning
|
||||
|
@ -3720,7 +3690,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
Patient pat = new Patient();
|
||||
pat.addIdentifier().setSystem("urn:system:rpdstu2").setValue("testSearchWithInclude02");
|
||||
pat.getManagingOrganization().setReferenceElement(orgId.toUnqualifiedVersionless());
|
||||
ourClient.create().resource(pat).prettyPrint().encodedXml().execute().getId();
|
||||
ourClient.create().resource(pat).prettyPrint().encodedXml().execute();
|
||||
|
||||
Bundle found = ourClient
|
||||
.search()
|
||||
|
@ -3891,7 +3861,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
assertThat(ids, contains(id1.getValue()));
|
||||
assertThat(ids, not(contains(id2.getValue())));
|
||||
} finally {
|
||||
IOUtils.closeQuietly(resp);
|
||||
resp.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3922,7 +3892,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
ourLog.info(responseContent);
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
} finally {
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
status.getEntity().getContent().close();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4186,13 +4156,10 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
String contents = loadClasspath("/update.xml");
|
||||
HttpPost post = new HttpPost(ourServerBase);
|
||||
post.setEntity(new StringEntity(contents, ContentType.create("application/xml+fhir", "UTF-8")));
|
||||
CloseableHttpResponse resp = ourHttpClient.execute(post);
|
||||
try {
|
||||
try (CloseableHttpResponse resp = ourHttpClient.execute(post)) {
|
||||
assertEquals(200, resp.getStatusLine().getStatusCode());
|
||||
String output = IOUtils.toString(resp.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||
ourLog.info(output);
|
||||
} finally {
|
||||
resp.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4204,7 +4171,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
p1.setManagingOrganization(new Reference("Organization/99999999999"));
|
||||
|
||||
try {
|
||||
ourClient.create().resource(p1).execute().getId();
|
||||
ourClient.create().resource(p1).execute();
|
||||
fail();
|
||||
} catch (InvalidRequestException e) {
|
||||
assertThat(e.getMessage(), containsString("Organization/99999999999"));
|
||||
|
@ -4222,16 +4189,13 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
|
||||
HttpPut post = new HttpPut(ourServerBase + "/Patient");
|
||||
post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
CloseableHttpResponse response = ourHttpClient.execute(post);
|
||||
try {
|
||||
try (CloseableHttpResponse response = ourHttpClient.execute(post)) {
|
||||
String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||
ourLog.info(responseString);
|
||||
assertEquals(400, response.getStatusLine().getStatusCode());
|
||||
OperationOutcome oo = myFhirCtx.newXmlParser().parseResource(OperationOutcome.class, responseString);
|
||||
assertThat(oo.getIssue().get(0).getDiagnostics(),
|
||||
containsString("Can not update resource, request URL must contain an ID element for update (PUT) operation (it must be of the form [base]/[resource type]/[id])"));
|
||||
} finally {
|
||||
response.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4246,15 +4210,12 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
|
||||
HttpPut post = new HttpPut(ourServerBase + "/Patient");
|
||||
post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
CloseableHttpResponse response = ourHttpClient.execute(post);
|
||||
try {
|
||||
try (CloseableHttpResponse response = ourHttpClient.execute(post)) {
|
||||
String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||
ourLog.info(responseString);
|
||||
assertThat(responseString, containsString("Can not update resource, request URL must contain an ID element for update (PUT) operation (it must be of the form [base]/[resource type]/[id])"));
|
||||
assertThat(responseString, containsString("<OperationOutcome"));
|
||||
assertEquals(400, response.getStatusLine().getStatusCode());
|
||||
} finally {
|
||||
response.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4272,15 +4233,12 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
|
||||
HttpPut post = new HttpPut(ourServerBase + "/Patient/FOO");
|
||||
post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
CloseableHttpResponse response = ourHttpClient.execute(post);
|
||||
try {
|
||||
try (CloseableHttpResponse response = ourHttpClient.execute(post)) {
|
||||
String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||
ourLog.info(responseString);
|
||||
assertThat(responseString, containsString("Can not update resource, request URL must contain an ID element for update (PUT) operation (it must be of the form [base]/[resource type]/[id])"));
|
||||
assertThat(responseString, containsString("<OperationOutcome"));
|
||||
assertEquals(400, response.getStatusLine().getStatusCode());
|
||||
} finally {
|
||||
response.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4486,7 +4444,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
try {
|
||||
assertEquals(200, response.getStatusLine().getStatusCode());
|
||||
String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||
IOUtils.closeQuietly(response.getEntity().getContent());
|
||||
response.getEntity().getContent().close();
|
||||
|
||||
Patient respPt = myFhirCtx.newXmlParser().parseResource(Patient.class, responseString);
|
||||
assertEquals("2", respPt.getIdElement().getVersionIdPart());
|
||||
|
|
Loading…
Reference in New Issue