use of org.orcid.jaxb.model.record_rc3.ExternalID in project ORCID-Source by ORCID.
the class SourceInActivitiesTest method getFundingWithPutCode.
private ProfileFundingEntity getFundingWithPutCode(String userOrcid) {
Funding funding = new Funding();
funding.setOrganization(getOrganization());
FundingTitle title = new FundingTitle();
title.setTitle(new Title("Title " + System.currentTimeMillis()));
funding.setTitle(title);
funding.setType(org.orcid.jaxb.model.record_v2.FundingType.AWARD);
ExternalID extId = new ExternalID();
extId.setValue("111");
extId.setType(FundingExternalIdentifierType.GRANT_NUMBER.value());
extId.setUrl(new Url("http://test.com"));
ExternalIDs extIdentifiers = new ExternalIDs();
extIdentifiers.getExternalIdentifier().add(extId);
funding.setExternalIdentifiers(extIdentifiers);
funding.setPutCode(Long.valueOf(111));
funding = profileFundingManager.createFunding(userOrcid, funding, true);
return profileFundingManager.getProfileFundingEntity(funding.getPutCode());
}
use of org.orcid.jaxb.model.record_rc3.ExternalID in project ORCID-Source by ORCID.
the class WorkExternalIdentifiersConversionsTest method testConvertFromExternalIDs.
@Test
public void testConvertFromExternalIDs() {
WorkExternalIDsConverter conv = new WorkExternalIDsConverter();
ExternalID id = new ExternalID();
id.setRelationship(Relationship.SELF);
id.setType("doi");
id.setUrl(new Url("http://what.com"));
id.setValue("value");
ExternalID id2 = new ExternalID();
id2.setRelationship(Relationship.PART_OF);
id2.setType("source-work-id");
id2.setUrl(new Url("http://whatnow.com"));
id2.setValue("value2");
ExternalIDs ids = new ExternalIDs();
ids.getExternalIdentifier().add(id);
ids.getExternalIdentifier().add(id2);
String externalIdentifiersAsString = conv.convertTo(ids, null);
assertEquals(expectedIDs, externalIdentifiersAsString);
}
use of org.orcid.jaxb.model.record_rc3.ExternalID in project ORCID-Source by ORCID.
the class FundingExternalIdentifiersConversionsTest method coreObjectToRecordTest.
@Test
public void coreObjectToRecordTest() {
FundingExternalIdentifiers fei = getFundingExternalIdentifiers();
ExternalIDs messageObject = fei.toRecordPojo();
assertNotNull(messageObject);
assertEquals(3, messageObject.getExternalIdentifier().size());
boolean found1 = false, found2 = false, found3 = false;
for (ExternalID f : messageObject.getExternalIdentifier()) {
if (f.getValue().equals("f1")) {
found1 = true;
assertEquals("www.f1.com", f.getUrl().getValue());
assertEquals(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value(), f.getType());
} else if (f.getValue().equals("f2")) {
found2 = true;
assertEquals("www.f2.com", f.getUrl().getValue());
assertEquals(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value(), f.getType());
} else if (f.getValue().equals("f3")) {
found3 = true;
assertEquals("www.f3.com", f.getUrl().getValue());
assertEquals(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value(), f.getType());
} else {
fail();
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
}
use of org.orcid.jaxb.model.record_rc3.ExternalID in project ORCID-Source by ORCID.
the class WorksTest method getWork.
private Work getWork(String title, boolean randomExtId, String extIdValue) {
Long time = System.currentTimeMillis();
Work work = new Work();
WorkTitle workTitle = new WorkTitle();
Title wTitle = new Title(title);
workTitle.setTranslatedTitle(new TranslatedTitle(title, "en"));
workTitle.setTitle(wTitle);
work.setWorkTitle(workTitle);
work.setWorkType(WorkType.BOOK);
ExternalID extId = new ExternalID();
extId.setRelationship(Relationship.SELF);
if (randomExtId) {
extId.setValue("work-ext-id-" + (Math.random() * 1000) + "-" + time);
} else {
extId.setValue("work-ext-id-" + extIdValue);
}
extId.setType("doi");
ExternalIDs extIds = new ExternalIDs();
extIds.getExternalIdentifier().add(extId);
work.setWorkExternalIdentifiers(extIds);
return work;
}
use of org.orcid.jaxb.model.record_rc3.ExternalID in project ORCID-Source by ORCID.
the class MemberV2_1Test method testUpdatePeerReviewWithProfileCreationTokenWhenClaimedAndNotSource.
@Test
public void testUpdatePeerReviewWithProfileCreationTokenWhenClaimedAndNotSource() throws JSONException, InterruptedException, URISyntaxException {
long time = System.currentTimeMillis();
PeerReview peerReviewToCreate = (PeerReview) unmarshallFromPath("/record_2.1/samples/read_samples/peer-review-2.1.xml", PeerReview.class);
peerReviewToCreate.setPutCode(null);
peerReviewToCreate.setGroupId(groupRecords.get(0).getGroupId());
peerReviewToCreate.setVisibility(Visibility.PUBLIC);
peerReviewToCreate.getExternalIdentifiers().getExternalIdentifier().clear();
ExternalID wExtId = new ExternalID();
wExtId.setValue("Work Id " + time);
wExtId.setType(WorkExternalIdentifierType.AGR.value());
wExtId.setRelationship(Relationship.SELF);
peerReviewToCreate.getExternalIdentifiers().getExternalIdentifier().add(wExtId);
String accessToken = getAccessToken();
ClientResponse postResponse = memberV2_1ApiClient.createPeerReviewXml(this.getUser1OrcidId(), peerReviewToCreate, accessToken);
assertNotNull(postResponse);
assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
String locationPath = postResponse.getLocation().getPath();
assertTrue("Location header path should match pattern, but was " + locationPath, locationPath.matches(".*/v2.1/" + this.getUser1OrcidId() + "/peer-review/\\d+"));
ClientResponse getResponse = memberV2_1ApiClient.viewLocationXml(postResponse.getLocation(), accessToken);
assertEquals(Response.Status.OK.getStatusCode(), getResponse.getStatus());
PeerReview gotPeerReview = getResponse.getEntity(PeerReview.class);
assertEquals("peer-review:subject-name", gotPeerReview.getSubjectName().getTitle().getContent());
gotPeerReview.getSubjectName().getTitle().setContent("updated title");
String profileCreateToken = oauthHelper.getClientCredentialsAccessToken(this.getClient2ClientId(), this.getClient2ClientSecret(), ScopePathType.ORCID_PROFILE_CREATE);
ClientResponse putResponse = memberV2_1ApiClient.updateLocationXml(postResponse.getLocation(), profileCreateToken, gotPeerReview);
assertEquals(Response.Status.FORBIDDEN.getStatusCode(), putResponse.getStatus());
ClientResponse getAfterUpdateResponse = memberV2_1ApiClient.viewLocationXml(postResponse.getLocation(), accessToken);
assertEquals(Response.Status.OK.getStatusCode(), getAfterUpdateResponse.getStatus());
PeerReview gotAfterUpdatePeerReview = getAfterUpdateResponse.getEntity(PeerReview.class);
assertEquals("peer-review:subject-name", gotAfterUpdatePeerReview.getSubjectName().getTitle().getContent());
ClientResponse deleteResponse = memberV2_1ApiClient.deletePeerReviewXml(this.getUser1OrcidId(), gotAfterUpdatePeerReview.getPutCode(), accessToken);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
}
Aggregations