Add tests

This commit is contained in:
James 2017-06-29 22:16:39 -04:00
parent 10ff2dd16c
commit dfd37c69d8
4 changed files with 99 additions and 38 deletions

View File

@ -40,6 +40,7 @@ public class TestDstu3Config extends BaseJavaConfigDstu3 {
DataSource dataSource = ProxyDataSourceBuilder
.create(retVal)
.multiline()
.logQueryBySlf4j(SLF4JLogLevel.INFO, "SQL")
.logSlowQueryBySlf4j(10, TimeUnit.SECONDS)
.countQuery()

View File

@ -27,6 +27,7 @@ import org.hl7.fhir.dstu3.model.Condition;
import org.hl7.fhir.dstu3.model.Device;
import org.hl7.fhir.dstu3.model.DiagnosticReport;
import org.hl7.fhir.dstu3.model.Encounter;
import org.hl7.fhir.dstu3.model.Group;
import org.hl7.fhir.dstu3.model.Immunization;
import org.hl7.fhir.dstu3.model.ImmunizationRecommendation;
import org.hl7.fhir.dstu3.model.Location;
@ -77,7 +78,10 @@ import ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet;
import ca.uhn.fhir.jpa.dao.IFhirSystemDao;
import ca.uhn.fhir.jpa.dao.IFulltextSearchSvc;
import ca.uhn.fhir.jpa.dao.ISearchParamRegistry;
import ca.uhn.fhir.jpa.dao.data.*;
import ca.uhn.fhir.jpa.dao.data.IResourceTableDao;
import ca.uhn.fhir.jpa.dao.data.IResourceTagDao;
import ca.uhn.fhir.jpa.dao.data.ISearchDao;
import ca.uhn.fhir.jpa.dao.data.ITagDefinitionDao;
import ca.uhn.fhir.jpa.dao.dstu2.FhirResourceDaoDstu2SearchNoFtTest;
import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamString;
import ca.uhn.fhir.jpa.entity.ResourceTable;
@ -104,18 +108,7 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest {
private static JpaValidationSupportChainDstu3 ourJpaValidationSupportChainDstu3;
private static IFhirResourceDaoValueSet<ValueSet, Coding, CodeableConcept> ourValueSetDao;
@Autowired
protected ITagDefinitionDao myTagDefinitionDao;
@Autowired
protected IResourceTagDao myResourceTagDao;
@Autowired
protected ISearchDao mySearchEntityDao;
@Autowired
@Qualifier("mySearchParameterDaoDstu3")
protected IFhirResourceDao<SearchParameter> mySearchParameterDao;
@Autowired
protected ISearchParamRegistry mySearchParamRegsitry;
// @Autowired
// @Autowired
// protected HapiWorkerContext myHapiWorkerContext;
@Autowired
@Qualifier("myAllergyIntoleranceDaoDstu3")
@ -131,13 +124,10 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest {
@Autowired
@Qualifier("myBundleDaoDstu3")
protected IFhirResourceDao<Bundle> myBundleDao;
@Autowired
@Autowired
@Qualifier("myCarePlanDaoDstu3")
protected IFhirResourceDao<CarePlan> myCarePlanDao;
@Autowired
@Qualifier("myProcedureRequestDaoDstu3")
protected IFhirResourceDao<ProcedureRequest> myProcedureRequestDao;
@Autowired
@Qualifier("myCodeSystemDaoDstu3")
protected IFhirResourceDaoCodeSystem<CodeSystem, Coding, CodeableConcept> myCodeSystemDao;
@Autowired
@ -166,6 +156,9 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest {
@Autowired
protected FhirContext myFhirCtx;
@Autowired
@Qualifier("myGroupDaoDstu3")
protected IFhirResourceDao<Group> myGroupDao;
@Autowired
@Qualifier("myImmunizationDaoDstu3")
protected IFhirResourceDao<Immunization> myImmunizationDao;
@Autowired
@ -181,12 +174,12 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest {
@Qualifier("myMediaDaoDstu3")
protected IFhirResourceDao<Media> myMediaDao;
@Autowired
@Qualifier("myMedicationDaoDstu3")
protected IFhirResourceDao<Medication> myMedicationDao;
@Autowired
@Qualifier("myMedicationAdministrationDaoDstu3")
protected IFhirResourceDao<MedicationAdministration> myMedicationAdministrationDao;
@Autowired
@Qualifier("myMedicationDaoDstu3")
protected IFhirResourceDao<Medication> myMedicationDao;
@Autowired
@Qualifier("myMedicationRequestDaoDstu3")
protected IFhirResourceDao<MedicationRequest> myMedicationRequestDao;
@Autowired
@ -202,15 +195,15 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest {
@Qualifier("myOrganizationDaoDstu3")
protected IFhirResourceDao<Organization> myOrganizationDao;
@Autowired
@Qualifier("myTaskDaoDstu3")
protected IFhirResourceDao<Task> myTaskDao;
@Autowired
@Qualifier("myPatientDaoDstu3")
protected IFhirResourceDaoPatient<Patient> myPatientDao;
@Autowired
@Qualifier("myPractitionerDaoDstu3")
protected IFhirResourceDao<Practitioner> myPractitionerDao;
@Autowired
@Qualifier("myProcedureRequestDaoDstu3")
protected IFhirResourceDao<ProcedureRequest> myProcedureRequestDao;
@Autowired
@Qualifier("myQuestionnaireDaoDstu3")
protected IFhirResourceDao<Questionnaire> myQuestionnaireDao;
@Autowired
@ -222,8 +215,21 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest {
@Autowired
protected IResourceTableDao myResourceTableDao;
@Autowired
protected IResourceTagDao myResourceTagDao;
@Autowired
protected ISearchCoordinatorSvc mySearchCoordinatorSvc;
@Autowired
protected IFulltextSearchSvc mySearchDao;
@Autowired
protected ISearchDao mySearchEntityDao;
@Autowired
@Qualifier("mySearchParameterDaoDstu3")
protected IFhirResourceDao<SearchParameter> mySearchParameterDao;
@Autowired
protected ISearchParamPresenceSvc mySearchParamPresenceSvc;
@Autowired
protected ISearchParamRegistry mySearchParamRegsitry;
@Autowired
protected IStaleSearchDeletingSvc myStaleSearchDeletingSvc;
@Autowired
@Qualifier("myStructureDefinitionDaoDstu3")
@ -241,8 +247,15 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest {
@Qualifier("mySystemProviderDstu3")
protected JpaSystemProviderDstu3 mySystemProvider;
@Autowired
protected ITagDefinitionDao myTagDefinitionDao;
@Autowired
@Qualifier("myTaskDaoDstu3")
protected IFhirResourceDao<Task> myTaskDao;
@Autowired
protected IHapiTerminologySvc myTermSvc;
@Autowired
protected PlatformTransactionManager myTransactionMgr;
@Autowired
protected PlatformTransactionManager myTxManager;
@Autowired
@Qualifier("myJpaValidationSupportChainDstu3")
@ -250,18 +263,6 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest {
@Autowired
@Qualifier("myValueSetDaoDstu3")
protected IFhirResourceDaoValueSet<ValueSet, Coding, CodeableConcept> myValueSetDao;
@Autowired
protected PlatformTransactionManager myTransactionMgr;
@Autowired
protected ISearchParamPresenceSvc mySearchParamPresenceSvc;
@Autowired
protected ISearchCoordinatorSvc mySearchCoordinatorSvc;
@After()
public void afterGrabCaches() {
ourValueSetDao = myValueSetDao;
ourJpaValidationSupportChainDstu3 = myJpaValidationSupportChainDstu3;
}
@After()
public void afterCleanupDao() {
@ -271,6 +272,12 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest {
myDaoConfig.setSuppressUpdatesWithNoChange(new DaoConfig().isSuppressUpdatesWithNoChange());
}
@After()
public void afterGrabCaches() {
ourValueSetDao = myValueSetDao;
ourJpaValidationSupportChainDstu3 = myJpaValidationSupportChainDstu3;
}
@Before
public void beforeCreateInterceptor() {
myInterceptor = mock(IServerInterceptor.class);

View File

@ -43,6 +43,7 @@ import org.hl7.fhir.dstu3.model.Device;
import org.hl7.fhir.dstu3.model.DiagnosticReport;
import org.hl7.fhir.dstu3.model.Encounter;
import org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender;
import org.hl7.fhir.dstu3.model.Group;
import org.hl7.fhir.dstu3.model.IdType;
import org.hl7.fhir.dstu3.model.Immunization;
import org.hl7.fhir.dstu3.model.ImmunizationRecommendation;
@ -157,13 +158,65 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
public void testEmptyChain() {
SearchParameterMap map = new SearchParameterMap();
map.add(Encounter.SP_SUBJECT, new ReferenceAndListParam().addAnd(new ReferenceOrListParam().add((ReferenceParam)new ReferenceParam("subject", "04823543").setChain("identifier"))));
map.add(Encounter.SP_SUBJECT, new ReferenceAndListParam().addAnd(new ReferenceOrListParam().add(new ReferenceParam("subject", "04823543").setChain("identifier"))));
IBundleProvider results = myMedicationAdministrationDao.search(map);
List<String> ids = toUnqualifiedIdValues(results);
assertThat(ids, empty());
}
@Test
public void testChainWithMultipleTypePossibilities() {
Patient sub1 = new Patient();
sub1.setActive(true);
sub1.addIdentifier().setSystem("foo").setValue("bar");
String sub1Id = myPatientDao.create(sub1).getId().toUnqualifiedVersionless().getValue();
Group sub2 = new Group();
sub2.setActive(true);
sub2.addIdentifier().setSystem("foo").setValue("bar");
String sub2Id = myGroupDao.create(sub2).getId().toUnqualifiedVersionless().getValue();
Encounter enc1 = new Encounter();
enc1.getSubject().setReference(sub1Id);
String enc1Id = myEncounterDao.create(enc1).getId().toUnqualifiedVersionless().getValue();
Encounter enc2 = new Encounter();
enc2.getSubject().setReference(sub2Id);
String enc2Id = myEncounterDao.create(enc2).getId().toUnqualifiedVersionless().getValue();
List<String> ids;
SearchParameterMap map;
IBundleProvider results;
map = new SearchParameterMap();
map.add(Encounter.SP_SUBJECT, new ReferenceParam("subject", "foo|bar").setChain("identifier"));
results = myEncounterDao.search(map);
ids = toUnqualifiedVersionlessIdValues(results);
assertThat(ids, hasItems(enc1Id, enc2Id));
System.exit(0);
map = new SearchParameterMap();
map.add(Encounter.SP_SUBJECT, new ReferenceParam("subject:Patient", "foo|bar").setChain("identifier"));
results = myEncounterDao.search(map);
ids = toUnqualifiedVersionlessIdValues(results);
assertThat(ids, hasItems(enc1Id));
map = new SearchParameterMap();
map.add(Encounter.SP_SUBJECT, new ReferenceParam("subject:Group", "foo|bar").setChain("identifier"));
results = myEncounterDao.search(map);
ids = toUnqualifiedVersionlessIdValues(results);
assertThat(ids, hasItems(enc2Id));
map = new SearchParameterMap();
map.add(Encounter.SP_SUBJECT, new ReferenceParam("subject", "04823543").setChain("identifier"));
results = myEncounterDao.search(map);
ids = toUnqualifiedVersionlessIdValues(results);
assertThat(ids, empty());
}
@Test
public void testEverythingTimings() throws Exception {
String methodName = "testEverythingTimings";

View File

@ -45,7 +45,7 @@
Add configuration to JPA server DaoConfig that allows a maximum
number of search results to be specified. Queries will never return
more than this number, which can be good for avoiding accidental
performance problems in situations where lare queries should not be
performance problems in situations where large queries should not be
needed
</action>
<action type="fix" issue="674">