use of org.orcid.jaxb.model.v3.dev1.record.InvitedPosition in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_InvitedPositionsTest method testUpdateInvitedPosition.
@Test
public void testUpdateInvitedPosition() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewInvitedPosition(ORCID, 32L);
assertNotNull(response);
InvitedPosition invitedPosition = (InvitedPosition) response.getEntity();
assertNotNull(invitedPosition);
assertEquals("PUBLIC Department", invitedPosition.getDepartmentName());
assertEquals("PUBLIC", invitedPosition.getRoleTitle());
Utils.verifyLastModified(invitedPosition.getLastModifiedDate());
LastModifiedDate before = invitedPosition.getLastModifiedDate();
invitedPosition.setDepartmentName("Updated department name");
invitedPosition.setRoleTitle("The updated role title");
// disambiguated org is required in API v3
DisambiguatedOrganization disambiguatedOrg = new DisambiguatedOrganization();
disambiguatedOrg.setDisambiguatedOrganizationIdentifier("abc456");
disambiguatedOrg.setDisambiguationSource("WDB");
invitedPosition.getOrganization().setDisambiguatedOrganization(disambiguatedOrg);
response = serviceDelegator.updateInvitedPosition(ORCID, 32L, invitedPosition);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.viewInvitedPosition(ORCID, 32L);
assertNotNull(response);
invitedPosition = (InvitedPosition) response.getEntity();
assertNotNull(invitedPosition);
Utils.verifyLastModified(invitedPosition.getLastModifiedDate());
assertTrue(invitedPosition.getLastModifiedDate().after(before));
assertEquals("Updated department name", invitedPosition.getDepartmentName());
assertEquals("The updated role title", invitedPosition.getRoleTitle());
// Rollback changes
invitedPosition.setDepartmentName("PUBLIC Department");
invitedPosition.setRoleTitle("PUBLIC");
response = serviceDelegator.updateInvitedPosition(ORCID, 32L, invitedPosition);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
}
use of org.orcid.jaxb.model.v3.dev1.record.InvitedPosition in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_InvitedPositionsTest method testAddInvitedPosition.
@Test
public void testAddInvitedPosition() {
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.getInvitedPositions());
Utils.verifyLastModified(originalSummary.getInvitedPositions().getLastModifiedDate());
assertNotNull(originalSummary.getInvitedPositions().getSummaries());
assertNotNull(originalSummary.getInvitedPositions().getSummaries().get(0));
Utils.verifyLastModified(originalSummary.getInvitedPositions().getSummaries().get(0).getLastModifiedDate());
assertEquals(4, originalSummary.getInvitedPositions().getSummaries().size());
response = serviceDelegator.createInvitedPosition(ORCID, (InvitedPosition) Utils.getAffiliation(AffiliationType.INVITED_POSITION));
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.getInvitedPositions());
Utils.verifyLastModified(summaryWithNewElement.getInvitedPositions().getLastModifiedDate());
assertNotNull(summaryWithNewElement.getInvitedPositions().getSummaries());
assertEquals(5, summaryWithNewElement.getInvitedPositions().getSummaries().size());
boolean haveNew = false;
for (InvitedPositionSummary invitedPositionSummary : summaryWithNewElement.getInvitedPositions().getSummaries()) {
assertNotNull(invitedPositionSummary.getPutCode());
Utils.verifyLastModified(invitedPositionSummary.getLastModifiedDate());
if (invitedPositionSummary.getPutCode().equals(putCode)) {
assertEquals("My department name", invitedPositionSummary.getDepartmentName());
haveNew = true;
} else {
assertTrue(originalSummary.getInvitedPositions().getSummaries().contains(invitedPositionSummary));
}
}
assertTrue(haveNew);
// Remove new element
serviceDelegator.deleteAffiliation(ORCID, putCode);
}
use of org.orcid.jaxb.model.v3.dev1.record.InvitedPosition in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_InvitedPositionsTest method testViewLimitedInvitedPosition.
@Test
public void testViewLimitedInvitedPosition() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response response = serviceDelegator.viewInvitedPosition(ORCID, 35L);
assertNotNull(response);
InvitedPosition invitedPosition = (InvitedPosition) response.getEntity();
assertNotNull(invitedPosition);
Utils.verifyLastModified(invitedPosition.getLastModifiedDate());
assertEquals(Long.valueOf(35L), invitedPosition.getPutCode());
assertEquals("/0000-0000-0000-0003/invited-position/35", invitedPosition.getPath());
assertEquals("SELF LIMITED Department", invitedPosition.getDepartmentName());
assertEquals(Visibility.LIMITED.value(), invitedPosition.getVisibility().value());
}
use of org.orcid.jaxb.model.v3.dev1.record.InvitedPosition 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.InvitedPosition in project ORCID-Source by ORCID.
the class PublicV3ApiServiceDelegatorTest method testGetPublicInvitedPositionUsingToken.
@Test
public void testGetPublicInvitedPositionUsingToken() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response r = serviceDelegator.viewInvitedPosition(ORCID, 32L);
assertNotNull(r);
InvitedPosition e = (InvitedPosition) r.getEntity();
assertNotNull(e);
assertEquals(Long.valueOf(32), e.getPutCode());
assertNotNull(e.getLastModifiedDate());
assertNotNull(e.getLastModifiedDate().getValue());
}
Aggregations