From ca20709cf3fb6231cc76b2cdc071141b6ca4d8ff Mon Sep 17 00:00:00 2001 From: Nicolas <25302138+NicolasCwy@users.noreply.github.com> Date: Tue, 26 Mar 2024 15:21:04 +0800 Subject: [PATCH] [#12048] Relax read notif verification for migration verification script (#12937) * Fix account requests with wrong field during seed * Relax account attributes verification * Fix lint errors * Fix order of account request variables --- .../teammates/client/scripts/sql/SeedDb.java | 2 +- .../scripts/sql/VerifyAccountAttributes.java | 32 ++++++++++--------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/client/java/teammates/client/scripts/sql/SeedDb.java b/src/client/java/teammates/client/scripts/sql/SeedDb.java index 20d13ad5c67..40185c120de 100644 --- a/src/client/java/teammates/client/scripts/sql/SeedDb.java +++ b/src/client/java/teammates/client/scripts/sql/SeedDb.java @@ -157,7 +157,7 @@ protected void persistAdditionalData() { String accountRequestEmail = String.format("Account Email %s", i); String accountRequestInstitute = String.format("Account Institute %s", i); AccountRequest accountRequest = AccountRequestAttributes - .builder(accountRequestName, accountRequestEmail, accountRequestInstitute) + .builder(accountRequestEmail, accountRequestInstitute, accountRequestName) .withRegisteredAt(Instant.now()).build().toEntity(); String accountGoogleId = String.format("Account Google ID %s", i); diff --git a/src/client/java/teammates/client/scripts/sql/VerifyAccountAttributes.java b/src/client/java/teammates/client/scripts/sql/VerifyAccountAttributes.java index b2f03532968..b53f684640c 100644 --- a/src/client/java/teammates/client/scripts/sql/VerifyAccountAttributes.java +++ b/src/client/java/teammates/client/scripts/sql/VerifyAccountAttributes.java @@ -1,12 +1,8 @@ package teammates.client.scripts.sql; // CHECKSTYLE.OFF:ImportOrder -import java.time.Instant; -import java.util.ArrayList; -import java.util.Collections; import java.util.LinkedList; import java.util.List; -import java.util.Map; import jakarta.persistence.TypedQuery; import jakarta.persistence.criteria.CriteriaBuilder; @@ -17,7 +13,6 @@ import teammates.common.util.HibernateUtil; import teammates.storage.entity.Account; -import teammates.storage.sqlentity.ReadNotification; /** * Class for verifying account attributes. @@ -87,18 +82,25 @@ public boolean equals(teammates.storage.sqlentity.Account sqlEntity, Account dat return false; } - Map datastoreReadNotifications = datastoreEntity.getReadNotifications(); - List sqlReadNotifications = sqlEntity.getReadNotifications(); + return true; - List datastoreEndTimes = new ArrayList(datastoreReadNotifications.values()); - Collections.sort(datastoreEndTimes); + // Not verifying read notification as current datastore implementation does not remove notifications + // that have been deleted from account entities. During migration, the notification will not be + // migrated since it is deleted and read notification will fail during migration (foreign key error) + // causing the verification to fail - List sqlEndTimes = new ArrayList<>(); - for (ReadNotification sqlReadNotification : sqlReadNotifications) { - sqlEndTimes.add(sqlReadNotification.getNotification().getEndTime()); - } - Collections.sort(sqlEndTimes); + // Map datastoreReadNotifications = datastoreEntity.getReadNotifications(); + // List sqlReadNotifications = sqlEntity.getReadNotifications(); + + // List datastoreEndTimes = new ArrayList(datastoreReadNotifications.values()); + // Collections.sort(datastoreEndTimes); + + // List sqlEndTimes = new ArrayList<>(); + // for (ReadNotification sqlReadNotification : sqlReadNotifications) { + // sqlEndTimes.add(sqlReadNotification.getNotification().getEndTime()); + // } + // Collections.sort(sqlEndTimes); - return datastoreEndTimes.equals(sqlEndTimes); + // return datastoreEndTimes.equals(sqlEndTimes); } }