use of org.orcid.jaxb.model.v3.dev1.common.Url 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.common.Url in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_PeerReviewsTest method testAddPeerReviewDuplicateFails.
@Test(expected = OrcidDuplicatedActivityException.class)
public void testAddPeerReviewDuplicateFails() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewPeerReview("4444-4444-4444-4447", 6L);
assertNotNull(response);
PeerReview peerReview = (PeerReview) response.getEntity();
assertNotNull(peerReview);
peerReview.setUrl(new Url("http://updated.com/url"));
peerReview.getSubjectName().getTitle().setContent("Updated Title");
// disambiguated org is required in API v3
DisambiguatedOrganization disambiguatedOrg = new DisambiguatedOrganization();
disambiguatedOrg.setDisambiguatedOrganizationIdentifier("some-org");
disambiguatedOrg.setDisambiguationSource("FUNDREF");
peerReview.getOrganization().setDisambiguatedOrganization(disambiguatedOrg);
peerReview.setPutCode(null);
response = serviceDelegator.createPeerReview("4444-4444-4444-4447", peerReview);
}
use of org.orcid.jaxb.model.v3.dev1.common.Url in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_PeerReviewsTest method testUpdatePeerReview.
@Test
public void testUpdatePeerReview() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewPeerReview("4444-4444-4444-4447", 6L);
assertNotNull(response);
PeerReview peerReview = (PeerReview) response.getEntity();
assertNotNull(peerReview);
Utils.verifyLastModified(peerReview.getLastModifiedDate());
LastModifiedDate before = peerReview.getLastModifiedDate();
peerReview.setUrl(new Url("http://updated.com/url"));
peerReview.getSubjectName().getTitle().setContent("Updated Title");
response = serviceDelegator.updatePeerReview("4444-4444-4444-4447", 6L, peerReview);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.viewPeerReview("4444-4444-4444-4447", 6L);
PeerReview updatedPeerReview = (PeerReview) response.getEntity();
assertNotNull(updatedPeerReview);
Utils.verifyLastModified(updatedPeerReview.getLastModifiedDate());
assertTrue(updatedPeerReview.getLastModifiedDate().after(before));
assertEquals("http://updated.com/url", updatedPeerReview.getUrl().getValue());
assertEquals("Updated Title", updatedPeerReview.getSubjectName().getTitle().getContent());
}
use of org.orcid.jaxb.model.v3.dev1.common.Url in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_PeerReviewsTest method testUpdatePeerReviewWhenYouAreNotTheSourceOf.
@Test
public void testUpdatePeerReviewWhenYouAreNotTheSourceOf() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewPeerReview("4444-4444-4444-4447", 2L);
assertNotNull(response);
PeerReview peerReview = (PeerReview) response.getEntity();
assertNotNull(peerReview);
assertEquals("http://peer_review.com/2", peerReview.getUrl().getValue());
assertEquals("APP-6666666666666666", peerReview.getSource().retrieveSourcePath());
// Update the info
peerReview.setUrl(new Url("http://updated.com/url"));
peerReview.getSubjectName().getTitle().setContent("Updated Title");
peerReview.getExternalIdentifiers().getExternalIdentifier().iterator().next().setValue("different");
// disambiguated org is required in API v3
DisambiguatedOrganization disambiguatedOrg = new DisambiguatedOrganization();
disambiguatedOrg.setDisambiguatedOrganizationIdentifier("some-org");
disambiguatedOrg.setDisambiguationSource("FUNDREF");
peerReview.getOrganization().setDisambiguatedOrganization(disambiguatedOrg);
try {
response = serviceDelegator.updatePeerReview("4444-4444-4444-4447", 2L, peerReview);
fail();
} catch (WrongSourceException wse) {
}
response = serviceDelegator.viewPeerReview("4444-4444-4444-4447", Long.valueOf(2));
peerReview = (PeerReview) response.getEntity();
assertNotNull(peerReview);
assertEquals("http://peer_review.com/2", peerReview.getUrl().getValue());
assertEquals("APP-6666666666666666", peerReview.getSource().retrieveSourcePath());
}
use of org.orcid.jaxb.model.v3.dev1.common.Url in project ORCID-Source by ORCID.
the class Utils method getPeerReview.
public static PeerReview getPeerReview() {
PeerReview peerReview = new PeerReview();
ExternalIDs weis = new ExternalIDs();
ExternalID wei1 = new ExternalID();
wei1.setRelationship(Relationship.PART_OF);
wei1.setUrl(new Url("http://myUrl.com"));
wei1.setValue("work-external-identifier-id");
wei1.setType(WorkExternalIdentifierType.DOI.value());
weis.getExternalIdentifier().add(wei1);
peerReview.setExternalIdentifiers(weis);
peerReview.setGroupId("issn:0000003");
peerReview.setOrganization(getOrganization());
peerReview.setRole(Role.CHAIR);
peerReview.setSubjectContainerName(new Title("subject-container-name"));
peerReview.setSubjectExternalIdentifier(wei1);
WorkTitle workTitle = new WorkTitle();
workTitle.setTitle(new Title("work-title"));
peerReview.setSubjectName(workTitle);
peerReview.setSubjectType(WorkType.DATA_SET);
peerReview.setType(PeerReviewType.EVALUATION);
return peerReview;
}
Aggregations