Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: simplify TrackedEntityService.getTrackedEntity(UID, ...) logic DHIS2-18541 #19633

Merged
merged 1 commit into from
Jan 13, 2025

Conversation

teleivo
Copy link
Contributor

@teleivo teleivo commented Jan 10, 2025

This change is necessary for #19377 and should make changes in behavior easier to see/discuss.

We have two methods for getting a single TE. They were implemented independently with convoluted logic. Let one reuse the other. Separate fetching, ACL, mapping to make the flow easier to follow. Move the TETAV logic in one place. This is the only way we can ensure the behavior is the same across different code paths.

Add an assertContainsOnly variant that lets us map both collection before making the actual assertion. This makes the assertion error easier to read.

assertContainsOnly(
    Set.of(tetavA, tetavB),
    trackedEntity.getTrackedEntityAttributeValues(),
    TrackedEntityAttributeValue::getValue);

gives you

org.opentest4j.AssertionFailedError: Expected [C] NOT to be in [A, B, C] ==> 
Expected :true
Actual   :false

instead of a giant output with most fields being equal and or irrelevant.

@teleivo teleivo force-pushed the DHIS2-18541-pre branch 2 times, most recently from bccddb0 to e968a25 Compare January 13, 2025 06:09
@teleivo teleivo changed the title chore: simplify logic DHIS2-18541 chore: simplify TrackedEntityService.getTrackedEntity(UID, ...) logic DHIS2-18541 Jan 13, 2025
@teleivo teleivo marked this pull request as ready for review January 13, 2025 06:24
@teleivo teleivo requested a review from a team as a code owner January 13, 2025 06:24
We have two methods for getting a single TE. They were implemented
independently with convoluted logic. Let one reuse the other. Separate
fetching, ACL, mapping to make the flow easier to follow. Move the TETAV
logic in one place. This is the only way we can ensure the behavior is
the same across different code paths.
@teleivo teleivo enabled auto-merge (squash) January 13, 2025 09:56
@teleivo teleivo merged commit 132a631 into master Jan 13, 2025
16 checks passed
@teleivo teleivo deleted the DHIS2-18541-pre branch January 13, 2025 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants