Skip to content

Commit

Permalink
fix: Return PAs when TE found [DHIS2-14300][2.40] (dhis2#17954) (dhis…
Browse files Browse the repository at this point in the history
…2#17968)

* fix: Return PA when TE found [DHIS2-14300][2.40]

* fix: Return PA when TE found [DHIS2-14300][2.39]
  • Loading branch information
muilpp authored Jul 3, 2024
1 parent d72b656 commit 57ac524
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public TrackedEntityInstance getTrackedEntityInstance(
}

Set<TrackedEntityAttribute> readableAttributes =
new HashSet<>(daoTrackedEntityInstance.getTrackedEntityType().getTrackedEntityAttributes());
trackedEntityAttributeService.getAllUserReadableTrackedEntityAttributes(user);

return getTei(daoTrackedEntityInstance, readableAttributes, params, user, null);
}
Expand All @@ -305,7 +305,7 @@ public TrackedEntityInstance getTrackedEntityInstanceExcludingACL(
User user = currentUserService.getCurrentUser();

Set<TrackedEntityAttribute> readableAttributes =
new HashSet<>(daoTrackedEntityInstance.getTrackedEntityType().getTrackedEntityAttributes());
trackedEntityAttributeService.getAllUserReadableTrackedEntityAttributes(user);
readableAttributes.addAll(program.getTrackedEntityAttributes());

return getTei(daoTrackedEntityInstance, readableAttributes, params, user, program);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -837,27 +837,13 @@ void shouldReturnTrackedEntityTypeAndProgramAttributesWhenSingleTERequestedAndPr
.collect(Collectors.toList()));
}

@Test
void
shouldReturnTrackedEntityTypeAttributesWhenSingleTERequestedAndProgramSpecifiedButItHasNoProgramAttributes() {
TrackedEntityInstance trackedEntityInstance =
trackedEntityInstanceService.getTrackedEntityInstanceExcludingACL(
maleA.getUid(), new Program(), TrackedEntityInstanceParams.TRUE);

assertContainsOnly(
List.of(uniqueIdAttribute.getUid()),
trackedEntityInstance.getAttributes().stream()
.map(Attribute::getAttribute)
.collect(Collectors.toList()));
}

@Test
void shouldReturnTrackedEntityTypeAttributesWhenSingleTERequestedAndNoProgramSpecified() {
TrackedEntityInstance trackedEntityInstance =
trackedEntityInstanceService.getTrackedEntityInstance(maleA);

assertContainsOnly(
List.of(uniqueIdAttribute.getUid()),
List.of(programAttribute.getUid(), uniqueIdAttribute.getUid()),
trackedEntityInstance.getAttributes().stream()
.map(Attribute::getAttribute)
.collect(Collectors.toList()));
Expand Down

0 comments on commit 57ac524

Please sign in to comment.