use of org.orcid.jaxb.model.v3.dev1.record.Membership in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_MembershipsTest method testViewMembershipReadPublic.
@Test
public void testViewMembershipReadPublic() {
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
Response r = serviceDelegator.viewMembership(ORCID, 37L);
Membership element = (Membership) r.getEntity();
assertNotNull(element);
assertEquals("/0000-0000-0000-0003/membership/37", element.getPath());
Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
use of org.orcid.jaxb.model.v3.dev1.record.Membership in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_MembershipsTest method testAddMembershipsDuplicateExternalIDs.
@Test(expected = OrcidDuplicatedActivityException.class)
public void testAddMembershipsDuplicateExternalIDs() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
ExternalID e1 = new ExternalID();
e1.setRelationship(Relationship.SELF);
e1.setType("erm");
e1.setUrl(new Url("https://orcid.org"));
e1.setValue("err");
ExternalID e2 = new ExternalID();
e2.setRelationship(Relationship.SELF);
e2.setType("err");
e2.setUrl(new Url("http://bbc.co.uk"));
e2.setValue("erm");
ExternalIDs externalIDs = new ExternalIDs();
externalIDs.getExternalIdentifier().add(e1);
externalIDs.getExternalIdentifier().add(e2);
Membership membership = (Membership) Utils.getAffiliation(AffiliationType.MEMBERSHIP);
membership.setExternalIDs(externalIDs);
Response response = serviceDelegator.createMembership(ORCID, membership);
assertNotNull(response);
assertEquals(HttpStatus.SC_CREATED, 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)));
try {
Membership duplicate = (Membership) Utils.getAffiliation(AffiliationType.MEMBERSHIP);
duplicate.setExternalIDs(externalIDs);
serviceDelegator.createMembership(ORCID, duplicate);
} finally {
serviceDelegator.deleteAffiliation(ORCID, putCode);
}
}
use of org.orcid.jaxb.model.v3.dev1.record.Membership in project ORCID-Source by ORCID.
the class Utils method getAffiliation.
public static Affiliation getAffiliation(AffiliationType type) {
Affiliation a = null;
switch(type) {
case DISTINCTION:
a = new Distinction();
break;
case EDUCATION:
a = new Education();
break;
case EMPLOYMENT:
a = new Employment();
break;
case INVITED_POSITION:
a = new InvitedPosition();
break;
case MEMBERSHIP:
a = new Membership();
break;
case QUALIFICATION:
a = new Qualification();
break;
case SERVICE:
a = new Service();
break;
}
a.setDepartmentName("My department name");
a.setRoleTitle("My Role");
a.setOrganization(getOrganization());
a.setStartDate(FuzzyDate.valueOf(2017, 1, 1));
return a;
}
use of org.orcid.jaxb.model.v3.dev1.record.Membership 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.Membership in project ORCID-Source by ORCID.
the class PublicV3ApiServiceDelegatorTest method testGetPublicMembershipUsingToken.
@Test
public void testGetPublicMembershipUsingToken() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response r = serviceDelegator.viewMembership(ORCID, 37L);
assertNotNull(r);
Membership e = (Membership) r.getEntity();
assertNotNull(e);
assertEquals(Long.valueOf(37), e.getPutCode());
assertNotNull(e.getLastModifiedDate());
assertNotNull(e.getLastModifiedDate().getValue());
}
Aggregations