fix empi tests so they work with Spring Batch
(all but one test fixed)
This commit is contained in:
parent
e51c5b5263
commit
93da042d19
|
@ -52,6 +52,7 @@ public class EmpiLinkDaoSvc {
|
||||||
@Autowired
|
@Autowired
|
||||||
private IdHelperService myIdHelperService;
|
private IdHelperService myIdHelperService;
|
||||||
|
|
||||||
|
@Transactional
|
||||||
public EmpiLink createOrUpdateLinkEntity(IBaseResource thePerson, IBaseResource theTarget, EmpiMatchResultEnum theMatchResult, EmpiLinkSourceEnum theLinkSource, @Nullable EmpiTransactionContext theEmpiTransactionContext) {
|
public EmpiLink createOrUpdateLinkEntity(IBaseResource thePerson, IBaseResource theTarget, EmpiMatchResultEnum theMatchResult, EmpiLinkSourceEnum theLinkSource, @Nullable EmpiTransactionContext theEmpiTransactionContext) {
|
||||||
Long personPid = myIdHelperService.getPidOrNull(thePerson);
|
Long personPid = myIdHelperService.getPidOrNull(thePerson);
|
||||||
Long resourcePid = myIdHelperService.getPidOrNull(theTarget);
|
Long resourcePid = myIdHelperService.getPidOrNull(theTarget);
|
||||||
|
|
|
@ -48,8 +48,11 @@ import org.slf4j.Logger;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
import org.springframework.transaction.PlatformTransactionManager;
|
||||||
|
import org.springframework.transaction.support.TransactionTemplate;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -99,16 +102,32 @@ abstract public class BaseEmpiR4Test extends BaseJpaR4Test {
|
||||||
EmpiSearchParameterLoader myEmpiSearchParameterLoader;
|
EmpiSearchParameterLoader myEmpiSearchParameterLoader;
|
||||||
@Autowired
|
@Autowired
|
||||||
SearchParamRegistryImpl mySearchParamRegistry;
|
SearchParamRegistryImpl mySearchParamRegistry;
|
||||||
|
@Autowired
|
||||||
|
private PlatformTransactionManager myPlatformTransactionManager;
|
||||||
|
|
||||||
|
private TransactionTemplate myTxTemplate;
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void initTxTemplate() {
|
||||||
|
myTxTemplate = new TransactionTemplate(myPlatformTransactionManager);
|
||||||
|
}
|
||||||
|
|
||||||
protected ServletRequestDetails myRequestDetails = new ServletRequestDetails(null);
|
protected ServletRequestDetails myRequestDetails = new ServletRequestDetails(null);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@After
|
@After
|
||||||
public void after() {
|
public void after() {
|
||||||
myEmpiLinkDao.deleteAll();
|
// TODO KHS Why does adding Spring Batch now require us to wrap this in a transaction?
|
||||||
|
myTxTemplate.executeWithoutResult(t -> myEmpiLinkDao.deleteAll());
|
||||||
|
assertEquals(0, myEmpiLinkDao.count());
|
||||||
super.after();
|
super.after();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO KHS Why does adding Spring Batch now require us to wrap this in a transaction?
|
||||||
|
protected void saveLink(EmpiLink theNoMatchLink) {
|
||||||
|
myTxTemplate.executeWithoutResult(t -> myEmpiLinkDaoSvc.save(theNoMatchLink));
|
||||||
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
protected Person createUnmanagedPerson() {
|
protected Person createUnmanagedPerson() {
|
||||||
return createPerson(new Person(), false);
|
return createPerson(new Person(), false);
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class EmpiExpungeTest extends BaseEmpiR4Test {
|
||||||
empiLink.setMatchResult(EmpiMatchResultEnum.MATCH);
|
empiLink.setMatchResult(EmpiMatchResultEnum.MATCH);
|
||||||
empiLink.setPersonPid(myPersonEntity.getId());
|
empiLink.setPersonPid(myPersonEntity.getId());
|
||||||
empiLink.setTargetPid(myTargetEntity.getId());
|
empiLink.setTargetPid(myTargetEntity.getId());
|
||||||
myEmpiLinkDaoSvc.save(empiLink);
|
saveLink(empiLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -41,7 +41,7 @@ public abstract class BaseLinkR4Test extends BaseProviderR4Test {
|
||||||
myLink = getOnlyPatientLink();
|
myLink = getOnlyPatientLink();
|
||||||
// Tests require our initial link to be a POSSIBLE_MATCH
|
// Tests require our initial link to be a POSSIBLE_MATCH
|
||||||
myLink.setMatchResult(EmpiMatchResultEnum.POSSIBLE_MATCH);
|
myLink.setMatchResult(EmpiMatchResultEnum.POSSIBLE_MATCH);
|
||||||
myEmpiLinkDao.save(myLink);
|
saveLink(myLink);
|
||||||
assertEquals(EmpiLinkSourceEnum.AUTO, myLink.getLinkSource());
|
assertEquals(EmpiLinkSourceEnum.AUTO, myLink.getLinkSource());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class EmpiProviderQueryLinkR4Test extends BaseLinkR4Test {
|
||||||
myPerson2Id = new StringType(person2.getIdElement().toVersionless().getValue());
|
myPerson2Id = new StringType(person2.getIdElement().toVersionless().getValue());
|
||||||
Long person2Pid = myIdHelperService.getPidOrNull(person2);
|
Long person2Pid = myIdHelperService.getPidOrNull(person2);
|
||||||
EmpiLink possibleDuplicateEmpiLink = new EmpiLink().setPersonPid(person1Pid).setTargetPid(person2Pid).setMatchResult(EmpiMatchResultEnum.POSSIBLE_DUPLICATE).setLinkSource(EmpiLinkSourceEnum.AUTO);
|
EmpiLink possibleDuplicateEmpiLink = new EmpiLink().setPersonPid(person1Pid).setTargetPid(person2Pid).setMatchResult(EmpiMatchResultEnum.POSSIBLE_DUPLICATE).setLinkSource(EmpiLinkSourceEnum.AUTO);
|
||||||
myEmpiLinkDaoSvc.save(possibleDuplicateEmpiLink);
|
saveLink(possibleDuplicateEmpiLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -116,7 +116,7 @@ public class EmpiLinkSvcTest extends BaseEmpiR4Test {
|
||||||
.setTargetPid(theTargetPid)
|
.setTargetPid(theTargetPid)
|
||||||
.setLinkSource(EmpiLinkSourceEnum.MANUAL)
|
.setLinkSource(EmpiLinkSourceEnum.MANUAL)
|
||||||
.setMatchResult(EmpiMatchResultEnum.NO_MATCH);
|
.setMatchResult(EmpiMatchResultEnum.NO_MATCH);
|
||||||
myEmpiLinkDaoSvc.save(noMatchLink);
|
saveLink(noMatchLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -164,7 +164,7 @@ public class EmpiPersonMergerSvcTest extends BaseEmpiR4Test {
|
||||||
EmpiLink fromLink = createEmpiLink(myFromPerson, myTargetPatient1);
|
EmpiLink fromLink = createEmpiLink(myFromPerson, myTargetPatient1);
|
||||||
fromLink.setLinkSource(EmpiLinkSourceEnum.MANUAL);
|
fromLink.setLinkSource(EmpiLinkSourceEnum.MANUAL);
|
||||||
fromLink.setMatchResult(EmpiMatchResultEnum.MATCH);
|
fromLink.setMatchResult(EmpiMatchResultEnum.MATCH);
|
||||||
myEmpiLinkDaoSvc.save(fromLink);
|
saveLink(fromLink);
|
||||||
|
|
||||||
createEmpiLink(myToPerson, myTargetPatient1);
|
createEmpiLink(myToPerson, myTargetPatient1);
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ public class EmpiPersonMergerSvcTest extends BaseEmpiR4Test {
|
||||||
EmpiLink toLink = createEmpiLink(myToPerson, myTargetPatient1);
|
EmpiLink toLink = createEmpiLink(myToPerson, myTargetPatient1);
|
||||||
toLink.setLinkSource(EmpiLinkSourceEnum.MANUAL);
|
toLink.setLinkSource(EmpiLinkSourceEnum.MANUAL);
|
||||||
toLink.setMatchResult(EmpiMatchResultEnum.MATCH);
|
toLink.setMatchResult(EmpiMatchResultEnum.MATCH);
|
||||||
myEmpiLinkDaoSvc.save(toLink);
|
saveLink(toLink);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mergePersons();
|
mergePersons();
|
||||||
|
|
Loading…
Reference in New Issue