Skip to content

Commit

Permalink
[#12048] Relax read notif verification for migration verification scr…
Browse files Browse the repository at this point in the history
…ipt (#12937)

* Fix account requests with wrong field during seed

* Relax account attributes verification

* Fix lint errors

* Fix order of account request variables
  • Loading branch information
NicolasCwy committed Mar 26, 2024
1 parent 716fdc4 commit ca20709
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/client/java/teammates/client/scripts/sql/SeedDb.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -17,7 +13,6 @@

import teammates.common.util.HibernateUtil;
import teammates.storage.entity.Account;
import teammates.storage.sqlentity.ReadNotification;

/**
* Class for verifying account attributes.
Expand Down Expand Up @@ -87,18 +82,25 @@ public boolean equals(teammates.storage.sqlentity.Account sqlEntity, Account dat
return false;
}

Map<String, Instant> datastoreReadNotifications = datastoreEntity.getReadNotifications();
List<ReadNotification> sqlReadNotifications = sqlEntity.getReadNotifications();
return true;

List<Instant> datastoreEndTimes = new ArrayList<Instant>(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<Instant> sqlEndTimes = new ArrayList<>();
for (ReadNotification sqlReadNotification : sqlReadNotifications) {
sqlEndTimes.add(sqlReadNotification.getNotification().getEndTime());
}
Collections.sort(sqlEndTimes);
// Map<String, Instant> datastoreReadNotifications = datastoreEntity.getReadNotifications();
// List<ReadNotification> sqlReadNotifications = sqlEntity.getReadNotifications();

// List<Instant> datastoreEndTimes = new ArrayList<Instant>(datastoreReadNotifications.values());
// Collections.sort(datastoreEndTimes);

// List<Instant> sqlEndTimes = new ArrayList<>();
// for (ReadNotification sqlReadNotification : sqlReadNotifications) {
// sqlEndTimes.add(sqlReadNotification.getNotification().getEndTime());
// }
// Collections.sort(sqlEndTimes);

return datastoreEndTimes.equals(sqlEndTimes);
// return datastoreEndTimes.equals(sqlEndTimes);
}
}

0 comments on commit ca20709

Please sign in to comment.