Skip to content

Commit

Permalink
Testing verified non professional addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
amontenegro committed Dec 11, 2024
1 parent eabc951 commit 7d111db
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,17 @@ public void testViewEmails() {
assertEquals(true, email.isVerified());
assertEquals(false, email.isPrimary());
}

@Test
public void viewNonProfessionalEmailsOnEmail() {
String orcid = "0000-0000-0000-0001";
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_LIMITED);
Response r = serviceDelegator.viewEmails(orcid);
Emails p = (Emails) r.getEntity();
assertEquals(1, p.getEmails().size());
Email e = p.getEmails().get(0);
assertTrue(e.isVerified());
assertEquals("APP-5555555555555555", e.getSource().retrieveSourcePath());
assertEquals("Source Client 1", e.getSource().getSourceName().getContent());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -634,4 +634,19 @@ 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 viewNonProfessionalEmailsOnPerson() {
String orcid = "0000-0000-0000-0001";
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_LIMITED);
Response r = serviceDelegator.viewPerson(orcid);
Person p = (Person) r.getEntity();
assertNotNull(p);
assertNotNull(p.getEmails());
assertEquals(1, p.getEmails().getEmails().size());
Email e = p.getEmails().getEmails().get(0);
assertTrue(e.isVerified());
assertEquals("APP-5555555555555555", e.getSource().retrieveSourcePath());
assertEquals("Source Client 1", e.getSource().getSourceName().getContent());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,17 @@ public void testViewEmails() {
assertEquals(true, email.isVerified());
assertEquals(false, email.isPrimary());
}

