Adding tests

This commit is contained in:
Nick Goupinets 2021-07-30 11:17:56 -04:00
parent a2aa2ca1c3
commit 0d34fe61c8
3 changed files with 51 additions and 2 deletions

View File

@ -111,6 +111,7 @@ public class MdmMessageHandler implements MessageHandler {
IBaseResource targetResource = theMsg.getPayload(myFhirContext);
ResourceOperationMessage outgoingMsg = new ResourceOperationMessage(myFhirContext, targetResource, theMsg.getOperationType());
outgoingMsg.setTransactionId(theMsg.getTransactionId());
mdmContext.getMdmLinkChangeEvent().setTargetResourceId(targetResource);
HookParams params = new HookParams()
.add(ResourceOperationMessage.class, outgoingMsg)

View File

@ -91,6 +91,42 @@ public class MdmStorageInterceptorIT extends BaseMdmR4Test {
MdmLinkChangeEvent linkChangeEvent = myMdmHelper.getAfterMdmLatch().getLatchInvocationParameterOfType(MdmLinkChangeEvent.class);
assertNotNull(linkChangeEvent);
assertEquals(link.getGoldenResourcePid(), new IdDt(linkChangeEvent.getGoldenResourceId()).getIdPartAsLong());
assertEquals(link.getSourcePid(), new IdDt(linkChangeEvent.getTargetResourceId()).getIdPartAsLong());
}
@Test
public void testUpdateLinkChangeEvent() throws InterruptedException {
Patient patient1 = addExternalEID(buildJanePatient(), "eid-1");
patient1 = createPatientAndUpdateLinks(patient1);
Patient patient2 = addExternalEID(buildJanePatient(), "eid-2");
patient2 = createPatientAndUpdateLinks(patient2);
MdmLinkChangeEvent linkChangeEvent = myMdmHelper.getAfterMdmLatch().getLatchInvocationParameterOfType(MdmLinkChangeEvent.class);
assertNotNull(linkChangeEvent);
// assertEquals(link.getGoldenResourcePid(), new IdDt(linkChangeEvent.getGoldenResourceId()).getIdPartAsLong());
// assertEquals(link.getSourcePid(), new IdDt(linkChangeEvent.getTargetResourceId()).getIdPartAsLong());
}
@Test
public void testDuplicateLinkChangeEvent() throws InterruptedException {
fail();
Practitioner pr = buildPractitionerWithNameAndId("Young", "AC-DC");
myMdmHelper.createWithLatch(pr);
ResourceOperationMessage resourceOperationMessage = myMdmHelper.getAfterMdmLatch().getLatchInvocationParameterOfType(ResourceOperationMessage.class);
assertNotNull(resourceOperationMessage);
assertEquals(pr.getId(), resourceOperationMessage.getId());
MdmLink example = new MdmLink();
example.setSourcePid(pr.getIdElement().getIdPartAsLong());
MdmLink link = myMdmLinkDao.findAll(Example.of(example)).get(0);
MdmLinkChangeEvent linkChangeEvent = myMdmHelper.getAfterMdmLatch().getLatchInvocationParameterOfType(MdmLinkChangeEvent.class);
assertNotNull(linkChangeEvent);
assertEquals(link.getGoldenResourcePid(), new IdDt(linkChangeEvent.getGoldenResourceId()).getIdPartAsLong());
assertEquals(link.getSourcePid(), new IdDt(linkChangeEvent.getTargetResourceId()).getIdPartAsLong());
}
@Test

View File

@ -1,15 +1,15 @@
package ca.uhn.fhir.mdm.api;
import org.hl7.fhir.instance.model.api.IBase;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class MdmLinkChangeEvent {
private String myTargetResourceId;
private String myGoldenResourceId;
private Set<String> myDuplicateGoldenResourceIds = new HashSet<>();
@ -36,6 +36,18 @@ public class MdmLinkChangeEvent {
return idElement.getValueAsString();
}
public String getTargetResourceId() {
return myTargetResourceId;
}
public void setTargetResourceId(IBaseResource theTargetResource) {
setTargetResourceId(getIdAsString(theTargetResource));
}
public void setTargetResourceId(String theTargetResourceId) {
myTargetResourceId = theTargetResourceId;
}
public Set<String> getDuplicateGoldenResourceIds() {
return myDuplicateGoldenResourceIds;
}