From eabc95176155153f546cb8b370f3515a5fb866d8 Mon Sep 17 00:00:00 2001 From: amontenegro Date: Wed, 11 Dec 2024 15:25:59 -0600 Subject: [PATCH] More tests --- ...rV2ApiServiceDelegator_ReadRecordTest.java | 16 +++++++++++++ ...rV3ApiServiceDelegator_ReadRecordTest.java | 24 ++++++++++++++----- .../PublicV2ApiServiceDelegatorTest.java | 17 ++++++++++++- .../PublicV3ApiServiceDelegatorTest.java | 16 +++++++++++++ 4 files changed, 66 insertions(+), 7 deletions(-) diff --git a/orcid-api-web/src/test/java/org/orcid/api/memberV2/server/delegator/MemberV2ApiServiceDelegator_ReadRecordTest.java b/orcid-api-web/src/test/java/org/orcid/api/memberV2/server/delegator/MemberV2ApiServiceDelegator_ReadRecordTest.java index 9ce94e6c7b..ea220a321a 100644 --- a/orcid-api-web/src/test/java/org/orcid/api/memberV2/server/delegator/MemberV2ApiServiceDelegator_ReadRecordTest.java +++ b/orcid-api-web/src/test/java/org/orcid/api/memberV2/server/delegator/MemberV2ApiServiceDelegator_ReadRecordTest.java @@ -1159,4 +1159,20 @@ private void assertAllPublicButEmails(Person p) { assertEquals(Long.valueOf(13), ru.getResearcherUrls().get(0).getPutCode()); assertEquals(Visibility.PUBLIC, ru.getResearcherUrls().get(0).getVisibility()); } + + @Test + public void viewNonProfessionalEmailsOnRecord() { + String orcid = "0000-0000-0000-0001"; + SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_LIMITED); + Response r = serviceDelegator.viewRecord(orcid); + Record record = (Record) r.getEntity(); + assertNotNull(record); + assertNotNull(record.getPerson()); + assertNotNull(record.getPerson().getEmails()); + assertEquals(1, record.getPerson().getEmails().getEmails().size()); + Email e = record.getPerson().getEmails().getEmails().get(0); + assertTrue(e.isVerified()); + assertEquals("APP-5555555555555555", e.getSource().retrieveSourcePath()); + assertEquals("Source Client 1", e.getSource().getSourceName().getContent()); + } } diff --git a/orcid-api-web/src/test/java/org/orcid/api/memberV3/server/delegator/MemberV3ApiServiceDelegator_ReadRecordTest.java b/orcid-api-web/src/test/java/org/orcid/api/memberV3/server/delegator/MemberV3ApiServiceDelegator_ReadRecordTest.java index e387c20e59..6a01ee10c7 100644 --- a/orcid-api-web/src/test/java/org/orcid/api/memberV3/server/delegator/MemberV3ApiServiceDelegator_ReadRecordTest.java +++ b/orcid-api-web/src/test/java/org/orcid/api/memberV3/server/delegator/MemberV3ApiServiceDelegator_ReadRecordTest.java @@ -1,11 +1,5 @@ package org.orcid.api.memberV3.server.delegator; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -78,6 +72,8 @@ import org.orcid.test.helper.v3.Utils; import org.springframework.test.context.ContextConfiguration; +import static org.junit.Assert.*; + @RunWith(OrcidJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:test-orcid-api-web-context.xml" }) public class MemberV3ApiServiceDelegator_ReadRecordTest extends DBUnitTest { @@ -1350,4 +1346,20 @@ private void assertAllPublicButEmails(Person p) { assertEquals(Long.valueOf(13), ru.getResearcherUrls().get(0).getPutCode()); assertEquals(Visibility.PUBLIC, ru.getResearcherUrls().get(0).getVisibility()); } + + @Test + public void viewNonProfessionalEmailsOnRecord() { + String orcid = "0000-0000-0000-0001"; + SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_LIMITED); + Response r = serviceDelegator.viewRecord(orcid); + Record record = (Record) r.getEntity(); + assertNotNull(record); + assertNotNull(record.getPerson()); + assertNotNull(record.getPerson().getEmails()); + assertEquals(1, record.getPerson().getEmails().getEmails().size()); + Email e = record.getPerson().getEmails().getEmails().get(0); + assertTrue(e.isVerified()); + assertEquals("APP-5555555555555555", e.getSource().retrieveSourcePath()); + assertEquals("Source Client 1", e.getSource().getSourceName().getContent()); + } } diff --git a/orcid-pub-web/src/test/java/org/orcid/api/publicV2/server/PublicV2ApiServiceDelegatorTest.java b/orcid-pub-web/src/test/java/org/orcid/api/publicV2/server/PublicV2ApiServiceDelegatorTest.java index fe170e3134..c05f202e3f 100644 --- a/orcid-pub-web/src/test/java/org/orcid/api/publicV2/server/PublicV2ApiServiceDelegatorTest.java +++ b/orcid-pub-web/src/test/java/org/orcid/api/publicV2/server/PublicV2ApiServiceDelegatorTest.java @@ -1534,5 +1534,20 @@ public void testSchemaOrgMBWriterV2() throws WebApplicationException, IOExceptio assertEquals("self_public_user_obo_type",doc.identifier.get(0).propertyID); assertEquals( "self_public_user_obo_ref",doc.identifier.get(0).value); } - + + @Test + public void viewNonProfessionalEmailsOnRecord() { + String orcid = "0000-0000-0000-0001"; + SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_LIMITED); + Response r = serviceDelegator.viewRecord(orcid); + Record record = (Record) r.getEntity(); + assertNotNull(record); + assertNotNull(record.getPerson()); + assertNotNull(record.getPerson().getEmails()); + assertEquals(1, record.getPerson().getEmails().getEmails().size()); + Email e = record.getPerson().getEmails().getEmails().get(0); + assertTrue(e.isVerified()); + assertEquals("APP-5555555555555555", e.getSource().retrieveSourcePath()); + assertEquals("Source Client 1", e.getSource().getSourceName().getContent()); + } } diff --git a/orcid-pub-web/src/test/java/org/orcid/api/publicV3/server/PublicV3ApiServiceDelegatorTest.java b/orcid-pub-web/src/test/java/org/orcid/api/publicV3/server/PublicV3ApiServiceDelegatorTest.java index acea94057d..7d38cc1633 100644 --- a/orcid-pub-web/src/test/java/org/orcid/api/publicV3/server/PublicV3ApiServiceDelegatorTest.java +++ b/orcid-pub-web/src/test/java/org/orcid/api/publicV3/server/PublicV3ApiServiceDelegatorTest.java @@ -2187,4 +2187,20 @@ public void testExpandedSearchByQueryNoRowsParamSet() { ReflectionTestUtils.setField(serviceDelegator, "orcidSearchManager", orcidSearchManager); } + + @Test + public void viewNonProfessionalEmailsOnRecord() { + String orcid = "0000-0000-0000-0001"; + SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_LIMITED); + Response r = serviceDelegator.viewRecord(orcid); + Record record = (Record) r.getEntity(); + assertNotNull(record); + assertNotNull(record.getPerson()); + assertNotNull(record.getPerson().getEmails()); + assertEquals(1, record.getPerson().getEmails().getEmails().size()); + Email e = record.getPerson().getEmails().getEmails().get(0); + assertTrue(e.isVerified()); + assertEquals("APP-5555555555555555", e.getSource().retrieveSourcePath()); + assertEquals("Source Client 1", e.getSource().getSourceName().getContent()); + } }