use of org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary in project ORCID-Source by ORCID.
the class JpaJaxbMembershipAdapterTest method fromOrgAffiliationRelationEntityToMembershipSummary.
@Test
public void fromOrgAffiliationRelationEntityToMembershipSummary() {
OrgAffiliationRelationEntity entity = getEntity();
assertNotNull(entity);
MembershipSummary summary = adapter.toMembershipSummary(entity);
assertNotNull(summary);
assertEquals("membership:department", summary.getDepartmentName());
assertEquals(Long.valueOf(123456), summary.getPutCode());
assertEquals("membership:title", summary.getRoleTitle());
assertEquals("private", summary.getVisibility().value());
assertNotNull(summary.getStartDate());
assertEquals("2000", summary.getStartDate().getYear().getValue());
assertEquals("01", summary.getStartDate().getMonth().getValue());
assertEquals("01", summary.getStartDate().getDay().getValue());
assertEquals("2020", summary.getEndDate().getYear().getValue());
assertEquals("02", summary.getEndDate().getMonth().getValue());
assertEquals("02", summary.getEndDate().getDay().getValue());
assertNotNull(summary.getSource());
assertNotNull(summary.getSource().retrieveSourcePath());
assertEquals("APP-000000001", summary.getSource().retrieveSourcePath());
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_MembershipsTest method testAddMembership.
@Test
public void testAddMembership() {
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.getMemberships());
Utils.verifyLastModified(originalSummary.getMemberships().getLastModifiedDate());
assertNotNull(originalSummary.getMemberships().getSummaries());
assertNotNull(originalSummary.getMemberships().getSummaries().get(0));
Utils.verifyLastModified(originalSummary.getMemberships().getSummaries().get(0).getLastModifiedDate());
assertEquals(4, originalSummary.getMemberships().getSummaries().size());
response = serviceDelegator.createMembership(ORCID, (Membership) Utils.getAffiliation(AffiliationType.MEMBERSHIP));
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.getMemberships());
Utils.verifyLastModified(summaryWithNewElement.getMemberships().getLastModifiedDate());
assertNotNull(summaryWithNewElement.getMemberships().getSummaries());
assertEquals(5, summaryWithNewElement.getMemberships().getSummaries().size());
boolean haveNew = false;
for (MembershipSummary membershipSummary : summaryWithNewElement.getMemberships().getSummaries()) {
assertNotNull(membershipSummary.getPutCode());
Utils.verifyLastModified(membershipSummary.getLastModifiedDate());
if (membershipSummary.getPutCode().equals(putCode)) {
assertEquals("My department name", membershipSummary.getDepartmentName());
haveNew = true;
} else {
assertTrue(originalSummary.getMemberships().getSummaries().contains(membershipSummary));
}
}
assertTrue(haveNew);
// Remove new element
serviceDelegator.deleteAffiliation(ORCID, putCode);
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary in project ORCID-Source by ORCID.
the class PublicV3ApiServiceDelegatorTest method testViewMemberships.
@Test
public void testViewMemberships() {
Response response = serviceDelegator.viewMemberships(ORCID);
assertNotNull(response);
Memberships memberships = (Memberships) response.getEntity();
assertNotNull(memberships);
assertEquals("/0000-0000-0000-0003/memberships", memberships.getPath());
assertNotNull(memberships.getLastModifiedDate());
assertNotNull(memberships.getLastModifiedDate().getValue());
assertEquals(1, memberships.getSummaries().size());
MembershipSummary membership = memberships.getSummaries().get(0);
assertEquals(Long.valueOf(37), membership.getPutCode());
assertNotNull(membership.getLastModifiedDate());
assertNotNull(membership.getLastModifiedDate().getValue());
assertEquals("/0000-0000-0000-0003/membership/37", membership.getPath());
assertEquals("PUBLIC Department", membership.getDepartmentName());
assertEquals(Visibility.PUBLIC.value(), membership.getVisibility().value());
assertEquals("APP-5555555555555555", membership.getSource().retrieveSourcePath());
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary in project ORCID-Source by ORCID.
the class PublicV3ApiServiceDelegatorImpl method viewMemberships.
@Override
public Response viewMemberships(String orcid) {
List<MembershipSummary> memberships = affiliationsManagerReadOnly.getMembershipSummaryList(orcid);
Memberships publicMemberships = new Memberships();
for (MembershipSummary summary : memberships) {
if (Visibility.PUBLIC.equals(summary.getVisibility())) {
ActivityUtils.setPathToActivity(summary, orcid);
sourceUtilsReadOnly.setSourceName(summary);
publicMemberships.getSummaries().add(summary);
}
}
Api3_0_Dev1LastModifiedDatesHelper.calculateLastModified(publicMemberships);
ActivityUtils.setPathToAffiliations(publicMemberships, orcid);
return Response.ok(publicMemberships).build();
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary in project ORCID-Source by ORCID.
the class PublicV3ApiServiceDelegatorImpl method viewMembershipSummary.
@Override
public Response viewMembershipSummary(String orcid, Long putCode) {
MembershipSummary s = affiliationsManagerReadOnly.getMembershipSummary(orcid, putCode);
publicAPISecurityManagerV3.checkIsPublic(s);
ActivityUtils.setPathToActivity(s, orcid);
sourceUtilsReadOnly.setSourceName(s);
return Response.ok(s).build();
}
Aggregations