-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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!
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()); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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.
GetNotificationAction action = getAction(Const.ParamsNames.NOTIFICATION_ID, UUID.randomUUID().toString()); | ||
EntityNotFoundException enfe = assertThrows(EntityNotFoundException.class, action::execute); |
There was a problem hiding this comment.
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.
GetNotificationAction action = getAction(Const.ParamsNames.NOTIFICATION_ID, null, new String[] {}); | ||
InvalidHttpParameterException ihpe = assertThrows(InvalidHttpParameterException.class, action::execute); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
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