-
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 GetNotificationsActionTest #13219
base: master
Are you sure you want to change the base?
Conversation
src/test/java/teammates/sqlui/webapi/GetNotificationsActionTest.java
Outdated
Show resolved
Hide resolved
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 and comprehensive work overall!
} | ||
|
||
@Test | ||
protected void testAccessControl_instructorAccessStudentNotification_shouldFail() { |
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.
What's the reason to use protected
for most of the test methods? If we don't need to limit visibility, let's change all to public
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.
After checking some files in the same directory, I think there's no standardisation on this. Perhaps you can just stick to one, public
protected
or or no modifier at all.
List<Notification> notificationToCheck = | ||
mockLogic.getActiveNotificationsByTargetUser(testNotification.getTargetUser()); | ||
notificationToCheck.forEach(n -> assertFalse(n.isShown())); |
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.
I think you did not set up a return value for when getActiveNotificationsByTargetUser
is called, so notificationToCheck
is null
by default and the assertion on line 169
won't be run.
List<Notification> notificationAttributes = | ||
mockLogic.getActiveNotificationsByTargetUser(NotificationTargetUser.INSTRUCTOR); | ||
notificationAttributes = notificationAttributes.stream() | ||
.filter(n -> !readNotificationsId.contains(n.getId().toString())) | ||
.collect(Collectors.toList()); | ||
notificationAttributes.forEach(n -> assertTrue(n.isShown())); |
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.
Let's rename notificationAttributes
to some other names such as activeNotifications
becuase 1) XXXAttribute
is the naming convention for datastore entities 2) it is clearer what kind these notifications are of
Part of #12048
Outline of Solution
Added the unit tests for GetNotificationsActionTest for PostgreSQL.
PS: This is not a duplicate of #13210 if anyone gets confused by the similar name