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

fix: Add templateid column in program rule action [DHIS2-17515] #17723

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

zubaira
Copy link
Contributor

@zubaira zubaira commented Jun 6, 2024

@zubaira zubaira marked this pull request as ready for review June 6, 2024 12:43
@zubaira zubaira requested review from a team and enricocolasante June 6, 2024 13:40
}

if (pnt == null) {
log.debug(
String.format(
"ProgramNotificationTemplate id: %s for program rule: %s does not exist",
programRuleAction.getTemplateUid(), rule.getName()));
programRuleAction.getNotificationTemplate().getUid(), rule.getName()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a NullPointerException.
And no failing test pointing this issue means that we are not testing the case where the notification template is not present

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch @enricocolasante. After this change, i think we won't be needing this part of the code.
I will add test as well to verify this change.

@zubaira zubaira requested review from enricocolasante and a team June 17, 2024 09:45

@Test
void testInValidRuleActionSendMessage() {
ProgramRuleAction programRuleAction = new ProgramRuleAction();
Copy link
Contributor

@enricocolasante enricocolasante Jun 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ProgramRuleAction shouldn't be of type SENDMESSAGE?

new NotificationProgramRuleActionValidator();
ProgramRuleActionValidationResult result =
notificationValidator.validate(programRuleAction, validationContext);
assertFalse(result.isValid());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also assert the ErrorCode to be sure you are getting the right error

@@ -134,7 +134,7 @@ public class ProgramRuleAction extends BaseIdentifiableObject implements Metadat
* <li>sendmessage
* </ul>
*/
private String templateUid;
private ProgramNotificationTemplate notificationTemplate;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this affect Maintenance App?
They were sending a uid before, how is it working now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes and we do have a ticket for that.
https://dhis2.atlassian.net/browse/DHIS2-17534

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change.
If we want to proceed this way, we need to coordinate with Platform team and we cannot just leave the app broken for the time being.
Why cannot we leave this field as a templateUid and change the underneath logic to validate it and store the actual ProgramNotificationTemplate in the DB?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is exactly what I discussed previously and we agreed to have a foreign key instead of a validation.
But foreign key is the right solution to go with. if its breaking change then we need to coordinate with the platform team.

Copy link
Contributor

@enricocolasante enricocolasante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Api tests are failing because of the contract change?

Copy link

sonarcloud bot commented Jun 25, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants