-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#12048] Create SQL logic for UpdateNotificationAction and add releva…
…nt tests for v9 migration (#12085)
- Loading branch information
Showing
22 changed files
with
307 additions
and
39 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
src/it/java/teammates/it/sqllogic/core/NotificationsLogicIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package teammates.it.sqllogic.core; | ||
|
||
import java.time.Instant; | ||
import java.util.UUID; | ||
|
||
import org.testng.annotations.Test; | ||
|
||
import teammates.common.datatransfer.NotificationStyle; | ||
import teammates.common.datatransfer.NotificationTargetUser; | ||
import teammates.common.exception.EntityAlreadyExistsException; | ||
import teammates.common.exception.EntityDoesNotExistException; | ||
import teammates.common.exception.InvalidParametersException; | ||
import teammates.it.test.BaseTestCaseWithSqlDatabaseAccess; | ||
import teammates.sqllogic.core.NotificationsLogic; | ||
import teammates.storage.sqlentity.Notification; | ||
|
||
/** | ||
* SUT: {@link NotificationsLogic}. | ||
*/ | ||
public class NotificationsLogicIT extends BaseTestCaseWithSqlDatabaseAccess { | ||
|
||
private NotificationsLogic notificationsLogic = NotificationsLogic.inst(); | ||
|
||
@Test | ||
public void testUpdateNotification() | ||
throws EntityAlreadyExistsException, InvalidParametersException, EntityDoesNotExistException { | ||
Instant newStartTime = Instant.parse("2012-01-01T00:00:00Z"); | ||
Instant newEndTime = Instant.parse("2098-01-01T00:00:00Z"); | ||
NotificationStyle newStyle = NotificationStyle.DARK; | ||
NotificationTargetUser newTargetUser = NotificationTargetUser.INSTRUCTOR; | ||
String newTitle = "An updated deprecation note"; | ||
String newMessage = "<p>Deprecation happens in three seconds</p>"; | ||
|
||
______TS("success: update notification that already exists"); | ||
Notification notification = new Notification(Instant.parse("2011-01-01T00:00:00Z"), | ||
Instant.parse("2099-01-01T00:00:00Z"), NotificationStyle.DANGER, NotificationTargetUser.GENERAL, | ||
"A deprecation note", "<p>Deprecation happens in three minutes</p>"); | ||
notificationsLogic.createNotification(notification); | ||
|
||
UUID notificationId = notification.getNotificationId(); | ||
Notification expectedNotification = notificationsLogic.updateNotification(notificationId, newStartTime, newEndTime, | ||
newStyle, newTargetUser, newTitle, newMessage); | ||
|
||
assertEquals(notificationId, expectedNotification.getNotificationId()); | ||
assertEquals(newStartTime, expectedNotification.getStartTime()); | ||
assertEquals(newEndTime, expectedNotification.getEndTime()); | ||
assertEquals(newStyle, expectedNotification.getStyle()); | ||
assertEquals(newTargetUser, expectedNotification.getTargetUser()); | ||
assertEquals(newTitle, expectedNotification.getTitle()); | ||
assertEquals(newMessage, expectedNotification.getMessage()); | ||
|
||
Notification actualNotification = notificationsLogic.getNotification(notificationId); | ||
verifyEquals(expectedNotification, actualNotification); | ||
|
||
______TS("failure: update notification that does not exist"); | ||
UUID nonExistentId = generateDifferentUuid(notificationId); | ||
|
||
assertThrows(EntityDoesNotExistException.class, () -> notificationsLogic.updateNotification(nonExistentId, | ||
newStartTime, newEndTime, newStyle, newTargetUser, newTitle, newMessage)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** | ||
* Contains test cases for {@link teammates.storage.sqlapi} package. | ||
*/ | ||
package teammates.it.sqllogic.core; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/** | ||
* Contains test cases for {@link teammates.storage.search} package. | ||
* Contains test cases for {@link teammates.storage.sqlapi} package. | ||
*/ | ||
package teammates.it.storage.sqlapi; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
src/main/java/teammates/storage/sqlapi/DeadlineExtensionsDb.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/main/java/teammates/storage/sqlapi/FeedbackSessionsDb.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.