use of org.orcid.jaxb.model.v3.dev1.record.InvitedPosition in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegatorImpl method viewInvitedPosition.
@Override
public Response viewInvitedPosition(String orcid, Long putCode) {
InvitedPosition e = affiliationsManagerReadOnly.getInvitedPositionAffiliation(orcid, putCode);
orcidSecurityManager.checkAndFilter(orcid, e, ScopePathType.AFFILIATIONS_READ_LIMITED);
ActivityUtils.setPathToActivity(e, orcid);
sourceUtils.setSourceName(e);
return Response.ok(e).build();
}
use of org.orcid.jaxb.model.v3.dev1.record.InvitedPosition in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_InvitedPositionsTest method testViewPublicInvitedPosition.
@Test
public void testViewPublicInvitedPosition() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response response = serviceDelegator.viewInvitedPosition(ORCID, 32L);
assertNotNull(response);
InvitedPosition invitedPosition = (InvitedPosition) response.getEntity();
assertNotNull(invitedPosition);
Utils.verifyLastModified(invitedPosition.getLastModifiedDate());
assertEquals(Long.valueOf(32L), invitedPosition.getPutCode());
assertEquals("/0000-0000-0000-0003/invited-position/32", invitedPosition.getPath());
assertEquals("PUBLIC Department", invitedPosition.getDepartmentName());
assertEquals(Visibility.PUBLIC.value(), invitedPosition.getVisibility().value());
}
use of org.orcid.jaxb.model.v3.dev1.record.InvitedPosition in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_InvitedPositionsTest method testViewInvitedPositions.
@Test
public void testViewInvitedPositions() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response r = serviceDelegator.viewInvitedPositions(ORCID);
assertNotNull(r);
InvitedPositions invitedPositions = (InvitedPositions) r.getEntity();
assertNotNull(invitedPositions);
assertEquals("/0000-0000-0000-0003/invited-positions", invitedPositions.getPath());
Utils.verifyLastModified(invitedPositions.getLastModifiedDate());
assertNotNull(invitedPositions.getSummaries());
assertEquals(4, invitedPositions.getSummaries().size());
boolean found1 = false, found2 = false, found3 = false, found4 = false;
for (InvitedPositionSummary summary : invitedPositions.getSummaries()) {
Utils.verifyLastModified(summary.getLastModifiedDate());
if (Long.valueOf(32).equals(summary.getPutCode())) {
assertEquals("PUBLIC Department", summary.getDepartmentName());
found1 = true;
} else if (Long.valueOf(33).equals(summary.getPutCode())) {
assertEquals("LIMITED Department", summary.getDepartmentName());
found2 = true;
} else if (Long.valueOf(34).equals(summary.getPutCode())) {
assertEquals("PRIVATE Department", summary.getDepartmentName());
found3 = true;
} else if (Long.valueOf(35).equals(summary.getPutCode())) {
assertEquals("SELF LIMITED Department", summary.getDepartmentName());
found4 = true;
} else {
fail("Invalid invitedPosition found: " + summary.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
assertTrue(found4);
}
use of org.orcid.jaxb.model.v3.dev1.record.InvitedPosition in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_InvitedPositionsTest method testUpdateInvitedPositionDuplicateExternalIDs.
@Test(expected = OrcidDuplicatedActivityException.class)
public void testUpdateInvitedPositionDuplicateExternalIDs() {
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);
InvitedPosition invitedPosition = (InvitedPosition) Utils.getAffiliation(AffiliationType.INVITED_POSITION);
invitedPosition.setExternalIDs(externalIDs);
Response response = serviceDelegator.createInvitedPosition(ORCID, invitedPosition);
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 putCode1 = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
InvitedPosition another = (InvitedPosition) Utils.getAffiliation(AffiliationType.INVITED_POSITION);
response = serviceDelegator.createInvitedPosition(ORCID, another);
map = response.getMetadata();
assertNotNull(map);
assertTrue(map.containsKey("Location"));
resultWithPutCode = (List<?>) map.get("Location");
Long putCode2 = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
response = serviceDelegator.viewInvitedPosition(ORCID, putCode2);
another = (InvitedPosition) response.getEntity();
another.setExternalIDs(externalIDs);
try {
serviceDelegator.updateInvitedPosition(ORCID, putCode2, another);
} finally {
serviceDelegator.deleteAffiliation(ORCID, putCode1);
serviceDelegator.deleteAffiliation(ORCID, putCode2);
}
}
use of org.orcid.jaxb.model.v3.dev1.record.InvitedPosition in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_InvitedPositionsTest method testUpdateInvitedPositionChangingVisibilityTest.
@Test(expected = VisibilityMismatchException.class)
public void testUpdateInvitedPositionChangingVisibilityTest() {
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(Visibility.PUBLIC, invitedPosition.getVisibility());
invitedPosition.setVisibility(Visibility.PRIVATE);
response = serviceDelegator.updateInvitedPosition(ORCID, 32L, invitedPosition);
fail();
}
Aggregations