use of org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_ServicesTest method testAddService.
@Test
public void testAddService() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewActivities(ORCID);
assertNotNull(response);
ActivitiesSummary originalSummary = (ActivitiesSummary) response.getEntity();
assertNotNull(originalSummary);
Utils.verifyLastModified(originalSummary.getLastModifiedDate());
assertNotNull(originalSummary.getServices());
Utils.verifyLastModified(originalSummary.getServices().getLastModifiedDate());
assertNotNull(originalSummary.getServices().getSummaries());
assertNotNull(originalSummary.getServices().getSummaries().get(0));
Utils.verifyLastModified(originalSummary.getServices().getSummaries().get(0).getLastModifiedDate());
assertEquals(4, originalSummary.getServices().getSummaries().size());
response = serviceDelegator.createService(ORCID, (Service) Utils.getAffiliation(AffiliationType.SERVICE));
assertNotNull(response);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
Map<?, ?> map = response.getMetadata();
assertNotNull(map);
assertTrue(map.containsKey("Location"));
List<?> resultWithPutCode = (List<?>) map.get("Location");
Long putCode = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
response = serviceDelegator.viewActivities(ORCID);
assertNotNull(response);
ActivitiesSummary summaryWithNewElement = (ActivitiesSummary) response.getEntity();
assertNotNull(summaryWithNewElement);
Utils.verifyLastModified(summaryWithNewElement.getLastModifiedDate());
assertNotNull(summaryWithNewElement.getServices());
Utils.verifyLastModified(summaryWithNewElement.getServices().getLastModifiedDate());
assertNotNull(summaryWithNewElement.getServices().getSummaries());
assertEquals(5, summaryWithNewElement.getServices().getSummaries().size());
boolean haveNew = false;
for (ServiceSummary serviceSummary : summaryWithNewElement.getServices().getSummaries()) {
assertNotNull(serviceSummary.getPutCode());
Utils.verifyLastModified(serviceSummary.getLastModifiedDate());
if (serviceSummary.getPutCode().equals(putCode)) {
assertEquals("My department name", serviceSummary.getDepartmentName());
haveNew = true;
} else {
assertTrue(originalSummary.getServices().getSummaries().contains(serviceSummary));
}
}
assertTrue(haveNew);
// Remove new element
serviceDelegator.deleteAffiliation(ORCID, putCode);
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_WorksTest method testAddWork.
@Test
public void testAddWork() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4445", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewActivities("4444-4444-4444-4445");
assertNotNull(response);
ActivitiesSummary summary = (ActivitiesSummary) response.getEntity();
assertNotNull(summary);
Utils.verifyLastModified(summary.getLastModifiedDate());
// Check works
assertNotNull(summary.getWorks());
assertNotNull(summary.getWorks().getWorkGroup());
assertEquals(1, summary.getWorks().getWorkGroup().size());
Utils.verifyLastModified(summary.getWorks().getLastModifiedDate());
assertNotNull(summary.getWorks().getWorkGroup().get(0));
Utils.verifyLastModified(summary.getWorks().getWorkGroup().get(0).getLastModifiedDate());
assertNotNull(summary.getWorks().getWorkGroup().get(0).getWorkSummary());
assertEquals(1, summary.getWorks().getWorkGroup().get(0).getWorkSummary().size());
String title = "work # 1 " + System.currentTimeMillis();
Work work = Utils.getWork(title);
response = serviceDelegator.createWork("4444-4444-4444-4445", work);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
Long putCode = Utils.getPutCode(response);
response = serviceDelegator.viewActivities("4444-4444-4444-4445");
assertNotNull(response);
summary = (ActivitiesSummary) response.getEntity();
assertNotNull(summary);
Utils.verifyLastModified(summary.getLastModifiedDate());
// Check works
assertNotNull(summary.getWorks());
assertNotNull(summary.getWorks().getWorkGroup());
assertEquals(2, summary.getWorks().getWorkGroup().size());
boolean haveOld = false;
boolean haveNew = false;
for (WorkGroup group : summary.getWorks().getWorkGroup()) {
Utils.verifyLastModified(group.getLastModifiedDate());
assertNotNull(group.getWorkSummary());
assertNotNull(group.getWorkSummary().get(0));
WorkSummary workSummary = group.getWorkSummary().get(0);
Utils.verifyLastModified(workSummary.getLastModifiedDate());
assertNotNull(workSummary.getTitle());
assertNotNull(workSummary.getTitle().getTitle());
if ("A Book With Contributors JSON".equals(workSummary.getTitle().getTitle().getContent())) {
haveOld = true;
} else if (title.equals(workSummary.getTitle().getTitle().getContent())) {
haveNew = true;
}
}
assertTrue(haveOld);
assertTrue(haveNew);
// Delete them
serviceDelegator.deleteWork("4444-4444-4444-4445", putCode);
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary in project ORCID-Source by ORCID.
the class PublicV3ApiServiceDelegatorTest method testValidateActivitiesUsingToken.
@Test
public void testValidateActivitiesUsingToken() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response response = serviceDelegator.viewActivities(ORCID);
assertNotNull(response);
ActivitiesSummary summary = (ActivitiesSummary) response.getEntity();
validateActivities(summary);
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV3Test method checkIsPublicActivitiesSummaryTest.
@Test
public void checkIsPublicActivitiesSummaryTest() {
ActivitiesSummary as = getActivitiesSummaryElement();
publicAPISecurityManagerV3.filter(as);
// Assert it have all activities
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());
// Assert it filters educations
as = getActivitiesSummaryElement();
setVisibility(as.getEducations().getSummaries(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
publicAPISecurityManagerV3.filter(as);
assertNotNull(as.getEducations());
assertTrue(as.getEducations().getSummaries().isEmpty());
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());
// Assert it filters employments
as = getActivitiesSummaryElement();
setVisibility(as.getEmployments().getSummaries(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
publicAPISecurityManagerV3.filter(as);
assertEquals(3, as.getEducations().getSummaries().size());
assertContainerContainsOnlyPublicElements(as.getEducations());
assertNotNull(as.getEmployments());
assertTrue(as.getEmployments().getSummaries().isEmpty());
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());
// Assert it filters distinctions
as = getActivitiesSummaryElement();
setVisibility(as.getDistinctions().getSummaries(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
publicAPISecurityManagerV3.filter(as);
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());
assertTrue(as.getDistinctions().getSummaries().isEmpty());
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());
// Assert it filters invited positions
as = getActivitiesSummaryElement();
setVisibility(as.getInvitedPositions().getSummaries(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
publicAPISecurityManagerV3.filter(as);
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());
assertTrue(as.getInvitedPositions().getSummaries().isEmpty());
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());
// Assert it filters memberships
as = getActivitiesSummaryElement();
setVisibility(as.getMemberships().getSummaries(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
publicAPISecurityManagerV3.filter(as);
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());
assertTrue(as.getMemberships().getSummaries().isEmpty());
assertEquals(3, as.getQualifications().getSummaries().size());
assertContainerContainsOnlyPublicElements(as.getQualifications());
assertEquals(3, as.getServices().getSummaries().size());
assertContainerContainsOnlyPublicElements(as.getServices());
// Assert it filters qualifications
as = getActivitiesSummaryElement();
setVisibility(as.getQualifications().getSummaries(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
publicAPISecurityManagerV3.filter(as);
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());
assertTrue(as.getQualifications().getSummaries().isEmpty());
assertEquals(3, as.getServices().getSummaries().size());
assertContainerContainsOnlyPublicElements(as.getServices());
// Assert it filters services
as = getActivitiesSummaryElement();
setVisibility(as.getServices().getSummaries(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
publicAPISecurityManagerV3.filter(as);
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());
assertTrue(as.getServices().getSummaries().isEmpty());
// Assert it filters funding
as = getActivitiesSummaryElement();
setVisibility(as.getFundings(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
publicAPISecurityManagerV3.filter(as);
assertEquals(3, as.getEducations().getSummaries().size());
assertContainerContainsOnlyPublicElements(as.getEducations());
assertEquals(3, as.getEmployments().getSummaries().size());
assertContainerContainsOnlyPublicElements(as.getEmployments());
assertTrue(as.getFundings().getFundingGroup().isEmpty());
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());
// Assert it filters peer reviews
as = getActivitiesSummaryElement();
setVisibility(as.getPeerReviews(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
publicAPISecurityManagerV3.filter(as);
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());
assertTrue(as.getPeerReviews().getPeerReviewGroup().isEmpty());
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());
// Assert it filters works
as = getActivitiesSummaryElement();
setVisibility(as.getWorks(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
publicAPISecurityManagerV3.filter(as);
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());
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());
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV3Test method getActivitiesSummaryElement.
private ActivitiesSummary getActivitiesSummaryElement() {
Visibility[] vs = { Visibility.PUBLIC, Visibility.PUBLIC, Visibility.PUBLIC };
ActivitiesSummary s = new ActivitiesSummary();
s.setDistinctions(getDistinctions(vs));
s.setEducations(getEducations(vs));
s.setEmployments(getEmployments(vs));
s.setInvitedPositions(getInvitedPositions(vs));
s.setMemberships(getMemberships(vs));
s.setQualifications(getQualifications(vs));
s.setServices(getServices(vs));
s.setFundings(getFundings(vs));
s.setPeerReviews(getPeerReviews(vs));
s.setWorks(getWorks(vs));
return s;
}
Aggregations