[Bugfix] mdm pointcut missing link update (#6296)
* add failing test * add side-effect link updates to link event * add to contributor list
This commit is contained in:
parent
43e28da0c5
commit
32651e1c36
|
@ -188,6 +188,12 @@ public class MdmLinkUpdaterSvcImpl implements IMdmLinkUpdaterSvc {
|
|||
// pointcut for MDM_POST_UPDATE_LINK
|
||||
MdmLinkEvent event = new MdmLinkEvent();
|
||||
event.addMdmLink(myModelConverter.toJson(mdmLink));
|
||||
|
||||
// add any link updates from side effects
|
||||
mdmContext.getMdmLinks().stream().forEach(link -> {
|
||||
event.addMdmLink(myModelConverter.toJson(link));
|
||||
});
|
||||
|
||||
HookParams hookParams = new HookParams();
|
||||
hookParams.add(RequestDetails.class, theParams.getRequestDetails()).add(MdmLinkEvent.class, event);
|
||||
myInterceptorBroadcaster.callHooks(Pointcut.MDM_POST_UPDATE_LINK, hookParams);
|
||||
|
|
|
@ -601,5 +601,55 @@ public class MdmOperationPointcutsIT extends BaseProviderR4Test {
|
|||
assertFalse(retval.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateLink_NoMatch_LinkEvent_allUpdates() {
|
||||
// When a Link is set to "NO_MATCH", it can cause other link updates.
|
||||
// If a source record would be left unlinked to any
|
||||
// golden record, a new link / golden record would be created.
|
||||
|
||||
// setup
|
||||
String inputState = """
|
||||
GP1, AUTO, MATCH, P1
|
||||
""";
|
||||
MDMState<Patient, JpaPid> state = new MDMState<>();
|
||||
state.setInputState(inputState);
|
||||
|
||||
// we won't use for validation, just setup
|
||||
myMdmLinkHelper.setup(state);
|
||||
|
||||
Patient patient = state.getParameter("P1");
|
||||
Patient originalPatientGolden = state.getParameter("GP1");
|
||||
|
||||
AtomicBoolean called = new AtomicBoolean(false);
|
||||
|
||||
Object interceptor = new Object() {
|
||||
@Hook(Pointcut.MDM_POST_UPDATE_LINK)
|
||||
void onUpdate(RequestDetails theDetails, MdmLinkEvent theEvent) {
|
||||
called.getAndSet(true);
|
||||
assertThat(theEvent.getMdmLinks()).hasSize(2);
|
||||
|
||||
MdmLinkJson originalLink = theEvent.getMdmLinks().get(0);
|
||||
MdmLinkJson newLink = theEvent.getMdmLinks().get(1);
|
||||
String original_target = "Patient/" + originalPatientGolden.getIdPart();
|
||||
|
||||
assertThat(originalLink.getGoldenResourceId()).isEqualTo(original_target);
|
||||
assertThat(newLink.getGoldenResourceId()).isNotEqualTo(original_target);
|
||||
}
|
||||
};
|
||||
myInterceptors.add(interceptor);
|
||||
myInterceptorService.registerInterceptor(interceptor);
|
||||
|
||||
// test
|
||||
myMdmProvider.updateLink(
|
||||
new StringType("Patient/" + originalPatientGolden.getIdPart()),
|
||||
new StringType("Patient/" + patient.getIdPart()),
|
||||
new StringType("NO_MATCH"),
|
||||
new ServletRequestDetails()
|
||||
);
|
||||
|
||||
// verify
|
||||
assertTrue(called.get());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
5
pom.xml
5
pom.xml
|
@ -921,6 +921,11 @@
|
|||
<name>Adrienne Sox</name>
|
||||
<organization>Galileo, Inc.</organization>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>Jake-Gillberg</id>
|
||||
<name>Jake Gillberg</name>
|
||||
<organization>Galileo, Inc.</organization>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>melihaydogd</id>
|
||||
<name>Ahmet Melih Aydoğdu</name>
|
||||
|
|
Loading…
Reference in New Issue