diff --git a/src/it/java/teammates/it/ui/webapi/GetAccountRequestsActionIT.java b/src/it/java/teammates/it/ui/webapi/GetAccountRequestsActionIT.java index 565fda387a5..feecca65747 100644 --- a/src/it/java/teammates/it/ui/webapi/GetAccountRequestsActionIT.java +++ b/src/it/java/teammates/it/ui/webapi/GetAccountRequestsActionIT.java @@ -87,17 +87,17 @@ public void testExecute() { assertEquals(2, arData.size()); - // account request 1 - assertEquals(arData.get(0).getEmail(), accountRequest1.getEmail()); - assertEquals(arData.get(0).getInstitute(), accountRequest1.getInstitute()); - assertEquals(arData.get(0).getName(), accountRequest1.getName()); - assertEquals(arData.get(0).getRegistrationKey(), accountRequest1.getRegistrationKey()); + // account request 1 (with the most recent created_at) + assertEquals(arData.get(1).getEmail(), accountRequest1.getEmail()); + assertEquals(arData.get(1).getInstitute(), accountRequest1.getInstitute()); + assertEquals(arData.get(1).getName(), accountRequest1.getName()); + assertEquals(arData.get(1).getRegistrationKey(), accountRequest1.getRegistrationKey()); // account request 2 - assertEquals(arData.get(1).getEmail(), accountRequest2.getEmail()); - assertEquals(arData.get(1).getInstitute(), accountRequest2.getInstitute()); - assertEquals(arData.get(1).getName(), accountRequest2.getName()); - assertEquals(arData.get(1).getRegistrationKey(), accountRequest2.getRegistrationKey()); + assertEquals(arData.get(0).getEmail(), accountRequest2.getEmail()); + assertEquals(arData.get(0).getInstitute(), accountRequest2.getInstitute()); + assertEquals(arData.get(0).getName(), accountRequest2.getName()); + assertEquals(arData.get(0).getRegistrationKey(), accountRequest2.getRegistrationKey()); } @Override diff --git a/src/it/resources/data/typicalDataBundle.json b/src/it/resources/data/typicalDataBundle.json index 887488e829d..4c97cca8512 100644 --- a/src/it/resources/data/typicalDataBundle.json +++ b/src/it/resources/data/typicalDataBundle.json @@ -73,7 +73,8 @@ "name": "Instructor 1", "email": "instr1@teammates.tmt", "institute": "TEAMMATES Test Institute 1", - "registeredAt": "2010-02-14T00:00:00Z" + "registeredAt": "2010-02-14T00:00:00Z", + "createdAt": "2011-02-01T00:00:00Z" }, "instructor2": { "id": "00000000-0000-4000-8000-000000000102", diff --git a/src/main/java/teammates/storage/sqlapi/AccountRequestsDb.java b/src/main/java/teammates/storage/sqlapi/AccountRequestsDb.java index 310b78e6239..499781a314e 100644 --- a/src/main/java/teammates/storage/sqlapi/AccountRequestsDb.java +++ b/src/main/java/teammates/storage/sqlapi/AccountRequestsDb.java @@ -84,7 +84,9 @@ public List getPendingAccountRequests() { CriteriaBuilder cb = HibernateUtil.getCriteriaBuilder(); CriteriaQuery cr = cb.createQuery(AccountRequest.class); Root root = cr.from(AccountRequest.class); - cr.select(root).where(cb.equal(root.get("status"), AccountRequestStatus.PENDING)); + cr.select(root) + .where(cb.equal(root.get("status"), AccountRequestStatus.PENDING)) + .orderBy(cb.desc(root.get("createdAt"))); TypedQuery query = HibernateUtil.createQuery(cr); return query.getResultList();