use of org.orcid.jaxb.model.v3.dev1.record.InvitedPosition in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_InvitedPositionsTest method testUpdateInvitedPositionYouAreNotTheSourceOf.
@Test(expected = WrongSourceException.class)
public void testUpdateInvitedPositionYouAreNotTheSourceOf() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewInvitedPosition(ORCID, 35L);
assertNotNull(response);
InvitedPosition invitedPosition = (InvitedPosition) response.getEntity();
assertNotNull(invitedPosition);
invitedPosition.setDepartmentName("Updated department name");
invitedPosition.setRoleTitle("The updated role title");
serviceDelegator.updateInvitedPosition(ORCID, 35L, invitedPosition);
fail();
}
use of org.orcid.jaxb.model.v3.dev1.record.InvitedPosition in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_InvitedPositionsTest method testDeleteInvitedPosition.
@Test
public void testDeleteInvitedPosition() {
SecurityContextTestUtils.setUpSecurityContext("0000-0000-0000-0002", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewInvitedPosition("0000-0000-0000-0002", 1003L);
assertNotNull(response);
InvitedPosition invitedPosition = (InvitedPosition) response.getEntity();
assertNotNull(invitedPosition);
response = serviceDelegator.deleteAffiliation("0000-0000-0000-0002", 1003L);
assertNotNull(response);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
try {
serviceDelegator.viewInvitedPosition("0000-0000-0000-0002", 1003L);
fail();
} catch (NoResultException nre) {
} catch (Exception e) {
fail();
}
}
use of org.orcid.jaxb.model.v3.dev1.record.InvitedPosition in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_InvitedPositionsTest method testAddInvitedPositionNoStartDate.
@Test(expected = OrcidValidationException.class)
public void testAddInvitedPositionNoStartDate() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
InvitedPosition invitedPosition = (InvitedPosition) Utils.getAffiliation(AffiliationType.INVITED_POSITION);
invitedPosition.setStartDate(null);
serviceDelegator.createInvitedPosition(ORCID, invitedPosition);
}
use of org.orcid.jaxb.model.v3.dev1.record.InvitedPosition in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_InvitedPositionsTest method testAddInvitedPositionsDuplicateExternalIDs.
@Test(expected = OrcidDuplicatedActivityException.class)
public void testAddInvitedPositionsDuplicateExternalIDs() {
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 putCode = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
try {
InvitedPosition duplicate = (InvitedPosition) Utils.getAffiliation(AffiliationType.INVITED_POSITION);
duplicate.setExternalIDs(externalIDs);
serviceDelegator.createInvitedPosition(ORCID, duplicate);
} finally {
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 testUpdateInvitedPositionLeavingVisibilityNullTest.
@Test
public void testUpdateInvitedPositionLeavingVisibilityNullTest() {
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(null);
response = serviceDelegator.updateInvitedPosition(ORCID, 32L, invitedPosition);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
invitedPosition = (InvitedPosition) response.getEntity();
assertNotNull(invitedPosition);
assertEquals(Visibility.PUBLIC, invitedPosition.getVisibility());
}
Aggregations