use of org.orcid.jaxb.model.v3.dev1.record.Emails in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_EmailsTest method testReadEmailPrivate.
@Test
public void testReadEmailPrivate() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4497", ScopePathType.EMAIL_READ_PRIVATE);
Response r = serviceDelegator.viewEmails("4444-4444-4444-4497");
assertNotNull(r);
assertEquals(Emails.class.getName(), r.getEntity().getClass().getName());
Emails email = (Emails) r.getEntity();
assertNotNull(email);
assertEquals("/4444-4444-4444-4497/email", email.getPath());
assertNotNull(email.getLastModifiedDate());
assertEquals(3, email.getEmails().size());
assertEquals("public_4444-4444-4444-4497@test.orcid.org", email.getEmails().get(0).getEmail());
assertEquals(Visibility.PUBLIC, email.getEmails().get(0).getVisibility());
assertEquals("limited_4444-4444-4444-4497@test.orcid.org", email.getEmails().get(1).getEmail());
assertEquals(Visibility.LIMITED, email.getEmails().get(1).getVisibility());
assertEquals("private_4444-4444-4444-4497@test.orcid.org", email.getEmails().get(2).getEmail());
assertEquals(Visibility.PRIVATE, email.getEmails().get(2).getVisibility());
}
use of org.orcid.jaxb.model.v3.dev1.record.Emails in project ORCID-Source by ORCID.
the class PublicV3ApiServiceDelegatorTest method testViewEmails.
@Test
public void testViewEmails() {
Response response = serviceDelegator.viewEmails(ORCID);
assertNotNull(response);
Emails emails = (Emails) response.getEntity();
assertNotNull(emails);
assertNotNull(emails.getLastModifiedDate());
assertNotNull(emails.getLastModifiedDate().getValue());
assertNotNull(emails.getEmails());
assertEquals(1, emails.getEmails().size());
Email email = emails.getEmails().get(0);
assertNotNull(email.getLastModifiedDate());
assertNotNull(email.getLastModifiedDate().getValue());
assertEquals("public_0000-0000-0000-0003@test.orcid.org", email.getEmail());
assertTrue(email.isCurrent());
assertTrue(email.isPrimary());
assertTrue(email.isVerified());
assertEquals(Visibility.PUBLIC.value(), email.getVisibility().value());
assertEquals("/0000-0000-0000-0003/email", emails.getPath());
assertEquals("APP-5555555555555555", email.getSource().retrieveSourcePath());
}
use of org.orcid.jaxb.model.v3.dev1.record.Emails in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV3Test method checkIsPublicRecordTest.
@Test
public void checkIsPublicRecordTest() {
Record r = getRecordElement();
publicAPISecurityManagerV3.filter(r);
// Verify activities - nothing filtered
ActivitiesSummary as = r.getActivitiesSummary();
assertEquals(3, as.getEducations().getSummaries().size());
assertContainerContainsOnlyPublicElements(as.getEducations());
assertEquals(3, as.getEmployments().getSummaries().size());
assertContainerContainsOnlyPublicElements(as.getEmployments());
assertEquals(3, as.getFundings().getFundingGroup().size());
assertGroupContainsOnlyPublicElements(as.getFundings());
assertEquals(3, as.getPeerReviews().getPeerReviewGroup().size());
assertGroupContainsOnlyPublicElements(as.getPeerReviews());
assertEquals(3, as.getWorks().getWorkGroup().size());
assertGroupContainsOnlyPublicElements(as.getWorks());
assertEquals(3, as.getDistinctions().getSummaries().size());
assertContainerContainsOnlyPublicElements(as.getDistinctions());
assertEquals(3, as.getInvitedPositions().getSummaries().size());
assertContainerContainsOnlyPublicElements(as.getInvitedPositions());
assertEquals(3, as.getMemberships().getSummaries().size());
assertContainerContainsOnlyPublicElements(as.getMemberships());
assertEquals(3, as.getQualifications().getSummaries().size());
assertContainerContainsOnlyPublicElements(as.getQualifications());
assertEquals(3, as.getServices().getSummaries().size());
assertContainerContainsOnlyPublicElements(as.getServices());
// Verify bio sections - nothing filtered
Person p = r.getPerson();
assertEquals(3, p.getAddresses().getAddress().size());
assertAllArePublic(p.getAddresses().getAddress());
assertEquals(3, p.getEmails().getEmails().size());
assertAllArePublic(p.getEmails().getEmails());
assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
assertAllArePublic(p.getExternalIdentifiers().getExternalIdentifiers());
assertEquals(3, p.getKeywords().getKeywords().size());
assertAllArePublic(p.getKeywords().getKeywords());
assertEquals(3, p.getOtherNames().getOtherNames().size());
assertAllArePublic(p.getOtherNames().getOtherNames());
assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
assertAllArePublic(p.getResearcherUrls().getResearcherUrls());
assertNotNull(p.getBiography());
assertNotNull(p.getName());
// Filter biography, name, educations and funding
r = getRecordElement();
r.getPerson().getBiography().setVisibility(Visibility.LIMITED);
r.getPerson().getName().setVisibility(Visibility.LIMITED);
setVisibility(r.getActivitiesSummary().getEducations().getSummaries(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
setVisibility(r.getActivitiesSummary().getFundings(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
publicAPISecurityManagerV3.filter(r);
// Verify activities - educations and funding filtered
as = r.getActivitiesSummary();
assertNotNull(as.getEducations());
assertTrue(as.getEducations().getSummaries().isEmpty());
assertEquals(3, as.getEmployments().getSummaries().size());
assertTrue(as.getFundings().getFundingGroup().isEmpty());
assertEquals(3, as.getPeerReviews().getPeerReviewGroup().size());
assertEquals(3, as.getWorks().getWorkGroup().size());
assertEquals(3, as.getDistinctions().getSummaries().size());
assertContainerContainsOnlyPublicElements(as.getDistinctions());
assertEquals(3, as.getInvitedPositions().getSummaries().size());
assertContainerContainsOnlyPublicElements(as.getInvitedPositions());
assertEquals(3, as.getMemberships().getSummaries().size());
assertContainerContainsOnlyPublicElements(as.getMemberships());
assertEquals(3, as.getQualifications().getSummaries().size());
assertContainerContainsOnlyPublicElements(as.getQualifications());
assertEquals(3, as.getServices().getSummaries().size());
assertContainerContainsOnlyPublicElements(as.getServices());
// Verify bio sections - bio and name filtered
p = r.getPerson();
assertEquals(3, p.getAddresses().getAddress().size());
assertEquals(3, p.getEmails().getEmails().size());
assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
assertEquals(3, p.getKeywords().getKeywords().size());
assertEquals(3, p.getOtherNames().getOtherNames().size());
assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
assertNull(p.getBiography());
assertNull(p.getName());
// Filter emails, external identifiers, peer reviews and works
r = getRecordElement();
setVisibility(r.getPerson().getEmails().getEmails(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
setVisibility(r.getPerson().getExternalIdentifiers().getExternalIdentifiers(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
setVisibility(r.getActivitiesSummary().getPeerReviews(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
setVisibility(r.getActivitiesSummary().getWorks(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
publicAPISecurityManagerV3.filter(r);
// Verify activities - peer reviews and works filtered
as = r.getActivitiesSummary();
assertEquals(3, as.getEducations().getSummaries().size());
assertEquals(3, as.getEmployments().getSummaries().size());
assertEquals(3, as.getFundings().getFundingGroup().size());
assertTrue(as.getPeerReviews().getPeerReviewGroup().isEmpty());
assertTrue(as.getWorks().getWorkGroup().isEmpty());
assertEquals(3, as.getDistinctions().getSummaries().size());
assertContainerContainsOnlyPublicElements(as.getDistinctions());
assertEquals(3, as.getInvitedPositions().getSummaries().size());
assertContainerContainsOnlyPublicElements(as.getInvitedPositions());
assertEquals(3, as.getMemberships().getSummaries().size());
assertContainerContainsOnlyPublicElements(as.getMemberships());
assertEquals(3, as.getQualifications().getSummaries().size());
assertContainerContainsOnlyPublicElements(as.getQualifications());
assertEquals(3, as.getServices().getSummaries().size());
assertContainerContainsOnlyPublicElements(as.getServices());
// Verify bio sections - emails, external identifiers filtered
p = r.getPerson();
assertEquals(3, p.getAddresses().getAddress().size());
assertNotNull(p.getEmails());
assertTrue(p.getEmails().getEmails().isEmpty());
assertNotNull(p.getExternalIdentifiers());
assertTrue(p.getExternalIdentifiers().getExternalIdentifiers().isEmpty());
assertEquals(3, p.getKeywords().getKeywords().size());
assertEquals(3, p.getOtherNames().getOtherNames().size());
assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
assertNotNull(p.getBiography());
assertNotNull(p.getName());
// Filter keywords and other names
r = getRecordElement();
setVisibility(r.getPerson().getOtherNames().getOtherNames(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
setVisibility(r.getPerson().getKeywords().getKeywords(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
publicAPISecurityManagerV3.filter(r);
// Verify activities - nothing filtered
as = r.getActivitiesSummary();
assertEquals(3, as.getEducations().getSummaries().size());
assertEquals(3, as.getEmployments().getSummaries().size());
assertEquals(3, as.getFundings().getFundingGroup().size());
assertEquals(3, as.getPeerReviews().getPeerReviewGroup().size());
assertEquals(3, as.getWorks().getWorkGroup().size());
assertEquals(3, as.getDistinctions().getSummaries().size());
assertContainerContainsOnlyPublicElements(as.getDistinctions());
assertEquals(3, as.getInvitedPositions().getSummaries().size());
assertContainerContainsOnlyPublicElements(as.getInvitedPositions());
assertEquals(3, as.getMemberships().getSummaries().size());
assertContainerContainsOnlyPublicElements(as.getMemberships());
assertEquals(3, as.getQualifications().getSummaries().size());
assertContainerContainsOnlyPublicElements(as.getQualifications());
assertEquals(3, as.getServices().getSummaries().size());
assertContainerContainsOnlyPublicElements(as.getServices());
// Verify bio sections - keywords and other names filtered
p = r.getPerson();
assertEquals(3, p.getAddresses().getAddress().size());
assertEquals(3, p.getEmails().getEmails().size());
assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
assertNotNull(p.getKeywords());
assertTrue(p.getKeywords().getKeywords().isEmpty());
assertNotNull(p.getOtherNames());
assertTrue(p.getOtherNames().getOtherNames().isEmpty());
assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
assertNotNull(p.getBiography());
assertNotNull(p.getName());
}
use of org.orcid.jaxb.model.v3.dev1.record.Emails in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV3Test method getEmailsElement.
private Emails getEmailsElement(Visibility... vs) {
Emails elements = new Emails();
for (Visibility v : vs) {
Email element = new Email();
element.setVisibility(v);
if (elements.getEmails() == null) {
elements.setEmails(new ArrayList<Email>());
}
elements.getEmails().add(element);
}
return elements;
}
use of org.orcid.jaxb.model.v3.dev1.record.Emails in project ORCID-Source by ORCID.
the class PublicV3ApiServiceDelegatorImpl method viewEmails.
@Override
public Response viewEmails(String orcid) {
Emails emails = emailManagerReadOnly.getPublicEmails(orcid);
publicAPISecurityManagerV3.filter(emails);
ElementUtils.setPathToEmail(emails, orcid);
Api3_0_Dev1LastModifiedDatesHelper.calculateLastModified(emails);
sourceUtilsReadOnly.setSourceName(emails);
return Response.ok(emails).build();
}
Aggregations