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 GetNotificationsActionTest #13219

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

Conversation

InfinityTwo
Copy link
Contributor

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

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.

Great and comprehensive work overall!

}

@Test
protected void testAccessControl_instructorAccessStudentNotification_shouldFail() {
Copy link
Contributor

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

Copy link
Contributor

@yuanxi1 yuanxi1 Feb 23, 2025

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.

Comment on lines +167 to +169
List<Notification> notificationToCheck =
mockLogic.getActiveNotificationsByTargetUser(testNotification.getTargetUser());
notificationToCheck.forEach(n -> assertFalse(n.isShown()));
Copy link
Contributor

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.

Comment on lines 242 to 247
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()));
Copy link
Contributor

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

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