use of org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_ActivitiesSummaryTest method testViewActivitiesReadPublic.
@Test
public void testViewActivitiesReadPublic() {
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
Response r = serviceDelegator.viewActivities(ORCID);
ActivitiesSummary as = (ActivitiesSummary) r.getEntity();
assertNotNull(as);
assertEquals("/0000-0000-0000-0003/activities", as.getPath());
Utils.assertIsPublicOrSource(as, "APP-5555555555555555");
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_ActivitiesSummaryTest method testViewActitivies_AffiliationsReadLimited_NoSource.
@Test
public void testViewActitivies_AffiliationsReadLimited_NoSource() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, "APP-5555555555555556", ScopePathType.AFFILIATIONS_READ_LIMITED);
Response response = serviceDelegator.viewActivities(ORCID);
ActivitiesSummary as = (ActivitiesSummary) response.getEntity();
assertNotNull(as);
assertNotNull(as.getPath());
Utils.verifyLastModified(as.getLastModifiedDate());
// Limited educations
boolean found1 = false, found2 = false, found3 = false;
assertNotNull(as.getEducations());
assertEquals(3, as.getEducations().getSummaries().size());
for (EducationSummary education : as.getEducations().getSummaries()) {
Long putCode = education.getPutCode();
if (putCode == 20L) {
assertEquals(Visibility.PUBLIC, education.getVisibility());
found1 = true;
} else if (putCode == 21L) {
assertEquals(Visibility.LIMITED, education.getVisibility());
found2 = true;
} else if (putCode == 25L) {
assertEquals(Visibility.LIMITED, education.getVisibility());
found3 = true;
} else {
fail("Invalid put code " + putCode);
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
// Limited employments
found1 = found2 = found3 = false;
assertNotNull(as.getEmployments());
assertEquals(3, as.getEmployments().getSummaries().size());
for (EmploymentSummary employment : as.getEmployments().getSummaries()) {
Long putCode = employment.getPutCode();
if (putCode == 17L) {
assertEquals(Visibility.PUBLIC, employment.getVisibility());
found1 = true;
} else if (putCode == 18L) {
assertEquals(Visibility.LIMITED, employment.getVisibility());
found2 = true;
} else if (putCode == 23L) {
assertEquals(Visibility.LIMITED, employment.getVisibility());
found3 = true;
} else {
fail("Invalid put code " + putCode);
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
// Only public funding
assertNotNull(as.getFundings());
assertEquals(1, as.getFundings().getFundingGroup().size());
assertEquals(1, as.getFundings().getFundingGroup().get(0).getFundingSummary().size());
assertEquals(Long.valueOf(10), as.getFundings().getFundingGroup().get(0).getFundingSummary().get(0).getPutCode());
assertEquals(Visibility.PUBLIC, as.getFundings().getFundingGroup().get(0).getFundingSummary().get(0).getVisibility());
// Only public peer reviews
assertNotNull(as.getPeerReviews());
assertEquals(1, as.getPeerReviews().getPeerReviewGroup().size());
assertEquals(1, as.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().size());
assertEquals(Long.valueOf(9), as.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getPutCode());
assertEquals(Visibility.PUBLIC, as.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getVisibility());
// Only public works
assertNotNull(as.getWorks());
assertEquals(1, as.getWorks().getWorkGroup().size());
assertEquals(1, as.getWorks().getWorkGroup().get(0).getWorkSummary().size());
assertEquals(Long.valueOf(11), as.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getPutCode());
assertEquals(Visibility.PUBLIC, as.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getVisibility());
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_DistinctionsTest method testAddDistinction.
@Test
public void testAddDistinction() {
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.getDistinctions());
Utils.verifyLastModified(originalSummary.getDistinctions().getLastModifiedDate());
assertNotNull(originalSummary.getDistinctions().getSummaries());
assertNotNull(originalSummary.getDistinctions().getSummaries().get(0));
Utils.verifyLastModified(originalSummary.getDistinctions().getSummaries().get(0).getLastModifiedDate());
assertEquals(4, originalSummary.getDistinctions().getSummaries().size());
response = serviceDelegator.createDistinction(ORCID, (Distinction) Utils.getAffiliation(AffiliationType.DISTINCTION));
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.getDistinctions());
Utils.verifyLastModified(summaryWithNewElement.getDistinctions().getLastModifiedDate());
assertNotNull(summaryWithNewElement.getDistinctions().getSummaries());
assertEquals(5, summaryWithNewElement.getDistinctions().getSummaries().size());
boolean haveNew = false;
for (DistinctionSummary distinctionSummary : summaryWithNewElement.getDistinctions().getSummaries()) {
assertNotNull(distinctionSummary.getPutCode());
Utils.verifyLastModified(distinctionSummary.getLastModifiedDate());
if (distinctionSummary.getPutCode().equals(putCode)) {
assertEquals("My department name", distinctionSummary.getDepartmentName());
haveNew = true;
} else {
assertTrue(originalSummary.getDistinctions().getSummaries().contains(distinctionSummary));
}
}
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_EducationsTest method testAddEducation.
@Test
public void testAddEducation() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewActivities(ORCID);
assertNotNull(response);
ActivitiesSummary summary = (ActivitiesSummary) response.getEntity();
assertNotNull(summary);
Utils.verifyLastModified(summary.getLastModifiedDate());
assertNotNull(summary.getEducations());
Utils.verifyLastModified(summary.getEducations().getLastModifiedDate());
assertNotNull(summary.getEducations().getSummaries());
assertNotNull(summary.getEducations().getSummaries().get(0));
Utils.verifyLastModified(summary.getEducations().getSummaries().get(0).getLastModifiedDate());
assertEquals(4, summary.getEducations().getSummaries().size());
response = serviceDelegator.createEducation(ORCID, (Education) Utils.getAffiliation(AffiliationType.EDUCATION));
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.getEducations());
Utils.verifyLastModified(summaryWithNewElement.getEducations().getLastModifiedDate());
assertNotNull(summaryWithNewElement.getEducations().getSummaries());
assertEquals(5, summaryWithNewElement.getEducations().getSummaries().size());
boolean haveNew = true;
for (EducationSummary educationSummary : summary.getEducations().getSummaries()) {
assertNotNull(educationSummary.getPutCode());
Utils.verifyLastModified(educationSummary.getLastModifiedDate());
if (educationSummary.getPutCode().equals(putCode)) {
assertEquals("My department name", educationSummary.getDepartmentName());
haveNew = true;
} else {
assertTrue(summary.getEducations().getSummaries().contains(educationSummary));
}
}
assertTrue(haveNew);
// Delete the just created 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_EmploymentsTest method testAddEmployment.
@Test
public void testAddEmployment() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewActivities(ORCID);
assertNotNull(response);
ActivitiesSummary summary = (ActivitiesSummary) response.getEntity();
assertNotNull(summary);
assertNotNull(summary.getEmployments());
assertNotNull(summary.getEmployments().getSummaries());
assertNotNull(summary.getEmployments().getSummaries().get(0));
assertEquals(4, summary.getEmployments().getSummaries().size());
response = serviceDelegator.createEmployment(ORCID, (Employment) Utils.getAffiliation(AffiliationType.EMPLOYMENT));
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.getEmployments());
Utils.verifyLastModified(summaryWithNewElement.getEmployments().getLastModifiedDate());
assertNotNull(summaryWithNewElement.getEmployments().getSummaries());
assertEquals(5, summaryWithNewElement.getEmployments().getSummaries().size());
boolean haveNew = false;
for (EmploymentSummary eSummary : summaryWithNewElement.getEmployments().getSummaries()) {
assertNotNull(eSummary.getPutCode());
Utils.verifyLastModified(eSummary.getLastModifiedDate());
if (eSummary.getPutCode().equals(putCode)) {
assertEquals("My department name", eSummary.getDepartmentName());
haveNew = true;
} else {
assertTrue(summary.getEmployments().getSummaries().contains(eSummary));
}
}
assertTrue(haveNew);
// Delete new element
serviceDelegator.deleteAffiliation(ORCID, putCode);
}
Aggregations