use of org.orcid.jaxb.model.v3.dev1.record.ExternalIDs in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_FundingTest method testUpdateFundingYouAreNotTheSourceOf.
@Test(expected = WrongSourceException.class)
public void testUpdateFundingYouAreNotTheSourceOf() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewFunding("4444-4444-4444-4446", 5L);
assertNotNull(response);
Funding funding = (Funding) response.getEntity();
assertNotNull(funding);
funding.getTitle().getTitle().setContent("Updated funding title");
ExternalID fExtId = new ExternalID();
fExtId.setRelationship(Relationship.PART_OF);
fExtId.setType(FundingExternalIdentifierType.GRANT_NUMBER.value());
fExtId.setUrl(new Url("http://fundingExtId.com"));
fExtId.setValue("new-funding-ext-id");
ExternalIDs fExtIds = new ExternalIDs();
fExtIds.getExternalIdentifier().add(fExtId);
funding.setExternalIdentifiers(fExtIds);
serviceDelegator.updateFunding("4444-4444-4444-4446", 5L, funding);
fail();
}
use of org.orcid.jaxb.model.v3.dev1.record.ExternalIDs in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_FundingTest method testUpdateFunding.
@Test
public void testUpdateFunding() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewFunding("4444-4444-4444-4447", 6L);
assertNotNull(response);
Funding funding = (Funding) response.getEntity();
assertNotNull(funding);
assertEquals("Public Funding # 1", funding.getTitle().getTitle().getContent());
assertEquals("This is the description for funding with id 6", funding.getDescription());
LastModifiedDate before = funding.getLastModifiedDate();
funding.getTitle().getTitle().setContent("Updated funding title");
funding.setDescription("This is an updated description");
ExternalID fExtId = new ExternalID();
fExtId.setRelationship(Relationship.PART_OF);
fExtId.setType(FundingExternalIdentifierType.GRANT_NUMBER.value());
fExtId.setUrl(new Url("http://fundingExtId.com"));
fExtId.setValue("new-funding-ext-id");
ExternalIDs fExtIds = new ExternalIDs();
fExtIds.getExternalIdentifier().add(fExtId);
funding.setExternalIdentifiers(fExtIds);
response = serviceDelegator.updateFunding("4444-4444-4444-4447", 6L, funding);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.viewFunding("4444-4444-4444-4447", 6L);
assertNotNull(response);
funding = (Funding) response.getEntity();
assertNotNull(funding);
Utils.verifyLastModified(funding.getLastModifiedDate());
assertTrue(funding.getLastModifiedDate().after(before));
assertEquals("Updated funding title", funding.getTitle().getTitle().getContent());
assertEquals("This is an updated description", funding.getDescription());
// Rollback changes
funding.getTitle().getTitle().setContent("Public Funding # 1");
funding.setDescription("This is the description for funding with id 6");
response = serviceDelegator.updateFunding("4444-4444-4444-4447", 6L, funding);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
}
use of org.orcid.jaxb.model.v3.dev1.record.ExternalIDs 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.ExternalIDs 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.ExternalIDs in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_QualificationsTest method testUpdateQualificationDuplicateExternalIDs.
@Test(expected = OrcidDuplicatedActivityException.class)
public void testUpdateQualificationDuplicateExternalIDs() {
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);
Qualification qualification = (Qualification) Utils.getAffiliation(AffiliationType.QUALIFICATION);
qualification.setExternalIDs(externalIDs);
Response response = serviceDelegator.createQualification(ORCID, qualification);
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)));
Qualification another = (Qualification) Utils.getAffiliation(AffiliationType.QUALIFICATION);
response = serviceDelegator.createQualification(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.viewQualification(ORCID, putCode2);
another = (Qualification) response.getEntity();
another.setExternalIDs(externalIDs);
try {
serviceDelegator.updateQualification(ORCID, putCode2, another);
} finally {
serviceDelegator.deleteAffiliation(ORCID, putCode1);
serviceDelegator.deleteAffiliation(ORCID, putCode2);
}
}
Aggregations