From e07961a20117577eaad2f15059a809bb33939446 Mon Sep 17 00:00:00 2001 From: andrej romanov <50377758+auumgn@users.noreply.github.com> Date: Wed, 30 Oct 2024 21:04:38 +0200 Subject: [PATCH 1/6] add source name and or id to emails missing both --- .../web/controllers/ManageProfileController.java | 12 +++++++++++- .../web/controllers/PublicRecordController.java | 12 ++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/orcid-web/src/main/java/org/orcid/frontend/web/controllers/ManageProfileController.java b/orcid-web/src/main/java/org/orcid/frontend/web/controllers/ManageProfileController.java index e3e99fb1b3f..f743785b496 100644 --- a/orcid-web/src/main/java/org/orcid/frontend/web/controllers/ManageProfileController.java +++ b/orcid-web/src/main/java/org/orcid/frontend/web/controllers/ManageProfileController.java @@ -536,7 +536,17 @@ public ModelAndView confirmDeactivateOrcidAccount(HttpServletRequest request, Ht if (Features.EMAIL_DOMAINS.isActive()) { emailDomains = profileEmailDomainManagerReadOnly.getEmailDomains(getCurrentUserOrcid()); } - return org.orcid.pojo.ajaxForm.Emails.valueOf(v2Emails, emailDomains); + org.orcid.pojo.ajaxForm.Emails emails = org.orcid.pojo.ajaxForm.Emails.valueOf(v2Emails, emailDomains); + // Old emails are missing the source name and id -- assign the user as the source + for (org.orcid.pojo.ajaxForm.Email email: emails.getEmails()) { + if (email.getSource() == null && email.getSourceName() == null) { + String orcid = getCurrentUserOrcid(); + String displayName = getPersonDetails(orcid, true).getDisplayName(); + email.setSource(orcid); + email.setSourceName(displayName); + } + } + return emails; } @RequestMapping(value = "/emails.json", method = RequestMethod.POST) diff --git a/orcid-web/src/main/java/org/orcid/frontend/web/controllers/PublicRecordController.java b/orcid-web/src/main/java/org/orcid/frontend/web/controllers/PublicRecordController.java index feb81265199..b0787513446 100644 --- a/orcid-web/src/main/java/org/orcid/frontend/web/controllers/PublicRecordController.java +++ b/orcid-web/src/main/java/org/orcid/frontend/web/controllers/PublicRecordController.java @@ -202,8 +202,16 @@ PublicRecord getRecord(String orcid) { if (Features.EMAIL_DOMAINS.isActive()) { emailDomains = profileEmailDomainManagerReadOnly.getPublicEmailDomains(orcid); } - - publicRecord.setEmails(org.orcid.pojo.ajaxForm.Emails.valueOf(filteredEmails, emailDomains)); + + org.orcid.pojo.ajaxForm.Emails emails = org.orcid.pojo.ajaxForm.Emails.valueOf(filteredEmails, emailDomains); + // Old emails are missing the source name and id -- assign the user as the source + for (org.orcid.pojo.ajaxForm.Email email: emails.getEmails()) { + if (email.getSource() == null && email.getSourceName() == null) { + email.setSource(orcid); + email.setSourceName(publicRecord.getDisplayName()); + } + } + publicRecord.setEmails(emails); // Fill external identifiers PersonExternalIdentifiers publicPersonExternalIdentifiers; From 76fcc8c36f75e365eb76da630256448065264e44 Mon Sep 17 00:00:00 2001 From: andrej romanov <50377758+auumgn@users.noreply.github.com> Date: Thu, 31 Oct 2024 00:03:36 +0200 Subject: [PATCH 2/6] add unfinished test --- .../ManageProfileControllerTest.java | 55 +++++++++++++++++-- 1 file changed, 50 insertions(+), 5 deletions(-) diff --git a/orcid-web/src/test/java/org/orcid/frontend/web/controllers/ManageProfileControllerTest.java b/orcid-web/src/test/java/org/orcid/frontend/web/controllers/ManageProfileControllerTest.java index a89a4fa8d3a..ab85214d192 100644 --- a/orcid-web/src/test/java/org/orcid/frontend/web/controllers/ManageProfileControllerTest.java +++ b/orcid-web/src/test/java/org/orcid/frontend/web/controllers/ManageProfileControllerTest.java @@ -13,6 +13,7 @@ import static org.mockito.Mockito.when; import static org.mockito.internal.verification.VerificationModeFactory.times; +import java.lang.annotation.Target; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; @@ -40,11 +41,10 @@ import org.orcid.core.manager.v3.OrcidSecurityManager; import org.orcid.core.manager.v3.ProfileEntityManager; import org.orcid.core.manager.v3.RecordNameManager; -import org.orcid.core.manager.v3.read_only.GivenPermissionToManagerReadOnly; -import org.orcid.core.manager.v3.read_only.ProfileEntityManagerReadOnly; -import org.orcid.core.manager.v3.read_only.RecordNameManagerReadOnly; +import org.orcid.core.manager.v3.read_only.*; import org.orcid.core.oauth.OrcidProfileUserDetails; import org.orcid.core.security.OrcidWebRole; +import org.orcid.jaxb.model.v3.release.common.Source; import org.orcid.utils.DateUtils; import org.orcid.core.utils.v3.OrcidIdentifierUtils; import org.orcid.frontend.email.RecordEmailSender; @@ -94,6 +94,12 @@ public class ManageProfileControllerTest { @Mock private EmailManager mockEmailManager; + @Mock + private EmailManagerReadOnly mockEmailManagerReadOnly; + + @Mock + private ProfileEmailDomainManagerReadOnly mockProfileEmailDomainManagerReadOnly; + @Mock private LocaleManager mockLocaleManager; @@ -127,6 +133,21 @@ public class ManageProfileControllerTest { @Mock(name="profileEntityManagerReadOnlyV3") private ProfileEntityManagerReadOnly mockProfileEntityManagerReadOnly; + @Mock + private PersonalDetailsManagerReadOnly mockPersonalDetailsManagerReadOnly; + + @Mock + private AddressManagerReadOnly mockAddressManagerReadOnly; + + @Mock + private ProfileKeywordManagerReadOnly mockKeywordManagerReadOnly; + + @Mock + private ResearcherUrlManagerReadOnly mockResearcherUrlManagerReadOnly; + + @Mock + private ExternalIdentifierManagerReadOnly mockExternalIdentifierManagerReadOnly; + @Before public void initMocks() throws Exception { controller = new ManageProfileController(); @@ -135,7 +156,8 @@ public void initMocks() throws Exception { TargetProxyHelper.injectIntoProxy(controller, "profileEntityCacheManager", mockProfileEntityCacheManager); TargetProxyHelper.injectIntoProxy(controller, "encryptionManager", mockEncryptionManager); TargetProxyHelper.injectIntoProxy(controller, "emailManager", mockEmailManager); - TargetProxyHelper.injectIntoProxy(controller, "emailManagerReadOnly", mockEmailManager); + TargetProxyHelper.injectIntoProxy(controller, "emailManagerReadOnly", mockEmailManagerReadOnly); + TargetProxyHelper.injectIntoProxy(controller, "profileEmailDomainManagerReadOnly", mockProfileEmailDomainManagerReadOnly); TargetProxyHelper.injectIntoProxy(controller, "localeManager", mockLocaleManager); TargetProxyHelper.injectIntoProxy(controller, "profileEntityManager", mockProfileEntityManager); TargetProxyHelper.injectIntoProxy(controller, "givenPermissionToManager", mockGivenPermissionToManager); @@ -147,6 +169,12 @@ public void initMocks() throws Exception { TargetProxyHelper.injectIntoProxy(controller, "twoFactorAuthenticationManager", twoFactorAuthenticationManager); TargetProxyHelper.injectIntoProxy(controller, "recordEmailSender", mockRecordEmailSender); TargetProxyHelper.injectIntoProxy(controller, "profileEntityManagerReadOnly", mockProfileEntityManagerReadOnly); + TargetProxyHelper.injectIntoProxy(controller, "personalDetailsManagerReadOnly", mockPersonalDetailsManagerReadOnly); + TargetProxyHelper.injectIntoProxy(controller, "addressManagerReadOnly", mockAddressManagerReadOnly); + TargetProxyHelper.injectIntoProxy(controller, "keywordManagerReadOnly", mockKeywordManagerReadOnly); + TargetProxyHelper.injectIntoProxy(controller, "researcherUrlManagerReadOnly", mockResearcherUrlManagerReadOnly); + TargetProxyHelper.injectIntoProxy(controller, "externalIdentifierManagerReadOnly", mockExternalIdentifierManagerReadOnly); + when(mockOrcidSecurityManager.isPasswordConfirmationRequired()).thenReturn(true); when(mockEncryptionManager.hashMatches(Mockito.anyString(), Mockito.anyString())).thenReturn(true); @@ -192,11 +220,13 @@ public Emails answer(InvocationOnMock invocation) throws Throwable { Emails emails = new Emails(); Email email1 = new Email(); email1.setEmail(invocation.getArgument(0) + "_1@test.orcid.org"); + email1.setSource(new Source()); email1.setVisibility(Visibility.PUBLIC); emails.getEmails().add(email1); Email email2 = new Email(); email2.setEmail(invocation.getArgument(0) + "_2@test.orcid.org"); + email2.setSource(new Source()); email2.setVisibility(Visibility.PUBLIC); emails.getEmails().add(email2); return emails; @@ -1116,7 +1146,22 @@ public void testEditEmail_primaryEmailChange() { verify(mockRecordEmailSender, Mockito.times(1)).sendVerificationEmail(eq(USER_ORCID), eq("email@orcid.org"), eq(true)); } - + + @Test + public void testEmptyEmailSource() { + SecurityContextHolder.getContext().setAuthentication(getAuthentication(USER_ORCID)); + when(mockProfileEmailDomainManagerReadOnly.getEmailDomains(eq(USER_ORCID))).thenReturn(null); + when(mockEmailManagerReadOnly.getPublicEmails(eq(USER_ORCID))).thenReturn(new Emails()); + MockHttpServletRequest mockRequest = new MockHttpServletRequest(); + MockHttpSession mockSession = new MockHttpSession(); + mockRequest.setSession(mockSession); + org.orcid.pojo.ajaxForm.Emails emails = controller.getEmails(mockRequest); + assertEquals(emails.getEmails().get(0).getSource(), USER_ORCID); + assertNull(emails.getEmails().get(0).getSourceName()); + + } + + protected Authentication getAuthentication(String orcid) { List roles = Arrays.asList(OrcidWebRole.ROLE_USER); OrcidProfileUserDetails details = new OrcidProfileUserDetails(orcid, "user_1@test.orcid.org", null, roles); From f15956c5b37ce8d9e42f58052d079f5c1f20a6cf Mon Sep 17 00:00:00 2001 From: amontenegro Date: Wed, 30 Oct 2024 19:00:56 -0600 Subject: [PATCH 3/6] Remove dup bean definition from child object --- .../frontend/web/controllers/ManageProfileController.java | 3 --- .../frontend/web/controllers/ManageProfileControllerTest.java | 1 - 2 files changed, 4 deletions(-) diff --git a/orcid-web/src/main/java/org/orcid/frontend/web/controllers/ManageProfileController.java b/orcid-web/src/main/java/org/orcid/frontend/web/controllers/ManageProfileController.java index f743785b496..72997bfb7bf 100644 --- a/orcid-web/src/main/java/org/orcid/frontend/web/controllers/ManageProfileController.java +++ b/orcid-web/src/main/java/org/orcid/frontend/web/controllers/ManageProfileController.java @@ -94,9 +94,6 @@ public class ManageProfileController extends BaseWorkspaceController { @Resource private GivenPermissionToManager givenPermissionToManager; - @Resource(name = "emailManagerReadOnlyV3") - private EmailManagerReadOnly emailManagerReadOnly; - @Resource(name = "profileEmailDomainManagerReadOnly") private ProfileEmailDomainManagerReadOnly profileEmailDomainManagerReadOnly; diff --git a/orcid-web/src/test/java/org/orcid/frontend/web/controllers/ManageProfileControllerTest.java b/orcid-web/src/test/java/org/orcid/frontend/web/controllers/ManageProfileControllerTest.java index ab85214d192..82f4dc01680 100644 --- a/orcid-web/src/test/java/org/orcid/frontend/web/controllers/ManageProfileControllerTest.java +++ b/orcid-web/src/test/java/org/orcid/frontend/web/controllers/ManageProfileControllerTest.java @@ -1161,7 +1161,6 @@ public void testEmptyEmailSource() { } - protected Authentication getAuthentication(String orcid) { List roles = Arrays.asList(OrcidWebRole.ROLE_USER); OrcidProfileUserDetails details = new OrcidProfileUserDetails(orcid, "user_1@test.orcid.org", null, roles); From 1ddf5e24898bb7277e4c70363beb7ef5b4cc023f Mon Sep 17 00:00:00 2001 From: andrej romanov <50377758+auumgn@users.noreply.github.com> Date: Thu, 31 Oct 2024 11:39:21 +0200 Subject: [PATCH 4/6] add tests --- .../ManageProfileControllerTest.java | 66 +++++++++++++++++-- 1 file changed, 59 insertions(+), 7 deletions(-) diff --git a/orcid-web/src/test/java/org/orcid/frontend/web/controllers/ManageProfileControllerTest.java b/orcid-web/src/test/java/org/orcid/frontend/web/controllers/ManageProfileControllerTest.java index 82f4dc01680..c8610c4140a 100644 --- a/orcid-web/src/test/java/org/orcid/frontend/web/controllers/ManageProfileControllerTest.java +++ b/orcid-web/src/test/java/org/orcid/frontend/web/controllers/ManageProfileControllerTest.java @@ -13,7 +13,6 @@ import static org.mockito.Mockito.when; import static org.mockito.internal.verification.VerificationModeFactory.times; -import java.lang.annotation.Target; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; @@ -44,13 +43,10 @@ import org.orcid.core.manager.v3.read_only.*; import org.orcid.core.oauth.OrcidProfileUserDetails; import org.orcid.core.security.OrcidWebRole; -import org.orcid.jaxb.model.v3.release.common.Source; +import org.orcid.jaxb.model.v3.release.common.*; import org.orcid.utils.DateUtils; import org.orcid.core.utils.v3.OrcidIdentifierUtils; import org.orcid.frontend.email.RecordEmailSender; -import org.orcid.jaxb.model.v3.release.common.CreditName; -import org.orcid.jaxb.model.v3.release.common.OrcidIdentifier; -import org.orcid.jaxb.model.v3.release.common.Visibility; import org.orcid.jaxb.model.v3.release.record.Biography; import org.orcid.jaxb.model.v3.release.record.Email; import org.orcid.jaxb.model.v3.release.record.Emails; @@ -84,6 +80,7 @@ public class ManageProfileControllerTest { private static final String USER_ORCID = "0000-0000-0000-0001"; private static final String DEPRECATED_USER_ORCID = "0000-0000-0000-0002"; private static final String DEPRECATED_USER_ORCID_URL = "https://localhost:8443/0000-0000-0000-0002"; + private static final String USER_CREDIT_NAME = "Credit Name"; @Mock private ProfileEntityCacheManager mockProfileEntityCacheManager; @@ -227,8 +224,16 @@ public Emails answer(InvocationOnMock invocation) throws Throwable { Email email2 = new Email(); email2.setEmail(invocation.getArgument(0) + "_2@test.orcid.org"); email2.setSource(new Source()); + email2.getSource().setSourceName(new SourceName(USER_CREDIT_NAME)); email2.setVisibility(Visibility.PUBLIC); emails.getEmails().add(email2); + + Email email3 = new Email(); + email3.setEmail(invocation.getArgument(0) + "_3@test.orcid.org"); + email3.setSource(new Source()); + email3.getSource().setSourceClientId(new SourceClientId(USER_ORCID)); + email3.setVisibility(Visibility.PUBLIC); + emails.getEmails().add(email3); return emails; } @@ -1156,11 +1161,58 @@ public void testEmptyEmailSource() { MockHttpSession mockSession = new MockHttpSession(); mockRequest.setSession(mockSession); org.orcid.pojo.ajaxForm.Emails emails = controller.getEmails(mockRequest); - assertEquals(emails.getEmails().get(0).getSource(), USER_ORCID); - assertNull(emails.getEmails().get(0).getSourceName()); + assertEquals(3, emails.getEmails().size()); + + org.orcid.pojo.ajaxForm.Email email1 = emails.getEmails().get(0); + assertEquals(email1.getValue(), USER_ORCID + "_1@test.orcid.org"); + assertEquals(email1.getSource(), USER_ORCID); + assertNull(email1.getSourceName()); + + org.orcid.pojo.ajaxForm.Email email2 = emails.getEmails().get(1); + assertEquals(email2.getValue(), USER_ORCID + "_2@test.orcid.org"); + assertNull(email2.getSource()); + assertEquals(email2.getSourceName(), USER_CREDIT_NAME); + } + + @Test + public void testEmailSourceWithSourceName() { + SecurityContextHolder.getContext().setAuthentication(getAuthentication(USER_ORCID)); + when(mockProfileEmailDomainManagerReadOnly.getEmailDomains(eq(USER_ORCID))).thenReturn(null); + when(mockEmailManagerReadOnly.getPublicEmails(eq(USER_ORCID))).thenReturn(new Emails()); + MockHttpServletRequest mockRequest = new MockHttpServletRequest(); + MockHttpSession mockSession = new MockHttpSession(); + mockRequest.setSession(mockSession); + org.orcid.pojo.ajaxForm.Emails emails = controller.getEmails(mockRequest); + + assertEquals(3, emails.getEmails().size()); + + org.orcid.pojo.ajaxForm.Email email2 = emails.getEmails().get(1); + assertEquals(email2.getValue(), USER_ORCID + "_2@test.orcid.org"); + assertNull(email2.getSource()); + assertEquals(email2.getSourceName(), USER_CREDIT_NAME); } + @Test + public void testEmailSourceWithSourceId() { + SecurityContextHolder.getContext().setAuthentication(getAuthentication(USER_ORCID)); + when(mockProfileEmailDomainManagerReadOnly.getEmailDomains(eq(USER_ORCID))).thenReturn(null); + when(mockEmailManagerReadOnly.getPublicEmails(eq(USER_ORCID))).thenReturn(new Emails()); + MockHttpServletRequest mockRequest = new MockHttpServletRequest(); + MockHttpSession mockSession = new MockHttpSession(); + mockRequest.setSession(mockSession); + org.orcid.pojo.ajaxForm.Emails emails = controller.getEmails(mockRequest); + + assertEquals(3, emails.getEmails().size()); + + org.orcid.pojo.ajaxForm.Email email3 = emails.getEmails().get(2); + assertEquals(email3.getValue(), USER_ORCID + "_3@test.orcid.org"); + assertNull(email3.getSourceName()); + assertEquals(email3.getSource(), USER_ORCID); + } + + + protected Authentication getAuthentication(String orcid) { List roles = Arrays.asList(OrcidWebRole.ROLE_USER); OrcidProfileUserDetails details = new OrcidProfileUserDetails(orcid, "user_1@test.orcid.org", null, roles); From 8689e4a8c0cb3cb4f0fa124cf398e7873c91ba35 Mon Sep 17 00:00:00 2001 From: andrej romanov <50377758+auumgn@users.noreply.github.com> Date: Thu, 31 Oct 2024 13:43:14 +0200 Subject: [PATCH 5/6] fix tests --- .../web/controllers/ManageProfileControllerTest.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/orcid-web/src/test/java/org/orcid/frontend/web/controllers/ManageProfileControllerTest.java b/orcid-web/src/test/java/org/orcid/frontend/web/controllers/ManageProfileControllerTest.java index c8610c4140a..cc087728332 100644 --- a/orcid-web/src/test/java/org/orcid/frontend/web/controllers/ManageProfileControllerTest.java +++ b/orcid-web/src/test/java/org/orcid/frontend/web/controllers/ManageProfileControllerTest.java @@ -91,9 +91,6 @@ public class ManageProfileControllerTest { @Mock private EmailManager mockEmailManager; - @Mock - private EmailManagerReadOnly mockEmailManagerReadOnly; - @Mock private ProfileEmailDomainManagerReadOnly mockProfileEmailDomainManagerReadOnly; @@ -153,7 +150,7 @@ public void initMocks() throws Exception { TargetProxyHelper.injectIntoProxy(controller, "profileEntityCacheManager", mockProfileEntityCacheManager); TargetProxyHelper.injectIntoProxy(controller, "encryptionManager", mockEncryptionManager); TargetProxyHelper.injectIntoProxy(controller, "emailManager", mockEmailManager); - TargetProxyHelper.injectIntoProxy(controller, "emailManagerReadOnly", mockEmailManagerReadOnly); + TargetProxyHelper.injectIntoProxy(controller, "emailManagerReadOnly", mockEmailManager); TargetProxyHelper.injectIntoProxy(controller, "profileEmailDomainManagerReadOnly", mockProfileEmailDomainManagerReadOnly); TargetProxyHelper.injectIntoProxy(controller, "localeManager", mockLocaleManager); TargetProxyHelper.injectIntoProxy(controller, "profileEntityManager", mockProfileEntityManager); @@ -1156,7 +1153,7 @@ public void testEditEmail_primaryEmailChange() { public void testEmptyEmailSource() { SecurityContextHolder.getContext().setAuthentication(getAuthentication(USER_ORCID)); when(mockProfileEmailDomainManagerReadOnly.getEmailDomains(eq(USER_ORCID))).thenReturn(null); - when(mockEmailManagerReadOnly.getPublicEmails(eq(USER_ORCID))).thenReturn(new Emails()); + when(mockEmailManager.getPublicEmails(eq(USER_ORCID))).thenReturn(new Emails()); MockHttpServletRequest mockRequest = new MockHttpServletRequest(); MockHttpSession mockSession = new MockHttpSession(); mockRequest.setSession(mockSession); @@ -1179,7 +1176,7 @@ public void testEmptyEmailSource() { public void testEmailSourceWithSourceName() { SecurityContextHolder.getContext().setAuthentication(getAuthentication(USER_ORCID)); when(mockProfileEmailDomainManagerReadOnly.getEmailDomains(eq(USER_ORCID))).thenReturn(null); - when(mockEmailManagerReadOnly.getPublicEmails(eq(USER_ORCID))).thenReturn(new Emails()); + when(mockEmailManager.getPublicEmails(eq(USER_ORCID))).thenReturn(new Emails()); MockHttpServletRequest mockRequest = new MockHttpServletRequest(); MockHttpSession mockSession = new MockHttpSession(); mockRequest.setSession(mockSession); @@ -1197,7 +1194,7 @@ public void testEmailSourceWithSourceName() { public void testEmailSourceWithSourceId() { SecurityContextHolder.getContext().setAuthentication(getAuthentication(USER_ORCID)); when(mockProfileEmailDomainManagerReadOnly.getEmailDomains(eq(USER_ORCID))).thenReturn(null); - when(mockEmailManagerReadOnly.getPublicEmails(eq(USER_ORCID))).thenReturn(new Emails()); + when(mockEmailManager.getPublicEmails(eq(USER_ORCID))).thenReturn(new Emails()); MockHttpServletRequest mockRequest = new MockHttpServletRequest(); MockHttpSession mockSession = new MockHttpSession(); mockRequest.setSession(mockSession); From 620975516eb514db2e8b0a3c157a09fcb760f741 Mon Sep 17 00:00:00 2001 From: andrej romanov <50377758+auumgn@users.noreply.github.com> Date: Thu, 31 Oct 2024 13:58:22 +0200 Subject: [PATCH 6/6] update email count in test --- .../ManageProfileControllerTest.java | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/orcid-web/src/test/java/org/orcid/frontend/web/controllers/ManageProfileControllerTest.java b/orcid-web/src/test/java/org/orcid/frontend/web/controllers/ManageProfileControllerTest.java index cc087728332..d501f59d488 100644 --- a/orcid-web/src/test/java/org/orcid/frontend/web/controllers/ManageProfileControllerTest.java +++ b/orcid-web/src/test/java/org/orcid/frontend/web/controllers/ManageProfileControllerTest.java @@ -419,16 +419,18 @@ public void testValidateDeprecateProfileWithValidData() { assertNotNull(deprecateProfile.getDeprecatingEmails()); assertEquals("0000-0000-0000-0002", deprecateProfile.getDeprecatingOrcid()); assertEquals("0000-0000-0000-0002 Given Names 0000-0000-0000-0002 Family Name", deprecateProfile.getDeprecatingAccountName()); - assertEquals(2, deprecateProfile.getDeprecatingEmails().size()); + assertEquals(3, deprecateProfile.getDeprecatingEmails().size()); assertTrue(deprecateProfile.getDeprecatingEmails().contains("0000-0000-0000-0002_1@test.orcid.org")); assertTrue(deprecateProfile.getDeprecatingEmails().contains("0000-0000-0000-0002_2@test.orcid.org")); + assertTrue(deprecateProfile.getDeprecatingEmails().contains("0000-0000-0000-0002_3@test.orcid.org")); assertEquals("0000-0000-0000-0001", deprecateProfile.getPrimaryOrcid()); assertEquals("0000-0000-0000-0001 Given Names 0000-0000-0000-0001 Family Name", deprecateProfile.getPrimaryAccountName()); assertNotNull(deprecateProfile.getPrimaryEmails()); - assertEquals(2, deprecateProfile.getPrimaryEmails().size()); + assertEquals(3, deprecateProfile.getPrimaryEmails().size()); assertTrue(deprecateProfile.getPrimaryEmails().contains("0000-0000-0000-0001_1@test.orcid.org")); assertTrue(deprecateProfile.getPrimaryEmails().contains("0000-0000-0000-0001_2@test.orcid.org")); + assertTrue(deprecateProfile.getPrimaryEmails().contains("0000-0000-0000-0001_3@test.orcid.org")); assertTrue(deprecateProfile.getErrors().isEmpty()); // Using orcid @@ -441,16 +443,19 @@ public void testValidateDeprecateProfileWithValidData() { assertNotNull(deprecateProfile.getDeprecatingEmails()); assertEquals("0000-0000-0000-0002", deprecateProfile.getDeprecatingOrcid()); assertEquals("0000-0000-0000-0002 Given Names 0000-0000-0000-0002 Family Name", deprecateProfile.getDeprecatingAccountName()); - assertEquals(2, deprecateProfile.getDeprecatingEmails().size()); + assertEquals(3, deprecateProfile.getDeprecatingEmails().size()); assertTrue(deprecateProfile.getDeprecatingEmails().contains("0000-0000-0000-0002_1@test.orcid.org")); assertTrue(deprecateProfile.getDeprecatingEmails().contains("0000-0000-0000-0002_2@test.orcid.org")); + assertTrue(deprecateProfile.getDeprecatingEmails().contains("0000-0000-0000-0002_3@test.orcid.org")); + assertEquals("0000-0000-0000-0001", deprecateProfile.getPrimaryOrcid()); assertEquals("0000-0000-0000-0001 Given Names 0000-0000-0000-0001 Family Name", deprecateProfile.getPrimaryAccountName()); assertNotNull(deprecateProfile.getPrimaryEmails()); - assertEquals(2, deprecateProfile.getPrimaryEmails().size()); + assertEquals(3, deprecateProfile.getPrimaryEmails().size()); assertTrue(deprecateProfile.getPrimaryEmails().contains("0000-0000-0000-0001_1@test.orcid.org")); assertTrue(deprecateProfile.getPrimaryEmails().contains("0000-0000-0000-0001_2@test.orcid.org")); + assertTrue(deprecateProfile.getPrimaryEmails().contains("0000-0000-0000-0001_3@test.orcid.org")); assertTrue(deprecateProfile.getErrors().isEmpty()); // Using orcid URL @@ -463,16 +468,19 @@ public void testValidateDeprecateProfileWithValidData() { assertNotNull(deprecateProfile.getDeprecatingEmails()); assertEquals("0000-0000-0000-0002", deprecateProfile.getDeprecatingOrcid()); assertEquals("0000-0000-0000-0002 Given Names 0000-0000-0000-0002 Family Name", deprecateProfile.getDeprecatingAccountName()); - assertEquals(2, deprecateProfile.getDeprecatingEmails().size()); + assertEquals(3, deprecateProfile.getDeprecatingEmails().size()); assertTrue(deprecateProfile.getDeprecatingEmails().contains("0000-0000-0000-0002_1@test.orcid.org")); assertTrue(deprecateProfile.getDeprecatingEmails().contains("0000-0000-0000-0002_2@test.orcid.org")); + assertTrue(deprecateProfile.getDeprecatingEmails().contains("0000-0000-0000-0002_3@test.orcid.org")); assertEquals("0000-0000-0000-0001", deprecateProfile.getPrimaryOrcid()); assertEquals("0000-0000-0000-0001 Given Names 0000-0000-0000-0001 Family Name", deprecateProfile.getPrimaryAccountName()); assertNotNull(deprecateProfile.getPrimaryEmails()); - assertEquals(2, deprecateProfile.getPrimaryEmails().size()); + assertEquals(3, deprecateProfile.getPrimaryEmails().size()); assertTrue(deprecateProfile.getPrimaryEmails().contains("0000-0000-0000-0001_1@test.orcid.org")); assertTrue(deprecateProfile.getPrimaryEmails().contains("0000-0000-0000-0001_2@test.orcid.org")); + assertTrue(deprecateProfile.getPrimaryEmails().contains("0000-0000-0000-0001_3@test.orcid.org")); + assertTrue(deprecateProfile.getErrors().isEmpty()); // Using orcid trim space @@ -486,16 +494,19 @@ public void testValidateDeprecateProfileWithValidData() { assertEquals("0000-0000-0000-0002", deprecateProfile.getDeprecatingOrcid()); assertEquals("0000-0000-0000-0002 Given Names 0000-0000-0000-0002 Family Name", deprecateProfile.getDeprecatingAccountName()); - assertEquals(2, deprecateProfile.getDeprecatingEmails().size()); + assertEquals(3, deprecateProfile.getDeprecatingEmails().size()); assertTrue(deprecateProfile.getDeprecatingEmails().contains("0000-0000-0000-0002_1@test.orcid.org")); assertTrue(deprecateProfile.getDeprecatingEmails().contains("0000-0000-0000-0002_2@test.orcid.org")); + assertTrue(deprecateProfile.getDeprecatingEmails().contains("0000-0000-0000-0002_3@test.orcid.org")); + assertEquals("0000-0000-0000-0001", deprecateProfile.getPrimaryOrcid()); assertEquals("0000-0000-0000-0001 Given Names 0000-0000-0000-0001 Family Name", deprecateProfile.getPrimaryAccountName()); assertNotNull(deprecateProfile.getPrimaryEmails()); - assertEquals(2, deprecateProfile.getPrimaryEmails().size()); + assertEquals(3, deprecateProfile.getPrimaryEmails().size()); assertTrue(deprecateProfile.getPrimaryEmails().contains("0000-0000-0000-0001_1@test.orcid.org")); assertTrue(deprecateProfile.getPrimaryEmails().contains("0000-0000-0000-0001_2@test.orcid.org")); + assertTrue(deprecateProfile.getPrimaryEmails().contains("0000-0000-0000-0001_3@test.orcid.org")); assertTrue(deprecateProfile.getErrors().isEmpty()); }