use of org.orcid.jaxb.model.v3.dev1.record.Biography in project ORCID-Source by ORCID.
the class PublicV3ApiServiceDelegatorTest method testGetPublicBiographyUsingToken.
// Biography
@Test
public void testGetPublicBiographyUsingToken() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response r = serviceDelegator.viewBiography(ORCID);
assertNotNull(r);
Biography b = (Biography) r.getEntity();
assertNotNull(b);
assertNotNull(b.getLastModifiedDate());
assertNotNull(b.getLastModifiedDate().getValue());
assertEquals(Visibility.PUBLIC, b.getVisibility());
}
use of org.orcid.jaxb.model.v3.dev1.record.Biography 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.Biography in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV3Test method getPersonElement.
private Person getPersonElement() {
Visibility[] vs = { Visibility.PUBLIC, Visibility.PUBLIC, Visibility.PUBLIC };
Person p = new Person();
p.setAddresses(getAddressesElement(vs));
p.setEmails(getEmailsElement(vs));
p.setExternalIdentifiers(getPersonExternalIdentifiersElement(vs));
p.setKeywords(getKeywordsElement(vs));
p.setOtherNames(getOtherNamesElement(vs));
p.setResearcherUrls(getResearcherUrlsElement(vs));
Name name = new Name();
name.setVisibility(Visibility.PUBLIC);
p.setName(name);
Biography b = new Biography();
b.setVisibility(Visibility.PUBLIC);
b.setContent("Biography test");
p.setBiography(b);
return p;
}
use of org.orcid.jaxb.model.v3.dev1.record.Biography in project ORCID-Source by ORCID.
the class PublicV3ApiServiceDelegatorImpl method viewBiography.
@Override
public Response viewBiography(String orcid) {
Biography bio = biographyManagerReadOnly.getBiography(orcid);
publicAPISecurityManagerV3.checkIsPublic(bio);
ElementUtils.setPathToBiography(bio, orcid);
return Response.ok(bio).build();
}
use of org.orcid.jaxb.model.v3.dev1.record.Biography in project ORCID-Source by ORCID.
the class GetMyDataControllerTest method before.
@Before
public void before() {
MockitoAnnotations.initMocks(this);
TargetProxyHelper.injectIntoProxy(getMyDataController, "batchSize", 50);
TargetProxyHelper.injectIntoProxy(getMyDataController, "personDetailsManager", mockPersonDetailsManager);
TargetProxyHelper.injectIntoProxy(getMyDataController, "workEntityCacheManager", mockWorkEntityCacheManager);
TargetProxyHelper.injectIntoProxy(getMyDataController, "affiliationManagerReadOnly", mockAffiliationManagerReadOnly);
TargetProxyHelper.injectIntoProxy(getMyDataController, "profileFundingManagerReadOnly", mockProfileFundingManagerReadOnly);
TargetProxyHelper.injectIntoProxy(getMyDataController, "peerReviewManagerReadOnly", mockPeerReviewManagerReadOnly);
TargetProxyHelper.injectIntoProxy(getMyDataController, "workManagerReadOnly", mockWorkManagerReadOnly);
when(mockPersonDetailsManager.getPersonDetails(anyString())).thenAnswer(new Answer<Person>() {
@Override
public Person answer(InvocationOnMock invocation) throws Throwable {
Person p = new Person();
p.setBiography(new Biography("Biography", Visibility.LIMITED));
Name name = new Name();
name.setVisibility(Visibility.LIMITED);
name.setFamilyName(new FamilyName("Family Name"));
name.setGivenNames(new GivenNames("Given Names"));
name.setCreditName(new CreditName("Credit Name"));
p.setName(name);
return p;
}
});
when(mockAffiliationManagerReadOnly.getAffiliations(anyString())).thenAnswer(new Answer<List<Affiliation>>() {
@Override
public List<Affiliation> answer(InvocationOnMock invocation) throws Throwable {
List<Affiliation> affs = new ArrayList<Affiliation>();
FuzzyDate startDate = new FuzzyDate(new Year(2018), new Month(1), new Day(1));
FuzzyDate endDate = new FuzzyDate(new Year(2018), new Month(12), new Day(31));
Distinction d = new Distinction();
d.setDepartmentName("distinction");
d.setEndDate(endDate);
d.setStartDate(startDate);
d.setPutCode(1L);
setOrg(d);
affs.add(d);
Education e = new Education();
e.setDepartmentName("education");
e.setEndDate(endDate);
e.setStartDate(startDate);
e.setPutCode(2L);
setOrg(e);
affs.add(e);
Employment emp = new Employment();
emp.setDepartmentName("employment");
emp.setEndDate(endDate);
emp.setStartDate(startDate);
emp.setPutCode(3L);
setOrg(emp);
affs.add(emp);
InvitedPosition i = new InvitedPosition();
i.setDepartmentName("invited position");
i.setEndDate(endDate);
i.setStartDate(startDate);
i.setPutCode(4L);
setOrg(i);
affs.add(i);
Membership m = new Membership();
m.setDepartmentName("membership");
m.setEndDate(endDate);
m.setStartDate(startDate);
m.setPutCode(5L);
setOrg(m);
affs.add(m);
Qualification q = new Qualification();
q.setDepartmentName("qualification");
q.setEndDate(endDate);
q.setStartDate(startDate);
q.setPutCode(6L);
setOrg(q);
affs.add(q);
Service s = new Service();
s.setDepartmentName("service");
s.setEndDate(endDate);
s.setStartDate(startDate);
s.setPutCode(7L);
setOrg(s);
affs.add(s);
return affs;
}
});
when(mockProfileFundingManagerReadOnly.getFundingList(anyString())).thenAnswer(new Answer<List<Funding>>() {
@Override
public List<Funding> answer(InvocationOnMock invocation) throws Throwable {
List<Funding> fundings = new ArrayList<Funding>();
Funding f = new Funding();
Amount a = new Amount();
a.setContent("1000");
a.setCurrencyCode("$");
f.setAmount(a);
FundingTitle t = new FundingTitle();
t.setTitle(new Title("title"));
f.setTitle(t);
setOrg(f);
f.setPutCode(1L);
fundings.add(f);
return fundings;
}
});
when(mockPeerReviewManagerReadOnly.findPeerReviews(anyString())).thenAnswer(new Answer<List<PeerReview>>() {
@Override
public List<PeerReview> answer(InvocationOnMock invocation) throws Throwable {
List<PeerReview> peerReviews = new ArrayList<PeerReview>();
PeerReview p = new PeerReview();
setOrg(p);
p.setPutCode(1L);
peerReviews.add(p);
return peerReviews;
}
});
when(mockWorkManagerReadOnly.findWorks(anyString(), any())).thenAnswer(new Answer<List<Work>>() {
@Override
public List<Work> answer(InvocationOnMock invocation) throws Throwable {
List<Work> works = new ArrayList<Work>();
Work w = new Work();
WorkTitle t = new WorkTitle();
t.setTitle(new Title("title"));
w.setPutCode(1L);
works.add(w);
return works;
}
});
when(mockWorkManagerReadOnly.getLastModified(anyString())).thenReturn(0L);
when(mockWorkEntityCacheManager.retrieveWorkLastModifiedList(anyString(), anyLong())).thenAnswer(new Answer<List<WorkLastModifiedEntity>>() {
@Override
public List<WorkLastModifiedEntity> answer(InvocationOnMock invocation) throws Throwable {
List<WorkLastModifiedEntity> works = new ArrayList<WorkLastModifiedEntity>();
WorkLastModifiedEntity w = new WorkLastModifiedEntity();
w.setId(1L);
w.setOrcid(ORCID);
w.setLastModified(new Date());
works.add(w);
return works;
}
});
}
Aggregations