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

[#12048] Migrate tests for GetNotificationActionTest #13210

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

Conversation

InfinityTwo
Copy link

@InfinityTwo InfinityTwo commented Feb 2, 2025

Part of #12048

Outline of Solution
Added the unit tests for GetNotificationActionTest for PostgreSQL.

PS: This is not a duplicate of #13219 if anyone gets confused by the similar name

Copy link
Contributor

@yuanxi1 yuanxi1 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, great work!

Comment on lines +41 to +49
NotificationAttributes notification = typicalBundle.notifications.get("notification1");
Notification testNotification = new Notification(
notification.getStartTime(),
notification.getEndTime(),
notification.getStyle(),
notification.getTargetUser(),
notification.getTitle(),
notification.getMessage());
notification.setNotificationId(testNotification.getId().toString());
Copy link
Contributor

Choose a reason for hiding this comment

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

Great observation to use typicalBundle. However, it uses src/test/resources/data/typicalDataBundle.json which is for datastore entities. After the migration is done, the file will become obsolete. I think it might be better to just create a Notification object in the test.
We may also consider adding a sql ver test data file @domoberzin ?

NotificationData output = (NotificationData) jsonResult.getOutput();
verifyNotificationEquals(expected, output);

when(mockLogic.getNotification(testNotification.getId())).thenCallRealMethod();
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the intended purpose of thenCallRealMethod() to reset the mock? Maybe can consider reset(mockLogic) because thenCallRealMethod() sets the real implementation to be called. But since Logic.getNotification should always be mocked, resetting is not strictly necessary.

Comment on lines +69 to +70
GetNotificationAction action = getAction(Const.ParamsNames.NOTIFICATION_ID, UUID.randomUUID().toString());
EntityNotFoundException enfe = assertThrows(EntityNotFoundException.class, action::execute);
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor style suggestion: Consider adding a blank line between the action and the assertions to improve readability.

Comment on lines +76 to +77
GetNotificationAction action = getAction(Const.ParamsNames.NOTIFICATION_ID, null, new String[] {});
InvalidHttpParameterException ihpe = assertThrows(InvalidHttpParameterException.class, action::execute);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

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.

2 participants