Skip to content

Commit

Permalink
fixed bug in survivorship rebuilding service (hapifhir#5995)
Browse files Browse the repository at this point in the history
Co-authored-by: leif stawnyczy <[email protected]>
  • Loading branch information
TipzCM and leif stawnyczy authored Jun 10, 2024
1 parent 4321670 commit 488bf6f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
type: fix
issue: 5994
title: "Fixed a bug in the MdmSurvivorshipSvcImpl that caused resourceType/id
(as opposed to just id) to be passed on to the IIdHelperService.
"
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.Spy;
import org.mockito.junit.jupiter.MockitoExtension;
Expand All @@ -43,11 +44,13 @@
import java.util.concurrent.atomic.AtomicInteger;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
Expand Down Expand Up @@ -195,6 +198,15 @@ public void rebuildGoldenResourceCurrentLinksUsingSurvivorshipRules_withManyLink

verify(resourceDao)
.update(eq(goldenPatientRebuilt), any(RequestDetails.class));

ArgumentCaptor<List<String>> idsCaptor = ArgumentCaptor.forClass(List.class);
verify(myIIdHelperService).resolveResourcePersistentIds(any(RequestPartitionId.class), anyString(), idsCaptor.capture());
assertNotNull(idsCaptor.getValue());
assertFalse(idsCaptor.getValue().isEmpty());
for (String id : idsCaptor.getValue()) {
assertFalse(id.contains("/"));
assertFalse(id.contains("Patient"));
}
}

private MdmTransactionContext createTransactionContext() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ private Stream<IBaseResource> getMatchedSourceIdsByLinkUpdateDate(
// we want it ordered
List<String> sourceIds = new ArrayList<>();
linksQuery.forEach(link -> {
sourceIds.add(link.getSourceId());
String sourceId = link.getSourceId();
// we want only the id part, not the resource type
sourceId = sourceId.replace(resourceType + "/", "");
sourceIds.add(sourceId);
});
Map<String, IResourcePersistentId> sourceIdToPid = new HashMap<>();
if (!sourceIds.isEmpty()) {
Expand Down

0 comments on commit 488bf6f

Please sign in to comment.