@Test
public void viewNonProfessionalEmailsOnEmail() {
String orcid = "0000-0000-0000-0001";
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_LIMITED);
Response r = serviceDelegator.viewEmails(orcid);
Emails p = (Emails) r.getEntity();
assertEquals(1, p.getEmails().size());
Email e = p.getEmails().get(0);
assertTrue(e.isVerified());
assertEquals("APP-5555555555555555", e.getSource().retrieveSourcePath());
assertEquals("Source Client 1", e.getSource().getSourceName().getContent());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,7 @@
import org.orcid.jaxb.model.groupid_v2.GroupIdRecord;
import org.orcid.jaxb.model.message.ScopePathType;
import org.orcid.jaxb.model.v3.release.common.Visibility;
import org.orcid.jaxb.model.v3.release.record.Address;
import org.orcid.jaxb.model.v3.release.record.Addresses;
import org.orcid.jaxb.model.v3.release.record.Biography;
import org.orcid.jaxb.model.v3.release.record.Distinction;
import org.orcid.jaxb.model.v3.release.record.Education;
import org.orcid.jaxb.model.v3.release.record.Email;
import org.orcid.jaxb.model.v3.release.record.Emails;
import org.orcid.jaxb.model.v3.release.record.Employment;
import org.orcid.jaxb.model.v3.release.record.Funding;
import org.orcid.jaxb.model.v3.release.record.InvitedPosition;
import org.orcid.jaxb.model.v3.release.record.Keyword;
import org.orcid.jaxb.model.v3.release.record.Keywords;
import org.orcid.jaxb.model.v3.release.record.Membership;
import org.orcid.jaxb.model.v3.release.record.OtherName;
import org.orcid.jaxb.model.v3.release.record.OtherNames;
import org.orcid.jaxb.model.v3.release.record.PeerReview;
import org.orcid.jaxb.model.v3.release.record.Person;
import org.orcid.jaxb.model.v3.release.record.PersonExternalIdentifier;
import org.orcid.jaxb.model.v3.release.record.PersonExternalIdentifiers;
import org.orcid.jaxb.model.v3.release.record.Qualification;
import org.orcid.jaxb.model.v3.release.record.ResearchResource;
import org.orcid.jaxb.model.v3.release.record.ResearcherUrl;
import org.orcid.jaxb.model.v3.release.record.ResearcherUrls;
import org.orcid.jaxb.model.v3.release.record.Service;
import org.orcid.jaxb.model.v3.release.record.Work;
import org.orcid.jaxb.model.v3.release.record.WorkBulk;
import org.orcid.jaxb.model.v3.release.record.*;
import org.orcid.test.DBUnitTest;
import org.orcid.test.OrcidJUnit4ClassRunner;
import org.orcid.test.helper.v3.Utils;
Expand Down Expand Up @@ -666,4 +641,19 @@ 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 viewNonProfessionalEmailsOnPerson() {
String orcid = "0000-0000-0000-0001";
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_LIMITED);
Response r = serviceDelegator.viewPerson(orcid);
Person p = (Person) r.getEntity();
assertNotNull(p);
assertNotNull(p.getEmails());
assertEquals(1, p.getEmails().getEmails().size());
Email e = p.getEmails().getEmails().get(0);
assertTrue(e.isVerified());
assertEquals("APP-5555555555555555", e.getSource().retrieveSourcePath());
assertEquals("Source Client 1", e.getSource().getSourceName().getContent());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ public class PublicV2ApiServiceDelegatorTest extends DBUnitTest {

private final String ORCID = "0000-0000-0000-0003";
private String deactivatedUserOrcid = "0000-0000-0000-0007";

@Resource(name = "publicV2ApiServiceDelegator")
PublicV2ApiServiceDelegator<?, ?, ?, ?, ?, ?, ?, ?, ?> serviceDelegator;

@Resource
SchemaOrgMBWriterV2 writerV2;

@BeforeClass
public static void initDBUnitData() throws Exception {
initDBUnitData(DATA_FILES);
Expand Down Expand Up @@ -184,7 +184,7 @@ public void testViewBulkWorks() {
assertNotNull(workBulk);
assertNotNull(workBulk.getBulk());
assertEquals(3, workBulk.getBulk().size());
assertTrue(workBulk.getBulk().get(0) instanceof Work);
assertTrue(workBulk.getBulk().get(0) instanceof Work);
assertTrue(workBulk.getBulk().get(1) instanceof OrcidError);
assertTrue(workBulk.getBulk().get(2) instanceof OrcidError);
Work work = (Work) workBulk.getBulk().get(0);
Expand Down Expand Up @@ -223,7 +223,7 @@ public void testViewFunding() {
assertEquals("APP-5555555555555555", funding.getSource().retrieveSourcePath());
assertNotNull(funding.getContributors().getContributor().get(0).getContributorOrcid());
assertEquals("0000-0000-0000-0000", funding.getContributors().getContributor().get(0).getContributorOrcid().getPath());
assertNull(funding.getContributors().getContributor().get(0).getCreditName());
assertNull(funding.getContributors().getContributor().get(0).getCreditName());
}

@Test
Expand Down Expand Up @@ -466,7 +466,7 @@ public void testViewExternalIdentifiers() {
assertNotNull(extIds.getLastModifiedDate().getValue());
assertEquals("/0000-0000-0000-0003/external-identifiers", extIds.getPath());
assertEquals(3, extIds.getExternalIdentifiers().size());

PersonExternalIdentifier extId = extIds.getExternalIdentifiers().get(0);
assertNotNull(extId);
assertNotNull(extId.getLastModifiedDate());
Expand All @@ -478,7 +478,7 @@ public void testViewExternalIdentifiers() {
assertEquals(Visibility.PUBLIC.value(), extId.getVisibility().value());
assertEquals("/0000-0000-0000-0003/external-identifiers/19", extId.getPath());
assertEquals("APP-5555555555555558", extId.getSource().retrieveSourcePath());

extId = extIds.getExternalIdentifiers().get(1);
assertNotNull(extId);
assertNotNull(extId.getLastModifiedDate());
Expand All @@ -490,7 +490,7 @@ public void testViewExternalIdentifiers() {
assertEquals(Visibility.PUBLIC.value(), extId.getVisibility().value());
assertEquals("/0000-0000-0000-0003/external-identifiers/18", extId.getPath());
assertEquals("0000-0000-0000-0003", extId.getSource().retrieveSourcePath());

extId = extIds.getExternalIdentifiers().get(2);
assertNotNull(extId);
assertNotNull(extId.getLastModifiedDate());
Expand Down Expand Up @@ -1184,11 +1184,11 @@ public void testSearchByQuery() {
result.setOrcidIdentifier(new OrcidIdentifier("some-orcid-id"));
search.getResults().add(result);
OrcidSearchManager orcidSearchManager = Mockito.mock(OrcidSearchManagerImpl.class);
Mockito.when(orcidSearchManager.findOrcidIds(Matchers.<Map<String, List<String>>> any())).thenReturn(search);
Mockito.when(orcidSearchManager.findOrcidIds(Matchers.<Map<String, List<String>>>any())).thenReturn(search);

PublicV2ApiServiceDelegatorImpl delegator = new PublicV2ApiServiceDelegatorImpl();
ReflectionTestUtils.setField(delegator, "orcidSearchManager", orcidSearchManager);

OrcidSecurityManager orcidSecurityManager = Mockito.mock(OrcidSecurityManagerImpl.class);
Mockito.when(orcidSecurityManager.getClientIdFromAPIRequest()).thenReturn(null);
ReflectionTestUtils.setField(delegator, "orcidSecurityManager", orcidSecurityManager);
Expand Down Expand Up @@ -1222,7 +1222,7 @@ public void testSearchByQueryIllegalStart() {

LocaleManager localeManager = Mockito.mock(LocaleManagerImpl.class);
Mockito.when(localeManager.resolveMessage(Mockito.anyString())).thenReturn("a message");

OrcidSecurityManager orcidSecurityManager = Mockito.mock(OrcidSecurityManagerImpl.class);
Mockito.when(orcidSecurityManager.getClientIdFromAPIRequest()).thenReturn(null);

Expand All @@ -1242,7 +1242,7 @@ public void testSearchByQueryLegalStart() {

OrcidSearchManager orcidSearchManager = Mockito.mock(OrcidSearchManagerImpl.class);
Mockito.when(orcidSearchManager.findOrcidIds(Mockito.anyMap())).thenReturn(new Search());

OrcidSecurityManager orcidSecurityManager = Mockito.mock(OrcidSecurityManagerImpl.class);
Mockito.when(orcidSecurityManager.getClientIdFromAPIRequest()).thenReturn(null);

Expand Down Expand Up @@ -1317,9 +1317,9 @@ private void validatePerson(Person person) {
assertNotNull(person.getExternalIdentifiers().getLastModifiedDate().getValue());
assertEquals("/0000-0000-0000-0003/external-identifiers", person.getExternalIdentifiers().getPath());
assertEquals(3, person.getExternalIdentifiers().getExternalIdentifiers().size());

PersonExternalIdentifiers extIds = person.getExternalIdentifiers();

assertNotNull(extIds);
PersonExternalIdentifier extId = extIds.getExternalIdentifiers().get(0);
assertNotNull(extId);
Expand All @@ -1332,7 +1332,7 @@ private void validatePerson(Person person) {
assertEquals(Visibility.PUBLIC.value(), extId.getVisibility().value());
assertEquals("/0000-0000-0000-0003/external-identifiers/19", extId.getPath());
assertEquals("APP-5555555555555558", extId.getSource().retrieveSourcePath());

extId = extIds.getExternalIdentifiers().get(1);
assertNotNull(extId);
assertNotNull(extId.getLastModifiedDate());
Expand All @@ -1344,7 +1344,7 @@ private void validatePerson(Person person) {
assertEquals(Visibility.PUBLIC.value(), extId.getVisibility().value());
assertEquals("/0000-0000-0000-0003/external-identifiers/18", extId.getPath());
assertEquals("0000-0000-0000-0003", extId.getSource().retrieveSourcePath());

extId = extIds.getExternalIdentifiers().get(2);
assertNotNull(extId);
assertNotNull(extId.getLastModifiedDate());
Expand All @@ -1356,7 +1356,7 @@ private void validatePerson(Person person) {
assertEquals(Visibility.PUBLIC.value(), extId.getVisibility().value());
assertEquals("/0000-0000-0000-0003/external-identifiers/13", extId.getPath());
assertEquals("APP-5555555555555555", extId.getSource().retrieveSourcePath());

assertNotNull(person.getKeywords());
assertNotNull(person.getKeywords().getLastModifiedDate());
assertNotNull(person.getKeywords().getLastModifiedDate().getValue());
Expand Down Expand Up @@ -1506,9 +1506,9 @@ private void validateRecord(Record record) {
OrcidIdentifier id = record.getOrcidIdentifier();
assertEquals("0000-0000-0000-0003", id.getPath());
}

@Test
public void testSchemaOrgMBWriterV2() throws WebApplicationException, IOException{
public void testSchemaOrgMBWriterV2() throws WebApplicationException, IOException {
Response response = serviceDelegator.viewRecord(ORCID);
Record record = (Record) response.getEntity();
ByteArrayOutputStream out = new ByteArrayOutputStream();
Expand All @@ -1517,22 +1517,22 @@ public void testSchemaOrgMBWriterV2() throws WebApplicationException, IOExceptio
objectMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
SchemaOrgDocument doc = objectMapper.readerFor(SchemaOrgDocument.class).readValue(out.toString());
assertTrue(doc.id.endsWith(ORCID));
assertEquals("Person",doc.type);
assertEquals("http://schema.org",doc.context);
assertEquals("Credit Name",doc.name);
assertEquals("Given Names",doc.givenName);
assertEquals("Family Name",doc.familyName);
assertEquals("Other Name PUBLIC",doc.alternateName.get(0));
assertEquals("WDB",doc.alumniOf.iterator().next().identifier.iterator().next().propertyID);
assertEquals("WDB",doc.affiliation.iterator().next().identifier.iterator().next().propertyID);
assertEquals("Person", doc.type);
assertEquals("http://schema.org", doc.context);
assertEquals("Credit Name", doc.name);
assertEquals("Given Names", doc.givenName);
assertEquals("Family Name", doc.familyName);
assertEquals("Other Name PUBLIC", doc.alternateName.get(0));
assertEquals("WDB", doc.alumniOf.iterator().next().identifier.iterator().next().propertyID);
assertEquals("WDB", doc.affiliation.iterator().next().identifier.iterator().next().propertyID);
Set<String> fundingIds = Sets.newHashSet();
for (SchemaOrgExternalID i: doc.worksAndFunding.funder.iterator().next().identifier)
for (SchemaOrgExternalID i : doc.worksAndFunding.funder.iterator().next().identifier)
fundingIds.add(i.propertyID);
assertEquals(Sets.newHashSet("WDB","grant_number"),fundingIds);
assertEquals("PUBLIC",doc.worksAndFunding.creator.iterator().next().name);
assertEquals("http://www.researcherurl.com?id=13",doc.url.get(0));
assertEquals("self_public_user_obo_type",doc.identifier.get(0).propertyID);
assertEquals( "self_public_user_obo_ref",doc.identifier.get(0).value);
assertEquals(Sets.newHashSet("WDB", "grant_number"), fundingIds);
assertEquals("PUBLIC", doc.worksAndFunding.creator.iterator().next().name);
assertEquals("http://www.researcherurl.com?id=13", doc.url.get(0));
assertEquals("self_public_user_obo_type", doc.identifier.get(0).propertyID);
assertEquals("self_public_user_obo_ref", doc.identifier.get(0).value);
}

@Test
Expand All @@ -1550,4 +1550,32 @@ public void viewNonProfessionalEmailsOnRecord() {
assertEquals("APP-5555555555555555", e.getSource().retrieveSourcePath());
assertEquals("Source Client 1", e.getSource().getSourceName().getContent());
}
}

@Test
public void viewNonProfessionalEmailsOnPerson() {
String orcid = "0000-0000-0000-0001";
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_LIMITED);
Response r = serviceDelegator.viewPerson(orcid);
Person p = (Person) r.getEntity();
assertNotNull(p);
assertNotNull(p.getEmails());
assertEquals(1, p.getEmails().getEmails().size());

Check failure on line 1562 in orcid-pub-web/src/test/java/org/orcid/api/publicV2/server/PublicV2ApiServiceDelegatorTest.java

View workflow job for this annotation

GitHub Actions / Unit test report for orcid-pub-web

org.orcid.api.publicV2.server.PublicV2ApiServiceDelegatorTest ► viewNonProfessionalEmailsOnPerson

Failed test found in: orcid-pub-web/target/surefire-reports/TEST-org.orcid.api.publicV2.server.PublicV2ApiServiceDelegatorTest.xml Error: java.lang.AssertionError: expected:<1> but was:<2>
Raw output
java.lang.AssertionError: expected:<1> but was:<2>
	at org.orcid.api.publicV2.server.PublicV2ApiServiceDelegatorTest.viewNonProfessionalEmailsOnPerson(PublicV2ApiServiceDelegatorTest.java:1562)
Email e = p.getEmails().getEmails().get(0);
assertTrue(e.isVerified());
assertEquals("APP-5555555555555555", e.getSource().retrieveSourcePath());
assertEquals("Source Client 1", e.getSource().getSourceName().getContent());
}

@Test
public void viewNonProfessionalEmailsOnEmail() {
String orcid = "0000-0000-0000-0001";
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_LIMITED);
Response r = serviceDelegator.viewEmails(orcid);
Emails p = (Emails) r.getEntity();
assertEquals(1, p.getEmails().size());

Check failure on line 1575 in orcid-pub-web/src/test/java/org/orcid/api/publicV2/server/PublicV2ApiServiceDelegatorTest.java

View workflow job for this annotation

GitHub Actions / Unit test report for orcid-pub-web

org.orcid.api.publicV2.server.PublicV2ApiServiceDelegatorTest ► viewNonProfessionalEmailsOnEmail

Failed test found in: orcid-pub-web/target/surefire-reports/TEST-org.orcid.api.publicV2.server.PublicV2ApiServiceDelegatorTest.xml Error: java.lang.AssertionError: expected:<1> but was:<2>
Raw output
java.lang.AssertionError: expected:<1> but was:<2>
	at org.orcid.api.publicV2.server.PublicV2ApiServiceDelegatorTest.viewNonProfessionalEmailsOnEmail(PublicV2ApiServiceDelegatorTest.java:1575)
Email e = p.getEmails().get(0);
assertTrue(e.isVerified());
assertEquals("APP-5555555555555555", e.getSource().retrieveSourcePath());
assertEquals("Source Client 1", e.getSource().getSourceName().getContent());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2203,4 +2203,32 @@ public void viewNonProfessionalEmailsOnRecord() {
assertEquals("APP-5555555555555555", e.getSource().retrieveSourcePath());
assertEquals("Source Client 1", e.getSource().getSourceName().getContent());
}

@Test
public void viewNonProfessionalEmailsOnPerson() {
String orcid = "0000-0000-0000-0001";
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_LIMITED);
Response r = serviceDelegator.viewPerson(orcid);
Person p = (Person) r.getEntity();
assertNotNull(p);
assertNotNull(p.getEmails());
assertEquals(1, p.getEmails().getEmails().size());

Check failure on line 2215 in orcid-pub-web/src/test/java/org/orcid/api/publicV3/server/PublicV3ApiServiceDelegatorTest.java

View workflow job for this annotation

GitHub Actions / Unit test report for orcid-pub-web

org.orcid.api.publicV3.server.PublicV3ApiServiceDelegatorTest ► viewNonProfessionalEmailsOnPerson

Failed test found in: orcid-pub-web/target/surefire-reports/TEST-org.orcid.api.publicV3.server.PublicV3ApiServiceDelegatorTest.xml Error: java.lang.AssertionError: expected:<1> but was:<2>
Raw output
java.lang.AssertionError: expected:<1> but was:<2>
	at org.orcid.api.publicV3.server.PublicV3ApiServiceDelegatorTest.viewNonProfessionalEmailsOnPerson(PublicV3ApiServiceDelegatorTest.java:2215)
Email e = p.getEmails().getEmails().get(0);
assertTrue(e.isVerified());
assertEquals("APP-5555555555555555", e.getSource().retrieveSourcePath());
assertEquals("Source Client 1", e.getSource().getSourceName().getContent());
}

@Test
public void viewNonProfessionalEmailsOnEmail() {
String orcid = "0000-0000-0000-0001";
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_LIMITED);
Response r = serviceDelegator.viewEmails(orcid);
Emails p = (Emails) r.getEntity();
assertEquals(1, p.getEmails().size());

Check failure on line 2228 in orcid-pub-web/src/test/java/org/orcid/api/publicV3/server/PublicV3ApiServiceDelegatorTest.java

View workflow job for this annotation

GitHub Actions / Unit test report for orcid-pub-web

org.orcid.api.publicV3.server.PublicV3ApiServiceDelegatorTest ► viewNonProfessionalEmailsOnEmail

Failed test found in: orcid-pub-web/target/surefire-reports/TEST-org.orcid.api.publicV3.server.PublicV3ApiServiceDelegatorTest.xml Error: java.lang.AssertionError: expected:<1> but was:<2>
Raw output
java.lang.AssertionError: expected:<1> but was:<2>
	at org.orcid.api.publicV3.server.PublicV3ApiServiceDelegatorTest.viewNonProfessionalEmailsOnEmail(PublicV3ApiServiceDelegatorTest.java:2228)
Email e = p.getEmails().get(0);
assertTrue(e.isVerified());
assertEquals("APP-5555555555555555", e.getSource().retrieveSourcePath());
assertEquals("Source Client 1", e.getSource().getSourceName().getContent());
}
}
19 changes: 16 additions & 3 deletions orcid-test/src/main/resources/data/ProfileEntityData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1813,7 +1813,20 @@
client_source_id="APP-5555555555555555"
date_created="2016-01-01 00:00:00.00"
last_modified="2016-01-01 00:00:00.00"
/>
/>

<email
orcid="0000-0000-0000-0001"
email="[email protected]"
email_hash="bb24ead143f1a58f97394436a0548e7bc3d30a539188accd5d82a28af4345778"
is_primary="true"
is_current="false"
is_verified="true"
visibility="PUBLIC"
client_source_id="APP-5555555555555555"
date_created="2016-01-01 00:00:00.00"
last_modified="2016-01-01 00:00:00.00"
/>

<email
orcid="0000-0000-0000-0002"
Expand Down Expand Up @@ -1955,8 +1968,8 @@
source_id="0000-0000-0000-0004"
date_created="2016-01-01 00:00:00.00"
last_modified="2016-01-01 00:00:00.00"
/>
/>

<email
orcid="4444-4444-4444-4497"
email="[email protected]"
Expand Down

0 comments on commit 7d111db

Please sign in to comment.