Connection handling cleanup for new tests

This commit is contained in:
James Agnew 2017-08-02 10:42:04 -04:00
parent 0e2cecfbd0
commit a4cbda357e
2 changed files with 76 additions and 65 deletions

View File

@ -60,7 +60,7 @@ public class FhirResourceDaoSearchParameterR4 extends FhirResourceDaoR4<SearchPa
ourLog.info("Marking all resources of type {} for reindexing due to updated search parameter with path: {}", expression); ourLog.info("Marking all resources of type {} for reindexing due to updated search parameter with path: {}", expression);
TransactionTemplate txTemplate = new TransactionTemplate(myPlatformTransactionManager); TransactionTemplate txTemplate = new TransactionTemplate(myPlatformTransactionManager);
txTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); txTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
int updatedCount = txTemplate.execute(new TransactionCallback<Integer>() { int updatedCount = txTemplate.execute(new TransactionCallback<Integer>() {
@Override @Override
public Integer doInTransaction(TransactionStatus theStatus) { public Integer doInTransaction(TransactionStatus theStatus) {

View File

@ -10,6 +10,8 @@ import org.hl7.fhir.r4.model.Appointment.AppointmentStatus;
import org.hl7.fhir.r4.model.Enumerations.AdministrativeGender; import org.hl7.fhir.r4.model.Enumerations.AdministrativeGender;
import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.instance.model.api.IIdType;
import org.junit.*; import org.junit.*;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.*;
import ca.uhn.fhir.jpa.dao.SearchParameterMap; import ca.uhn.fhir.jpa.dao.SearchParameterMap;
import ca.uhn.fhir.model.api.Include; import ca.uhn.fhir.model.api.Include;
@ -207,8 +209,8 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test
Patient patient = new Patient(); Patient patient = new Patient();
patient.addName().setFamily("P2"); patient.addName().setFamily("P2");
Extension extParent = patient Extension extParent = patient
.addExtension() .addExtension()
.setUrl("http://acme.org/foo"); .setUrl("http://acme.org/foo");
extParent extParent
.addExtension() .addExtension()
.setUrl("http://acme.org/bar") .setUrl("http://acme.org/bar")
@ -245,8 +247,8 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test
Patient patient = new Patient(); Patient patient = new Patient();
patient.addName().setFamily("P2"); patient.addName().setFamily("P2");
Extension extParent = patient Extension extParent = patient
.addExtension() .addExtension()
.setUrl("http://acme.org/foo"); .setUrl("http://acme.org/foo");
extParent extParent
.addExtension() .addExtension()
.setUrl("http://acme.org/bar") .setUrl("http://acme.org/bar")
@ -287,8 +289,8 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test
Patient patient = new Patient(); Patient patient = new Patient();
patient.addName().setFamily("P2"); patient.addName().setFamily("P2");
Extension extParent = patient Extension extParent = patient
.addExtension() .addExtension()
.setUrl("http://acme.org/foo"); .setUrl("http://acme.org/foo");
extParent extParent
.addExtension() .addExtension()
@ -329,8 +331,8 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test
Patient patient = new Patient(); Patient patient = new Patient();
patient.addName().setFamily("P2"); patient.addName().setFamily("P2");
Extension extParent = patient Extension extParent = patient
.addExtension() .addExtension()
.setUrl("http://acme.org/foo"); .setUrl("http://acme.org/foo");
extParent extParent
.addExtension() .addExtension()
@ -372,8 +374,8 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test
Patient patient = new Patient(); Patient patient = new Patient();
patient.addName().setFamily("P2"); patient.addName().setFamily("P2");
Extension extParent = patient Extension extParent = patient
.addExtension() .addExtension()
.setUrl("http://acme.org/foo"); .setUrl("http://acme.org/foo");
extParent extParent
.addExtension() .addExtension()
@ -414,8 +416,8 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test
Patient patient = new Patient(); Patient patient = new Patient();
patient.addName().setFamily("P2"); patient.addName().setFamily("P2");
Extension extParent = patient Extension extParent = patient
.addExtension() .addExtension()
.setUrl("http://acme.org/foo"); .setUrl("http://acme.org/foo");
extParent extParent
.addExtension() .addExtension()
@ -452,8 +454,8 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test
Patient patient = new Patient(); Patient patient = new Patient();
patient.addName().setFamily("P2"); patient.addName().setFamily("P2");
Extension extParent = patient Extension extParent = patient
.addExtension() .addExtension()
.setUrl("http://acme.org/foo"); .setUrl("http://acme.org/foo");
extParent extParent
.addExtension() .addExtension()
.setUrl("http://acme.org/bar") .setUrl("http://acme.org/bar")
@ -474,7 +476,7 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test
@Test @Test
public void testSearchForExtensionTwoDeepDecimal() { public void testSearchForExtensionTwoDeepDecimal() {
SearchParameter siblingSp = new SearchParameter(); final SearchParameter siblingSp = new SearchParameter();
siblingSp.addBase("Patient"); siblingSp.addBase("Patient");
siblingSp.setCode("foobar"); siblingSp.setCode("foobar");
siblingSp.setType(org.hl7.fhir.r4.model.Enumerations.SearchParamType.NUMBER); siblingSp.setType(org.hl7.fhir.r4.model.Enumerations.SearchParamType.NUMBER);
@ -482,21 +484,33 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test
siblingSp.setExpression("Patient.extension('http://acme.org/foo').extension('http://acme.org/bar')"); siblingSp.setExpression("Patient.extension('http://acme.org/foo').extension('http://acme.org/bar')");
siblingSp.setXpathUsage(org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NORMAL); siblingSp.setXpathUsage(org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NORMAL);
siblingSp.setStatus(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE); siblingSp.setStatus(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE);
mySearchParameterDao.create(siblingSp, mySrd);
mySearchParamRegsitry.forceRefresh(); TransactionTemplate txTemplate = new TransactionTemplate(myTxManager);
txTemplate.setPropagationBehavior(TransactionTemplate.PROPAGATION_REQUIRES_NEW);
txTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus theArg0) {
mySearchParameterDao.create(siblingSp, mySrd);
mySearchParamRegsitry.forceRefresh();
}
});
Patient patient = new Patient(); final Patient patient = new Patient();
patient.addName().setFamily("P2"); patient.addName().setFamily("P2");
Extension extParent = patient Extension extParent = patient
.addExtension() .addExtension()
.setUrl("http://acme.org/foo"); .setUrl("http://acme.org/foo");
extParent extParent
.addExtension() .addExtension()
.setUrl("http://acme.org/bar") .setUrl("http://acme.org/bar")
.setValue(new DecimalType("2.1")); .setValue(new DecimalType("2.1"));
IIdType p2id = myPatientDao.create(patient).getId().toUnqualifiedVersionless(); IIdType p2id = txTemplate.execute(new TransactionCallback<IIdType>() {
@Override
public IIdType doInTransaction(TransactionStatus theArg0) {
return myPatientDao.create(patient).getId().toUnqualifiedVersionless();
}
});
SearchParameterMap map; SearchParameterMap map;
IBundleProvider results; IBundleProvider results;
@ -526,8 +540,8 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test
Patient patient = new Patient(); Patient patient = new Patient();
patient.addName().setFamily("P2"); patient.addName().setFamily("P2");
Extension extParent = patient Extension extParent = patient
.addExtension() .addExtension()
.setUrl("http://acme.org/foo"); .setUrl("http://acme.org/foo");
extParent extParent
.addExtension() .addExtension()
.setUrl("http://acme.org/bar") .setUrl("http://acme.org/bar")
@ -590,8 +604,6 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test
} }
@Test @Test
public void testSearchForExtensionReferenceWithoutTarget() { public void testSearchForExtensionReferenceWithoutTarget() {
SearchParameter siblingSp = new SearchParameter(); SearchParameter siblingSp = new SearchParameter();
@ -644,7 +656,6 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test
foundResources = toUnqualifiedVersionlessIdValues(results); foundResources = toUnqualifiedVersionlessIdValues(results);
assertThat(foundResources, containsInAnyOrder(appid.getValue())); assertThat(foundResources, containsInAnyOrder(appid.getValue()));
} }
@Test @Test