Test fix
This commit is contained in:
parent
7a7ab845a5
commit
4e78735cf9
|
@ -26,7 +26,6 @@ import org.hl7.fhir.r4.model.Reference;
|
|||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.mockito.Mockito;
|
||||
import org.slf4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
|
@ -37,13 +36,10 @@ import java.util.List;
|
|||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.slf4j.LoggerFactory.getLogger;
|
||||
|
||||
@ContextConfiguration(classes = {MdmHelperConfig.class})
|
||||
public class MdmSearchExpandingInterceptorIT extends BaseMdmR4Test {
|
||||
|
||||
private static final Logger ourLog = getLogger(MdmSearchExpandingInterceptorIT.class);
|
||||
|
||||
@RegisterExtension
|
||||
@Autowired
|
||||
public MdmHelperR4 myMdmHelper;
|
||||
|
@ -55,11 +51,10 @@ public class MdmSearchExpandingInterceptorIT extends BaseMdmR4Test {
|
|||
* <p>
|
||||
* Returns a list of stringified ids for the various resources.
|
||||
* <p>
|
||||
* Currently, order of returned resources is patientids first,
|
||||
* observation ids next. But this can be refined as needed.
|
||||
* Currently, order of returned resources is Patient IDs first,
|
||||
* Observation IDs next. But this can be refined as needed.
|
||||
*
|
||||
* @param theResourceCount - number of patients to create
|
||||
* @return
|
||||
*/
|
||||
private List<String> createAndLinkNewResources(int theResourceCount) throws InterruptedException {
|
||||
boolean expansion = myStorageSettings.isAllowMdmExpansion();
|
||||
|
@ -134,16 +129,16 @@ public class MdmSearchExpandingInterceptorIT extends BaseMdmR4Test {
|
|||
|
||||
//With MDM Expansion disabled, this should return 1 result.
|
||||
myStorageSettings.setAllowMdmExpansion(false);
|
||||
IBundleProvider search = myObservationDao.search(searchParameterMap);
|
||||
IBundleProvider search = myObservationDao.search(searchParameterMap, mySrd);
|
||||
assertEquals(1, search.size());
|
||||
|
||||
//Once MDM Expansion is allowed, this should now return 4 resourecs.
|
||||
//Once MDM Expansion is allowed, this should now return 4 resources.
|
||||
myStorageSettings.setAllowMdmExpansion(true);
|
||||
search = myObservationDao.search(searchParameterMap);
|
||||
search = myObservationDao.search(searchParameterMap, mySrd);
|
||||
assertEquals(4, search.size());
|
||||
List<MdmLink> all = myMdmLinkDao.findAll();
|
||||
Long goldenPid = all.get(0).getGoldenResourcePid();
|
||||
IIdType goldenId = myIdHelperService.translatePidIdToForcedId(myFhirContext, "Patient", JpaPid.fromId(goldenPid));
|
||||
JpaPid goldenPid = all.get(0).getGoldenResourcePersistenceId();
|
||||
IIdType goldenId = myIdHelperService.translatePidIdToForcedId(myFhirContext, "Patient", goldenPid);
|
||||
//Verify that expansion by the golden resource id resolves down to everything its links have.
|
||||
|
||||
SearchParameterMap goldenSpMap = new SearchParameterMap();
|
||||
|
@ -152,7 +147,7 @@ public class MdmSearchExpandingInterceptorIT extends BaseMdmR4Test {
|
|||
goldenReferenceOrListParam.addOr(new ReferenceParam(goldenId).setMdmExpand(true));
|
||||
goldenSpMap.add(Observation.SP_SUBJECT, goldenReferenceOrListParam);
|
||||
|
||||
search = myObservationDao.search(goldenSpMap);
|
||||
search = myObservationDao.search(goldenSpMap, mySrd);
|
||||
assertEquals(resourceCount, search.size());
|
||||
}
|
||||
|
||||
|
@ -170,16 +165,16 @@ public class MdmSearchExpandingInterceptorIT extends BaseMdmR4Test {
|
|||
|
||||
//With MDM Expansion disabled, this should return 1 result.
|
||||
myStorageSettings.setAllowMdmExpansion(false);
|
||||
IBundleProvider search = myObservationDao.search(searchParameterMap);
|
||||
IBundleProvider search = myObservationDao.search(searchParameterMap, mySrd);
|
||||
assertEquals(1, search.size());
|
||||
|
||||
//Once MDM Expansion is allowed, this should now return 4 resourecs.
|
||||
//Once MDM Expansion is allowed, this should now return 4 resources.
|
||||
myStorageSettings.setAllowMdmExpansion(true);
|
||||
search = myObservationDao.search(searchParameterMap);
|
||||
search = myObservationDao.search(searchParameterMap, mySrd);
|
||||
assertEquals(4, search.size());
|
||||
List<MdmLink> all = myMdmLinkDao.findAll();
|
||||
Long goldenPid = all.get(0).getGoldenResourcePid();
|
||||
IIdType goldenId = myIdHelperService.translatePidIdToForcedId(myFhirContext, "Patient", JpaPid.fromId(goldenPid));
|
||||
JpaPid goldenPid = all.get(0).getGoldenResourcePersistenceId();
|
||||
IIdType goldenId = myIdHelperService.translatePidIdToForcedId(myFhirContext, "Patient", goldenPid);
|
||||
//Verify that expansion by the golden resource id resolves down to everything its links have.
|
||||
|
||||
SearchParameterMap goldenSpMap = new SearchParameterMap();
|
||||
|
@ -188,7 +183,7 @@ public class MdmSearchExpandingInterceptorIT extends BaseMdmR4Test {
|
|||
goldenReferenceOrListParam.addOr(new ReferenceParam(goldenId).setMdmExpand(true));
|
||||
goldenSpMap.add(Observation.SP_SUBJECT, goldenReferenceOrListParam);
|
||||
|
||||
search = myObservationDao.search(goldenSpMap);
|
||||
search = myObservationDao.search(goldenSpMap, mySrd);
|
||||
assertEquals(resourceCount, search.size());
|
||||
}
|
||||
|
||||
|
@ -208,7 +203,7 @@ public class MdmSearchExpandingInterceptorIT extends BaseMdmR4Test {
|
|||
orListParam.add(patientIdParam);
|
||||
map.add("_id", orListParam);
|
||||
|
||||
IBundleProvider outcome = myPatientDao.search(map);
|
||||
IBundleProvider outcome = myPatientDao.search(map, mySrd);
|
||||
|
||||
assertNotNull(outcome);
|
||||
// we know 4 cause that's how many patients are created
|
||||
|
@ -267,7 +262,7 @@ public class MdmSearchExpandingInterceptorIT extends BaseMdmR4Test {
|
|||
//Even though the user has NO mdm links, that should not cause a request failure.
|
||||
SearchParameterMap map = new SearchParameterMap();
|
||||
map.add(Observation.SP_SUBJECT, new ReferenceParam("Patient/" + id).setMdmExpand(true));
|
||||
IBundleProvider search = myObservationDao.search(map);
|
||||
IBundleProvider search = myObservationDao.search(map, mySrd);
|
||||
assertEquals(1, search.size());
|
||||
}
|
||||
|
||||
|
@ -275,7 +270,7 @@ public class MdmSearchExpandingInterceptorIT extends BaseMdmR4Test {
|
|||
Observation observation = new Observation();
|
||||
observation.setSubject(new Reference("Patient/" + thePatientId));
|
||||
observation.setCode(new CodeableConcept().setText("Made for Patient/" + thePatientId));
|
||||
DaoMethodOutcome daoMethodOutcome = myObservationDao.create(observation);
|
||||
DaoMethodOutcome daoMethodOutcome = myObservationDao.create(observation, mySrd);
|
||||
return (Observation) daoMethodOutcome.getResource();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -185,7 +185,11 @@ public class MdmReadVirtualizationInterceptor<P extends IResourcePersistentId<?>
|
|||
&& !referenceId.isUuid()) {
|
||||
Optional<IIdType> nonExpandedId = expansionResults.getOriginalIdForExpandedId(referenceId);
|
||||
if (nonExpandedId != null && nonExpandedId.isPresent()) {
|
||||
ourLog.debug("Replacing reference at {} value {} with {}", referenceInfo.getName(), referenceInfo.getResourceReference().getReferenceElement(), nonExpandedId.get().getValue());
|
||||
ourLog.debug(
|
||||
"Replacing reference at {} value {} with {}",
|
||||
referenceInfo.getName(),
|
||||
referenceInfo.getResourceReference().getReferenceElement(),
|
||||
nonExpandedId.get().getValue());
|
||||
referenceInfo
|
||||
.getResourceReference()
|
||||
.setReference(nonExpandedId.get().getValue());
|
||||
|
|
Loading…
Reference in New Issue