Working through failed tests. Consolidating sleep calls
This commit is contained in:
parent
10aa6c9f07
commit
b4350bbdae
|
@ -25,11 +25,15 @@ import com.google.common.collect.ImmutableSet;
|
|||
import com.google.common.reflect.ClassPath;
|
||||
import com.google.common.reflect.ClassPath.ClassInfo;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.r4.model.InstantType;
|
||||
import org.hl7.fhir.r4.model.Patient;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.AnnotatedElement;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -165,10 +169,21 @@ public class TestUtil {
|
|||
ourLog.info("Sleeping for {}ms", timeToSleep);
|
||||
Thread.sleep(timeToSleep);
|
||||
} catch (InterruptedException theE) {
|
||||
theE.printStackTrace();
|
||||
ourLog.error("Interrupted", theE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void clearAllStaticFieldsForUnitTest() {
|
||||
ca.uhn.fhir.util.TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
public static InstantType getTimestamp(IBaseResource resource) {
|
||||
return new InstantType(new Date(resource.getMeta().getLastUpdated().getTime()));
|
||||
}
|
||||
|
||||
public static void sleepOneClick() {
|
||||
sleepAtLeast(1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParamConstants;
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||
import ca.uhn.fhir.jpa.util.TestUtil;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.dstu3.model.*;
|
||||
|
@ -40,7 +41,6 @@ import ca.uhn.fhir.rest.api.SortSpec;
|
|||
import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
||||
import ca.uhn.fhir.rest.param.*;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
|
||||
|
@ -667,6 +667,9 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
|
|||
id1 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||
}
|
||||
long betweenTime = System.currentTimeMillis();
|
||||
|
||||
TestUtil.sleepOneClick();
|
||||
|
||||
IIdType id2;
|
||||
{
|
||||
Patient patient = new Patient();
|
||||
|
@ -1199,7 +1202,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
|
|||
int sleep = 100;
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(sleep);
|
||||
TestUtil.sleepAtLeast(sleep);
|
||||
|
||||
IIdType id1a;
|
||||
{
|
||||
|
@ -1218,7 +1221,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
|
|||
ourLog.info("Res 2: {}", myPatientDao.read(id1a, mySrd).getMeta().getLastUpdatedElement().getValueAsString());
|
||||
ourLog.info("Res 3: {}", myPatientDao.read(id1b, mySrd).getMeta().getLastUpdatedElement().getValueAsString());
|
||||
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(sleep);
|
||||
TestUtil.sleepAtLeast(sleep);
|
||||
long end = System.currentTimeMillis();
|
||||
|
||||
SearchParameterMap map;
|
||||
|
@ -1615,18 +1618,18 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
|
|||
obs01.setSubject(new Reference(patientId01));
|
||||
IIdType obsId01 = myObservationDao.create(obs01, mySrd).getId().toUnqualifiedVersionless();
|
||||
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(1);
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepOneClick();
|
||||
Date between = new Date();
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(1);
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepOneClick();
|
||||
|
||||
Observation obs02 = new Observation();
|
||||
obs02.setEffective(new DateTimeType(new Date()));
|
||||
obs02.setSubject(new Reference(locId01));
|
||||
IIdType obsId02 = myObservationDao.create(obs02, mySrd).getId().toUnqualifiedVersionless();
|
||||
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(1);
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepOneClick();
|
||||
Date after = new Date();
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(1);
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepOneClick();
|
||||
|
||||
ourLog.info("P1[{}] L1[{}] Obs1[{}] Obs2[{}]", new Object[] { patientId01, locId01, obsId01, obsId02 });
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import ca.uhn.fhir.jpa.dao.data.ISearchDao;
|
|||
import ca.uhn.fhir.jpa.dao.r4.FhirResourceDaoR4SearchPageExpiryTest;
|
||||
import ca.uhn.fhir.jpa.entity.Search;
|
||||
import ca.uhn.fhir.jpa.search.StaleSearchDeletingSvcImpl;
|
||||
import ca.uhn.fhir.jpa.util.TestUtil;
|
||||
import ca.uhn.fhir.util.StopWatch;
|
||||
import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
||||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
|
@ -29,7 +30,6 @@ import org.springframework.transaction.support.TransactionTemplate;
|
|||
import java.util.Date;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import static ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast;
|
||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
@ -105,8 +105,7 @@ public class FhirResourceDaoDstu3SearchPageExpiryTest extends BaseJpaDstu3Test {
|
|||
}
|
||||
assertEquals(searchUuid1, searchUuid2);
|
||||
|
||||
sleepAtLeast(501);
|
||||
|
||||
TestUtil.sleepAtLeast(501);
|
||||
// We're now past 500ms so we shouldn't reuse the search
|
||||
|
||||
final String searchUuid3;
|
||||
|
@ -277,7 +276,7 @@ public class FhirResourceDaoDstu3SearchPageExpiryTest extends BaseJpaDstu3Test {
|
|||
}
|
||||
assertEquals(searchUuid1, searchUuid2);
|
||||
|
||||
sleepAtLeast(501);
|
||||
TestUtil.sleepAtLeast(501);
|
||||
|
||||
// We're now past 500ms so we shouldn't reuse the search
|
||||
|
||||
|
@ -363,7 +362,7 @@ public class FhirResourceDaoDstu3SearchPageExpiryTest extends BaseJpaDstu3Test {
|
|||
}
|
||||
});
|
||||
if (search == null) {
|
||||
sleepAtLeast(100);
|
||||
TestUtil.sleepAtLeast(100);
|
||||
}
|
||||
}
|
||||
assertNotNull("Search " + bundleProvider.getUuid() + " not found on disk after 10 seconds", search);
|
||||
|
|
|
@ -2867,21 +2867,21 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
|
|||
p.addName().setFamily(methodName);
|
||||
IIdType id1 = myPatientDao.create(p, mySrd).getId().toUnqualifiedVersionless();
|
||||
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(1);
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepOneClick();
|
||||
|
||||
p = new Patient();
|
||||
p.addIdentifier().setSystem("urn:system2").setValue(methodName);
|
||||
p.addName().setFamily(methodName);
|
||||
IIdType id2 = myPatientDao.create(p, mySrd).getId().toUnqualifiedVersionless();
|
||||
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(1);
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepOneClick();
|
||||
|
||||
p = new Patient();
|
||||
p.addIdentifier().setSystem("urn:system3").setValue(methodName);
|
||||
p.addName().setFamily(methodName);
|
||||
IIdType id3 = myPatientDao.create(p, mySrd).getId().toUnqualifiedVersionless();
|
||||
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(1);
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepOneClick();
|
||||
|
||||
p = new Patient();
|
||||
p.addIdentifier().setSystem("urn:system4").setValue(methodName);
|
||||
|
|
|
@ -306,7 +306,7 @@ public class FhirResourceDaoDstu3UpdateTest extends BaseJpaDstu3Test {
|
|||
|
||||
assertEquals("1", outcome.getId().getVersionIdPart());
|
||||
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(100);
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepOneClick();
|
||||
Date now = new Date();
|
||||
Patient retrieved = myPatientDao.read(outcome.getId(), mySrd);
|
||||
InstantType updated = retrieved.getMeta().getLastUpdatedElement().copy();
|
||||
|
|
|
@ -4,6 +4,7 @@ import static org.hamcrest.Matchers.containsString;
|
|||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import ca.uhn.fhir.jpa.util.TestUtil;
|
||||
import ca.uhn.fhir.rest.api.EncodingEnum;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.api.ValidationModeEnum;
|
||||
|
@ -11,7 +12,6 @@ import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException;
|
|||
import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
import ca.uhn.fhir.util.StopWatch;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.hl7.fhir.dstu3.model.*;
|
||||
import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent;
|
||||
|
@ -25,8 +25,6 @@ import org.junit.Test;
|
|||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import static ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast;
|
||||
|
||||
public class FhirResourceDaoDstu3ValidateTest extends BaseJpaDstu3Test {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoDstu3ValidateTest.class);
|
||||
|
||||
|
@ -64,7 +62,7 @@ public class FhirResourceDaoDstu3ValidateTest extends BaseJpaDstu3Test {
|
|||
MethodOutcome results = myQuestionnaireResponseDao.validate(qr, null, null, null, null, null, null);
|
||||
ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(results.getOperationOutcome()));
|
||||
|
||||
sleepAtLeast(2500);
|
||||
TestUtil.sleepAtLeast(2500);
|
||||
try {
|
||||
myQuestionnaireResponseDao.validate(qr, null, null, null, null, null, null);
|
||||
fail();
|
||||
|
|
|
@ -4,6 +4,7 @@ import ca.uhn.fhir.jpa.dao.DaoConfig;
|
|||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap.EverythingModeEnum;
|
||||
import ca.uhn.fhir.jpa.model.entity.*;
|
||||
import ca.uhn.fhir.jpa.util.TestUtil;
|
||||
import ca.uhn.fhir.model.api.Include;
|
||||
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
|
||||
import ca.uhn.fhir.parser.StrictErrorHandler;
|
||||
|
@ -12,7 +13,6 @@ import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
|||
import ca.uhn.fhir.rest.param.*;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.MethodNotAllowedException;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
|
@ -151,16 +151,16 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test {
|
|||
List<String> ids;
|
||||
|
||||
Date beforeAll = new Date();
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(100);
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepOneClick();
|
||||
|
||||
Organization org = new Organization();
|
||||
org.setName("O1");
|
||||
org.setId("O1");
|
||||
myOrganizationDao.update(org);
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(100);
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepOneClick();
|
||||
|
||||
Date beforePatient = new Date();
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(100);
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepOneClick();
|
||||
|
||||
Patient p = new Patient();
|
||||
p.setId("P1");
|
||||
|
@ -168,7 +168,7 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test {
|
|||
p.setManagingOrganization(new Reference("Organization/O1"));
|
||||
myPatientDao.update(p);
|
||||
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(100);
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepOneClick();
|
||||
Date afterAll = new Date();
|
||||
|
||||
// Search with between date (should still return Organization even though
|
||||
|
@ -216,7 +216,7 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test {
|
|||
myOrganizationDao.update(org);
|
||||
|
||||
Date beforeAll = new Date();
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(100);
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepOneClick();
|
||||
|
||||
Patient p = new Patient();
|
||||
p.setId("P1");
|
||||
|
@ -224,17 +224,17 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test {
|
|||
p.setManagingOrganization(new Reference("Organization/O1"));
|
||||
myPatientDao.update(p);
|
||||
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(100);
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepOneClick();
|
||||
|
||||
Date beforeOrg = new Date();
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(100);
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepOneClick();
|
||||
|
||||
org = new Organization();
|
||||
org.setActive(true);
|
||||
org.setId("O1");
|
||||
myOrganizationDao.update(org);
|
||||
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(100);
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepOneClick();
|
||||
Date afterAll = new Date();
|
||||
|
||||
// Everything should come back
|
||||
|
@ -890,6 +890,9 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test {
|
|||
id1 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||
}
|
||||
long betweenTime = System.currentTimeMillis();
|
||||
|
||||
TestUtil.sleepOneClick();
|
||||
|
||||
IIdType id2;
|
||||
{
|
||||
Patient patient = new Patient();
|
||||
|
@ -1266,6 +1269,8 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test {
|
|||
|
||||
Date betweenTime = new Date();
|
||||
|
||||
TestUtil.sleepOneClick();
|
||||
|
||||
IIdType id2;
|
||||
{
|
||||
Patient patient = new Patient();
|
||||
|
@ -1439,10 +1444,10 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test {
|
|||
id0 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||
}
|
||||
|
||||
int sleep = 100;
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
Thread.sleep(sleep);
|
||||
|
||||
TestUtil.sleepOneClick();
|
||||
|
||||
IIdType id1a;
|
||||
{
|
||||
|
@ -1461,7 +1466,8 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test {
|
|||
ourLog.info("Res 2: {}", myPatientDao.read(id1a, mySrd).getMeta().getLastUpdatedElement().getValueAsString());
|
||||
ourLog.info("Res 3: {}", myPatientDao.read(id1b, mySrd).getMeta().getLastUpdatedElement().getValueAsString());
|
||||
|
||||
Thread.sleep(sleep);
|
||||
TestUtil.sleepOneClick();
|
||||
|
||||
long end = System.currentTimeMillis();
|
||||
|
||||
SearchParameterMap map;
|
||||
|
@ -1487,7 +1493,7 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test {
|
|||
|
||||
map = new SearchParameterMap();
|
||||
map.setLastUpdated(new DateRangeParam(new DateParam(ParamPrefixEnum.GREATERTHAN, startDateTime.getValue()),
|
||||
new DateParam(ParamPrefixEnum.LESSTHAN, myPatientDao.read(id1b, mySrd).getMeta().getLastUpdatedElement().getValue())));
|
||||
new DateParam(ParamPrefixEnum.LESSTHAN, TestUtil.getTimestamp(myPatientDao.read(id1b, mySrd)))));
|
||||
ourLog.info("Searching: {}", map.getLastUpdated());
|
||||
assertThat(toUnqualifiedVersionlessIds(myPatientDao.search(map)), containsInAnyOrder(id1a));
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import ca.uhn.fhir.jpa.dao.DaoConfig;
|
|||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap.EverythingModeEnum;
|
||||
import ca.uhn.fhir.jpa.model.entity.*;
|
||||
import ca.uhn.fhir.jpa.util.TestUtil;
|
||||
import ca.uhn.fhir.model.api.Include;
|
||||
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
|
||||
import ca.uhn.fhir.parser.StrictErrorHandler;
|
||||
|
@ -12,7 +13,6 @@ import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
|||
import ca.uhn.fhir.rest.param.*;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.MethodNotAllowedException;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
|
@ -153,16 +153,16 @@ public class FhirResourceDaoR4SearchNoHashesTest extends BaseJpaR4Test {
|
|||
List<String> ids;
|
||||
|
||||
Date beforeAll = new Date();
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(100);
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepOneClick();
|
||||
|
||||
Organization org = new Organization();
|
||||
org.setName("O1");
|
||||
org.setId("O1");
|
||||
myOrganizationDao.update(org);
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(100);
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepOneClick();
|
||||
|
||||
Date beforePatient = new Date();
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(100);
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepOneClick();
|
||||
|
||||
Patient p = new Patient();
|
||||
p.setId("P1");
|
||||
|
@ -170,7 +170,7 @@ public class FhirResourceDaoR4SearchNoHashesTest extends BaseJpaR4Test {
|
|||
p.setManagingOrganization(new Reference("Organization/O1"));
|
||||
myPatientDao.update(p);
|
||||
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(100);
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepOneClick();
|
||||
Date afterAll = new Date();
|
||||
|
||||
// Search with between date (should still return Organization even though
|
||||
|
@ -218,7 +218,7 @@ public class FhirResourceDaoR4SearchNoHashesTest extends BaseJpaR4Test {
|
|||
myOrganizationDao.update(org);
|
||||
|
||||
Date beforeAll = new Date();
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(100);
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepOneClick();
|
||||
|
||||
Patient p = new Patient();
|
||||
p.setId("P1");
|
||||
|
@ -226,17 +226,17 @@ public class FhirResourceDaoR4SearchNoHashesTest extends BaseJpaR4Test {
|
|||
p.setManagingOrganization(new Reference("Organization/O1"));
|
||||
myPatientDao.update(p);
|
||||
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(100);
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepOneClick();
|
||||
|
||||
Date beforeOrg = new Date();
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(100);
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepOneClick();
|
||||
|
||||
org = new Organization();
|
||||
org.setActive(true);
|
||||
org.setId("O1");
|
||||
myOrganizationDao.update(org);
|
||||
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(100);
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepOneClick();
|
||||
Date afterAll = new Date();
|
||||
|
||||
// Everything should come back
|
||||
|
@ -891,6 +891,7 @@ public class FhirResourceDaoR4SearchNoHashesTest extends BaseJpaR4Test {
|
|||
patient.addIdentifier().setSystem("urn:system").setValue("001");
|
||||
id1 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||
}
|
||||
TestUtil.sleepOneClick();
|
||||
long betweenTime = System.currentTimeMillis();
|
||||
IIdType id2;
|
||||
{
|
||||
|
@ -1266,6 +1267,8 @@ public class FhirResourceDaoR4SearchNoHashesTest extends BaseJpaR4Test {
|
|||
id1 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||
}
|
||||
|
||||
TestUtil.sleepOneClick();
|
||||
|
||||
Date betweenTime = new Date();
|
||||
|
||||
IIdType id2;
|
||||
|
@ -1349,8 +1352,7 @@ public class FhirResourceDaoR4SearchNoHashesTest extends BaseJpaR4Test {
|
|||
public void testSearchLastUpdatedParam() throws InterruptedException {
|
||||
String methodName = "testSearchLastUpdatedParam";
|
||||
|
||||
int sleep = 100;
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(sleep);
|
||||
TestUtil.sleepOneClick();
|
||||
|
||||
DateTimeType beforeAny = new DateTimeType(new Date(), TemporalPrecisionEnum.MILLI);
|
||||
IIdType id1a;
|
||||
|
@ -1368,9 +1370,9 @@ public class FhirResourceDaoR4SearchNoHashesTest extends BaseJpaR4Test {
|
|||
id1b = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||
}
|
||||
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(1100);
|
||||
TestUtil.sleepAtLeast(1100);
|
||||
DateTimeType beforeR2 = new DateTimeType(new Date(), TemporalPrecisionEnum.MILLI);
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(1100);
|
||||
TestUtil.sleepAtLeast(1100);
|
||||
|
||||
IIdType id2;
|
||||
{
|
||||
|
@ -1441,10 +1443,8 @@ public class FhirResourceDaoR4SearchNoHashesTest extends BaseJpaR4Test {
|
|||
id0 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||
}
|
||||
|
||||
int sleep = 100;
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(sleep);
|
||||
TestUtil.sleepOneClick();
|
||||
|
||||
IIdType id1a;
|
||||
{
|
||||
|
@ -1463,7 +1463,8 @@ public class FhirResourceDaoR4SearchNoHashesTest extends BaseJpaR4Test {
|
|||
ourLog.info("Res 2: {}", myPatientDao.read(id1a, mySrd).getMeta().getLastUpdatedElement().getValueAsString());
|
||||
ourLog.info("Res 3: {}", myPatientDao.read(id1b, mySrd).getMeta().getLastUpdatedElement().getValueAsString());
|
||||
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(sleep);
|
||||
TestUtil.sleepOneClick();
|
||||
|
||||
long end = System.currentTimeMillis();
|
||||
|
||||
SearchParameterMap map;
|
||||
|
@ -1489,7 +1490,7 @@ public class FhirResourceDaoR4SearchNoHashesTest extends BaseJpaR4Test {
|
|||
|
||||
map = new SearchParameterMap();
|
||||
map.setLastUpdated(new DateRangeParam(new DateParam(ParamPrefixEnum.GREATERTHAN, startDateTime.getValue()),
|
||||
new DateParam(ParamPrefixEnum.LESSTHAN, myPatientDao.read(id1b, mySrd).getMeta().getLastUpdatedElement().getValue())));
|
||||
new DateParam(ParamPrefixEnum.LESSTHAN, TestUtil.getTimestamp(myPatientDao.read(id1b, mySrd)))));
|
||||
ourLog.info("Searching: {}", map.getLastUpdated());
|
||||
assertThat(toUnqualifiedVersionlessIds(myPatientDao.search(map)), containsInAnyOrder(id1a));
|
||||
}
|
||||
|
@ -1860,14 +1861,14 @@ public class FhirResourceDaoR4SearchNoHashesTest extends BaseJpaR4Test {
|
|||
IIdType obsId01 = myObservationDao.create(obs01, mySrd).getId().toUnqualifiedVersionless();
|
||||
|
||||
Date between = new Date();
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(10);
|
||||
TestUtil.sleepOneClick();
|
||||
|
||||
Observation obs02 = new Observation();
|
||||
obs02.setEffective(new DateTimeType(new Date()));
|
||||
obs02.setSubject(new Reference(locId01));
|
||||
IIdType obsId02 = myObservationDao.create(obs02, mySrd).getId().toUnqualifiedVersionless();
|
||||
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(10);
|
||||
TestUtil.sleepOneClick();
|
||||
Date after = new Date();
|
||||
|
||||
ourLog.info("P1[{}] L1[{}] Obs1[{}] Obs2[{}]", patientId01, locId01, obsId01, obsId02);
|
||||
|
@ -1991,14 +1992,14 @@ public class FhirResourceDaoR4SearchNoHashesTest extends BaseJpaR4Test {
|
|||
pid1 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||
}
|
||||
Date between = new Date();
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(10);
|
||||
TestUtil.sleepOneClick();
|
||||
{
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier().setSystem("urn:system").setValue("002");
|
||||
patient.addName().setFamily("Tester_testSearchStringParam").addGiven("John");
|
||||
pid2 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||
}
|
||||
ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast(10);
|
||||
TestUtil.sleepOneClick();
|
||||
Date after = new Date();
|
||||
|
||||
SearchParameterMap params;
|
||||
|
@ -2945,6 +2946,8 @@ public class FhirResourceDaoR4SearchNoHashesTest extends BaseJpaR4Test {
|
|||
tag1id = myOrganizationDao.create(org, mySrd).getId().toUnqualifiedVersionless();
|
||||
}
|
||||
|
||||
TestUtil.sleepOneClick();
|
||||
|
||||
Date betweenDate = new Date();
|
||||
|
||||
IIdType tag2id;
|
||||
|
|
|
@ -6,6 +6,7 @@ import ca.uhn.fhir.jpa.dao.data.ISearchDao;
|
|||
import ca.uhn.fhir.jpa.entity.Search;
|
||||
import ca.uhn.fhir.jpa.entity.SearchStatusEnum;
|
||||
import ca.uhn.fhir.jpa.search.StaleSearchDeletingSvcImpl;
|
||||
import ca.uhn.fhir.jpa.util.TestUtil;
|
||||
import ca.uhn.fhir.util.StopWatch;
|
||||
import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
||||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
|
@ -29,7 +30,6 @@ import javax.annotation.Nullable;
|
|||
import java.util.Date;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import static ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast;
|
||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
@ -100,7 +100,7 @@ public class FhirResourceDaoR4SearchPageExpiryTest extends BaseJpaR4Test {
|
|||
}
|
||||
assertEquals(searchUuid1, searchUuid2);
|
||||
|
||||
sleepAtLeast(501);
|
||||
TestUtil.sleepAtLeast(501);
|
||||
|
||||
// We're now past 500ms so we shouldn't reuse the search
|
||||
|
||||
|
@ -274,7 +274,7 @@ public class FhirResourceDaoR4SearchPageExpiryTest extends BaseJpaR4Test {
|
|||
}
|
||||
assertEquals(searchUuid1, searchUuid2);
|
||||
|
||||
sleepAtLeast(501);
|
||||
TestUtil.sleepAtLeast(501);
|
||||
|
||||
// We're now past 500ms so we shouldn't reuse the search
|
||||
|
||||
|
@ -360,7 +360,7 @@ public class FhirResourceDaoR4SearchPageExpiryTest extends BaseJpaR4Test {
|
|||
}
|
||||
});
|
||||
if (search == null) {
|
||||
sleepAtLeast(100);
|
||||
TestUtil.sleepAtLeast(100);
|
||||
}
|
||||
}
|
||||
assertNotNull("Search " + bundleProvider.getUuid() + " not found on disk after 10 seconds", search);
|
||||
|
@ -407,7 +407,7 @@ public class FhirResourceDaoR4SearchPageExpiryTest extends BaseJpaR4Test {
|
|||
for (int i = 0; i < 20 && search == null; i++) {
|
||||
search = theSearchEntityDao.findByUuid(theUuid);
|
||||
if (search == null || search.getStatus() == SearchStatusEnum.LOADING) {
|
||||
sleepAtLeast(100);
|
||||
TestUtil.sleepAtLeast(100);
|
||||
}
|
||||
}
|
||||
assertNotNull(search);
|
||||
|
|
|
@ -2,6 +2,7 @@ package ca.uhn.fhir.jpa.dao.r4;
|
|||
|
||||
import ca.uhn.fhir.jpa.dao.DaoConfig;
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||
import ca.uhn.fhir.jpa.util.TestUtil;
|
||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
||||
|
@ -12,7 +13,6 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceGoneException;
|
|||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor.ActionRequestDetails;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.r4.model.*;
|
||||
|
@ -314,11 +314,14 @@ public class FhirResourceDaoR4UpdateTest extends BaseJpaR4Test {
|
|||
assertEquals("1", outcome.getId().getVersionIdPart());
|
||||
|
||||
Date now = new Date();
|
||||
|
||||
TestUtil.sleepOneClick();
|
||||
|
||||
Patient retrieved = myPatientDao.read(outcome.getId(), mySrd);
|
||||
InstantType updated = retrieved.getMeta().getLastUpdatedElement().copy();
|
||||
InstantType updated = TestUtil.getTimestamp(retrieved);
|
||||
assertTrue(updated.before(now));
|
||||
|
||||
Thread.sleep(1000);
|
||||
TestUtil.sleepOneClick();
|
||||
|
||||
reset(myInterceptor);
|
||||
retrieved.getIdentifier().get(0).setValue("002");
|
||||
|
@ -341,11 +344,11 @@ public class FhirResourceDaoR4UpdateTest extends BaseJpaR4Test {
|
|||
|
||||
assertEquals("2", retrieved2.getIdElement().getVersionIdPart());
|
||||
assertEquals("002", retrieved2.getIdentifier().get(0).getValue());
|
||||
InstantType updated2 = retrieved2.getMeta().getLastUpdatedElement();
|
||||
InstantType updated2 = TestUtil.getTimestamp(retrieved2);
|
||||
assertTrue(updated2.after(now));
|
||||
assertTrue(updated2.before(now2));
|
||||
|
||||
Thread.sleep(2000);
|
||||
TestUtil.sleepOneClick();
|
||||
|
||||
/*
|
||||
* Get history
|
||||
|
|
|
@ -2,12 +2,12 @@ package ca.uhn.fhir.jpa.provider.r4;
|
|||
|
||||
import ca.uhn.fhir.jpa.dao.DaoConfig;
|
||||
import ca.uhn.fhir.jpa.search.SearchCoordinatorSvcImpl;
|
||||
import ca.uhn.fhir.jpa.util.TestUtil;
|
||||
import ca.uhn.fhir.parser.StrictErrorHandler;
|
||||
import ca.uhn.fhir.rest.api.CacheControlDirective;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.client.interceptor.CapturingInterceptor;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import org.hl7.fhir.r4.model.Bundle;
|
||||
import org.hl7.fhir.r4.model.Patient;
|
||||
import org.junit.After;
|
||||
|
@ -159,6 +159,7 @@ public class ResourceProviderR4CacheTest extends BaseResourceProviderR4Test {
|
|||
ourClient.create().resource(pt1).execute();
|
||||
|
||||
Date beforeFirst = new Date();
|
||||
TestUtil.sleepOneClick();
|
||||
|
||||
Bundle results1 = ourClient.search().forResource("Patient").where(Patient.FAMILY.matches().value("FAM")).returnBundle(Bundle.class).execute();
|
||||
assertEquals(1, results1.getEntry().size());
|
||||
|
|
|
@ -37,6 +37,7 @@ import java.util.Set;
|
|||
import java.util.TreeSet;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import ca.uhn.fhir.jpa.util.TestUtil;
|
||||
import ca.uhn.fhir.rest.api.PreferReturnEnum;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
@ -116,7 +117,6 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceGoneException;
|
|||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor;
|
||||
import ca.uhn.fhir.util.StopWatch;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import ca.uhn.fhir.util.UrlUtil;
|
||||
|
||||
@SuppressWarnings("Duplicates")
|
||||
|
@ -3659,6 +3659,8 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
Search search1 = newTxTemplate().execute(theStatus -> mySearchEntityDao.findByUuid(uuid1));
|
||||
Date lastReturned1 = search1.getSearchLastReturned();
|
||||
|
||||
TestUtil.sleepOneClick();
|
||||
|
||||
Bundle result2 = ourClient
|
||||
.search()
|
||||
.forResource("Organization")
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
|||
|
||||
@Configuration
|
||||
@EnableScheduling
|
||||
@ComponentScan(basePackages = {"ca.uhn.fhir.jpa.searchparam", "ca.uhn.fhir.jpa.subscription.module", "ca.uhn.fhir.jpa.model.interceptor.executor"})
|
||||
@ComponentScan(basePackages = {"ca.uhn.fhir.jpa.searchparam", "ca.uhn.fhir.jpa.subscription.module"})
|
||||
public abstract class BaseSubscriptionConfig {
|
||||
public abstract FhirContext fhirContext();
|
||||
|
||||
|
|
|
@ -13,8 +13,6 @@ import java.util.concurrent.TimeUnit;
|
|||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class LatchedService implements IAnonymousLambdaHook {
|
||||
|
|
|
@ -65,8 +65,8 @@ public abstract class BaseBlockingQueueSubscribableChannelDstu3Test extends Base
|
|||
private static SubscribableChannel ourSubscribableChannel;
|
||||
private List<IIdType> mySubscriptionIds = Collections.synchronizedList(new ArrayList<>());
|
||||
private long idCounter = 0;
|
||||
protected LatchedService mySubscriptionMatchingPost = new LatchedService(Pointcut.SUBSCRIPTION_AFTER_SUBSCRIPTION_MATCHING);
|
||||
protected LatchedService mySubscriptionActivatedPost = new LatchedService(Pointcut.SUBSCRIPTION_AFTER_SUBSCRIPTION_ACTIVATED);
|
||||
protected LatchedService mySubscriptionMatchingPost = new LatchedService(Pointcut.SUBSCRIPTION_AFTER_PERSISTED_RESOURCE_CHECKED);
|
||||
protected LatchedService mySubscriptionActivatedPost = new LatchedService(Pointcut.SUBSCRIPTION_AFTER_ACTIVE_SUBSCRIPTION_REGISTERED);
|
||||
|
||||
@Before
|
||||
public void beforeReset() {
|
||||
|
@ -77,8 +77,8 @@ public abstract class BaseBlockingQueueSubscribableChannelDstu3Test extends Base
|
|||
ourSubscribableChannel = mySubscriptionChannelFactory.newDeliveryChannel("test", Subscription.SubscriptionChannelType.RESTHOOK.toCode().toLowerCase());
|
||||
ourSubscribableChannel.subscribe(myStandaloneSubscriptionMessageHandler);
|
||||
}
|
||||
myInterceptorRegistry.registerAnonymousHookForUnitTest(Pointcut.SUBSCRIPTION_AFTER_SUBSCRIPTION_MATCHING, mySubscriptionMatchingPost);
|
||||
myInterceptorRegistry.registerAnonymousHookForUnitTest(Pointcut.SUBSCRIPTION_AFTER_SUBSCRIPTION_ACTIVATED, mySubscriptionActivatedPost);
|
||||
myInterceptorRegistry.registerAnonymousHookForUnitTest(Pointcut.SUBSCRIPTION_AFTER_PERSISTED_RESOURCE_CHECKED, mySubscriptionMatchingPost);
|
||||
myInterceptorRegistry.registerAnonymousHookForUnitTest(Pointcut.SUBSCRIPTION_AFTER_ACTIVE_SUBSCRIPTION_REGISTERED, mySubscriptionActivatedPost);
|
||||
}
|
||||
|
||||
@After
|
||||
|
|
Loading…
Reference in New Issue