diff --git a/orcid-persistence/src/test/java/org/orcid/persistence/dao/ProfileDaoTest.java b/orcid-persistence/src/test/java/org/orcid/persistence/dao/ProfileDaoTest.java index c1d8d0565af..2d14ac9c1cc 100644 --- a/orcid-persistence/src/test/java/org/orcid/persistence/dao/ProfileDaoTest.java +++ b/orcid-persistence/src/test/java/org/orcid/persistence/dao/ProfileDaoTest.java @@ -375,74 +375,5 @@ public void testDisable2FA() { profileDao.disable2FA("2000-0000-0000-0002"); profile = profileDao.find("2000-0000-0000-0002"); assertFalse(profile.getUsing2FA()); - } - - @Test - @Transactional - @Rollback(true) - public void findEmailsUnverfiedDaysTest() throws IllegalAccessException { - String orcid = "9999-9999-9999-999X"; - ProfileEntity profile = new ProfileEntity(); - profile.setId(orcid); - profile.setClaimed(true); - profileDao.persist(profile); - profileDao.flush(); - emailDao.removeAll(); - - // Created today - assertEquals(1, insertEmailWithDateCreated("unverified_1@test.orcid.org", "bd22086b65b6259fe79f7844a6b6a369441733b9ef04eff762f3d640957b78f5", orcid, false, new Date())); - - // Created 2 days ago - assertEquals(1, insertEmailWithDateCreated("unverified_2@test.orcid.org", "95770578974f683fb05c179a84f57c3fc7d4b260f8079fbc590080e51873bb67", orcid, false, LocalDateTime.now().minusDays(2).toDate())); - - // Created 7 days ago - assertEquals(1, insertEmailWithDateCreated("unverified_3@test.orcid.org", "3cbebfc1de2500494fc95553c956e757cb1998149d366afb71888cdeb1550719", orcid, false, LocalDateTime.now().minusDays(7).toDate())); - - // Created 15 days ago - assertEquals(1, insertEmailWithDateCreated("unverified_4@test.orcid.org", "8fccc2e14b546b968033dee2efb1644623a31a7878b55ae8ad52951961ca3719", orcid, false, LocalDateTime.now().minusDays(15).toDate())); - - // Created 2 days ago and verified - assertEquals(1, insertEmailWithDateCreated("verified_1@test.orcid.org", "2f4812b9c675e9803a4bb616dd1bc241c8c9302ba5690a1ea9d48049a32e7c5f", orcid, true, LocalDateTime.now().minusDays(2).toDate())); - - // Created 7 days ago and verified - assertEquals(1, insertEmailWithDateCreated("verified_2@test.orcid.org", "896dea808bbf69bde1b177f27800e84d17763860bffde1dfd8ef200e79ff9971", orcid, true, LocalDateTime.now().minusDays(7).toDate())); - - // Created 15 days ago and verified - assertEquals(1, insertEmailWithDateCreated("verified_3@test.orcid.org", "f98cce12446df199b852583ce677ecf9870ebe1b58df21bc4e7b01dea67daf01", orcid, true, LocalDateTime.now().minusDays(28).toDate())); - - List> results = profileDao.findEmailsUnverfiedDays(2, EmailEventType.VERIFY_EMAIL_2_DAYS_SENT); - assertNotNull(results); - assertEquals(1, results.size()); - assertEquals(orcid, results.get(0).getLeft()); - assertEquals("unverified_2@test.orcid.org", results.get(0).getMiddle()); - - results = profileDao.findEmailsUnverfiedDays(7, EmailEventType.VERIFY_EMAIL_7_DAYS_SENT); - assertNotNull(results); - assertEquals(1, results.size()); - assertEquals(orcid, results.get(0).getLeft()); - assertEquals("unverified_3@test.orcid.org", results.get(0).getMiddle()); - - results = profileDao.findEmailsUnverfiedDays(28, EmailEventType.VERIFY_EMAIL_28_DAYS_SENT); - assertNotNull(results); - assertEquals(1, results.size()); - assertEquals(orcid, results.get(0).getLeft()); - assertEquals("unverified_4@test.orcid.org", results.get(0).getMiddle()); - } - - private int insertEmailWithDateCreated(String email, String emailHash, String orcid, boolean isVerified, Date dateCreated) { - Query q = entityManager.createNativeQuery( - "INSERT INTO email(email,email_hash,orcid,source_id,visibility,is_primary,is_current,is_verified,date_created,last_modified) " - + "values(:email, :emailHash, :orcid, :sourceId, :visibility, :isPrimary, :isCurrent, :isVerified, :dateCreated, :lastModified)"); - q.setParameter("email", email); - q.setParameter("emailHash", emailHash); - q.setParameter("orcid", orcid); - q.setParameter("sourceId", orcid); - q.setParameter("visibility", "PUBLIC"); - q.setParameter("isPrimary", false); - q.setParameter("isCurrent", false); - q.setParameter("isVerified", isVerified); - q.setParameter("dateCreated", dateCreated); - q.setParameter("lastModified", dateCreated); - return q.executeUpdate(); - } + } }