-
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
Create SQL logic for UpdateNotificationAction and add relevant tests for v9 migration #12085
Create SQL logic for UpdateNotificationAction and add relevant tests for v9 migration #12085
Conversation
2298e1d
to
533399c
Compare
533399c
to
eaf3c0c
Compare
@@ -34,7 +35,7 @@ public JsonResult execute() throws InvalidHttpRequestBodyException { | |||
.build(); | |||
|
|||
try { | |||
return new JsonResult(new NotificationData(logic.updateNotification(newNotification))); | |||
return new JsonResult(new NotificationData(sqlLogic.updateNotification(newNotification))); |
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.
Can we fetch the notification then use the setters to update rather than create a detached object. This ensures that it's in a managed state (less chance of random errors when session is flushed, slight performance benefits as well).
d47b2d9
to
b481ea7
Compare
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.
Changes look great!
@@ -18,23 +19,20 @@ public class UpdateNotificationAction extends AdminOnlyAction { | |||
|
|||
@Override | |||
public JsonResult execute() throws InvalidHttpRequestBodyException { | |||
String notificationId = getNonNullRequestParamValue(Const.ParamsNames.NOTIFICATION_ID); | |||
UUID notificationId = UUID.fromString(getNonNullRequestParamValue(Const.ParamsNames.NOTIFICATION_ID)); |
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 added a method for this, getUUIDRequestParamValue. See GetNotificationAction. Main difference is that string is validated to ensure it is a proper UUID.
notificationRequest.getStyle(), notificationRequest.getTargetUser(), notificationRequest.getTitle(), | ||
notificationRequest.getMessage()); | ||
|
||
HibernateUtil.flushSession(); |
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.
No need to flush (unless we need a generated (in db) value such as ID, createdAt/updatedAt timestamp)
public class NotificationsLogicIT extends BaseTestCaseWithSqlDatabaseAccess { | ||
|
||
private NotificationsLogic notificationsLogic = NotificationsLogic.inst(); | ||
private NotificationsDb notificationsDb = NotificationsDb.inst(); |
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.
Might be slightly cleaner to use getNotifications in logic instead of db, then we can remove this declaration.
@BeforeClass | ||
public void initLogicDependencies() { | ||
notificationsLogic.initLogicDependencies(notificationsDb); | ||
} |
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.
Maybe move this up to parent class and initialise all dependencies? We will need to do this for all test cases.
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.
Just realise it is already initialised in setUpClass method
db28ea7
to
3a91abf
Compare
…nt tests for v9 migration (#12085)
…nt tests for v9 migration (#12085)
Part of #12048
Create SQL logic for
UpdateNotificationAction
and add relevant tests