use of org.orcid.jaxb.model.record_v2.ExternalIDs in project ORCID-Source by ORCID.
the class PeerReviewManagerTest method getPeerReview.
private PeerReview getPeerReview(String extIdValue) {
PeerReview peerReview = new PeerReview();
peerReview.setRole(Role.CHAIR);
ExternalIDs extIds = new ExternalIDs();
ExternalID extId = new ExternalID();
extId.setRelationship(Relationship.SELF);
extId.setType("doi");
extId.setUrl(new Url("http://orcid.org"));
if (extIdValue == null) {
extId.setValue("ext-id-value");
} else {
extId.setValue("ext-id-value-" + extIdValue);
}
extIds.getExternalIdentifier().add(extId);
peerReview.setExternalIdentifiers(extIds);
if (extIdValue == null) {
peerReview.setSubjectContainerName(new Title("Peer review title"));
} else {
peerReview.setSubjectContainerName(new Title("Peer review title " + extIdValue));
}
peerReview.setSubjectExternalIdentifier(extId);
Organization org = new Organization();
org.setName("org-name");
OrganizationAddress address = new OrganizationAddress();
address.setCity("city");
address.setCountry(Iso3166Country.US);
org.setAddress(address);
peerReview.setOrganization(org);
peerReview.setType(PeerReviewType.EVALUATION);
peerReview.setVisibility(Visibility.PUBLIC);
return peerReview;
}
use of org.orcid.jaxb.model.record_v2.ExternalIDs in project ORCID-Source by ORCID.
the class WorkManagerTest method testCreateWorksWithBulkAllOK.
@Test
public void testCreateWorksWithBulkAllOK() {
String orcid = "0000-0000-0000-0003";
Long time = System.currentTimeMillis();
when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
WorkBulk bulk = new WorkBulk();
for (int i = 0; i < 5; i++) {
Work work = new Work();
WorkTitle title = new WorkTitle();
title.setTitle(new Title("Bulk work " + i + " " + time));
work.setWorkTitle(title);
ExternalIDs extIds = new ExternalIDs();
ExternalID extId = new ExternalID();
extId.setRelationship(Relationship.SELF);
extId.setType("doi");
extId.setUrl(new Url("http://doi/" + i + "/" + time));
extId.setValue("doi-" + i + "-" + time);
extIds.getExternalIdentifier().add(extId);
work.setWorkExternalIdentifiers(extIds);
work.setWorkType(WorkType.BOOK);
bulk.getBulk().add(work);
}
bulk = workManager.createWorks(orcid, bulk);
assertNotNull(bulk);
assertEquals(5, bulk.getBulk().size());
for (int i = 0; i < 5; i++) {
assertTrue(Work.class.isAssignableFrom(bulk.getBulk().get(i).getClass()));
Work w = (Work) bulk.getBulk().get(i);
assertNotNull(w.getPutCode());
assertTrue(0L < w.getPutCode());
assertEquals("Bulk work " + i + " " + time, w.getWorkTitle().getTitle().getContent());
assertNotNull(w.getExternalIdentifiers().getExternalIdentifier());
assertEquals("doi-" + i + "-" + time, w.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
Work w1 = workManager.getWork(orcid, w.getPutCode(), 0L);
assertNotNull(w1);
assertEquals("Bulk work " + i + " " + time, w1.getWorkTitle().getTitle().getContent());
//Delete the work
assertTrue(workManager.checkSourceAndRemoveWork(orcid, w1.getPutCode()));
}
}
use of org.orcid.jaxb.model.record_v2.ExternalIDs in project ORCID-Source by ORCID.
the class WorkManagerTest method getWorkSummary.
private WorkSummary getWorkSummary(String titleValue, String extIdValue, Visibility visibility, String displayIndex) {
WorkSummary summary = new WorkSummary();
summary.setDisplayIndex(displayIndex);
Title title = new Title(titleValue);
WorkTitle workTitle = new WorkTitle();
workTitle.setTitle(title);
summary.setTitle(workTitle);
summary.setType(WorkType.ARTISTIC_PERFORMANCE);
summary.setVisibility(visibility);
ExternalIDs extIds = new ExternalIDs();
ExternalID extId = new ExternalID();
extId.setRelationship(Relationship.SELF);
extId.setType("doi");
extId.setUrl(new Url("http://orcid.org"));
extId.setValue(extIdValue);
extIds.getExternalIdentifier().add(extId);
summary.setExternalIdentifiers(extIds);
return summary;
}
use of org.orcid.jaxb.model.record_v2.ExternalIDs in project ORCID-Source by ORCID.
the class BibtexManagerTest method testDOIManagerIsInvoked.
@Test
public void testDOIManagerIsInvoked() {
when(doiManager.fetchDOIBibtex("111")).thenReturn("OK");
Work w = new Work();
w.setWorkExternalIdentifiers(new ExternalIDs());
ExternalID id = new ExternalID();
id.setType("doi");
id.setValue("111");
w.getExternalIdentifiers().getExternalIdentifier().add(id);
String bib = bibtexManager.generateBibtex(ORCID, w);
Assert.assertEquals("OK", bib);
}
use of org.orcid.jaxb.model.record_v2.ExternalIDs in project ORCID-Source by ORCID.
the class ExternalIDValidatorTest method testValidateWorkOrPeerReview.
@Test
public void testValidateWorkOrPeerReview() {
//call for ExternalID and ExternalIDs
//ID valid
ExternalID id1 = new ExternalID();
id1.setRelationship(Relationship.SELF);
id1.setType("doi");
id1.setValue("value1");
id1.setUrl(new Url("http://value1.com"));
validator.validateWorkOrPeerReview(id1);
//ID bad type
try {
id1.setType("invalid");
validator.validateWorkOrPeerReview(id1);
fail("no exception thrown for invalid type");
} catch (Exception e) {
if (!(e instanceof ActivityIdentifierValidationException))
throw e;
}
//id null
try {
id1.setType(null);
validator.validateWorkOrPeerReview(id1);
fail("no exception thrown for invalid type");
} catch (Exception e) {
if (!(e instanceof ActivityIdentifierValidationException))
throw e;
}
ExternalIDs ids = new ExternalIDs();
ids.getExternalIdentifier().add(id1);
//IDS one invalid
id1.setType("invalid");
try {
validator.validateWorkOrPeerReview(ids);
fail("no exception thrown for invalid type");
} catch (Exception e) {
if (!(e instanceof ActivityIdentifierValidationException))
throw e;
}
//IDS one valid (lowercase)
id1.setType("doi");
validator.validateWorkOrPeerReview(ids);
//IDS two valid
ExternalID id2 = new ExternalID();
id2.setRelationship(Relationship.SELF);
id2.setType("source-work-id");
id2.setValue("value2");
id2.setUrl(new Url("http://value1.com"));
ids.getExternalIdentifier().add(id2);
validator.validateWorkOrPeerReview(ids);
//IDS one invalid, one valid
id2.setType("not-a-type");
try {
validator.validateWorkOrPeerReview(ids);
fail("no exception thrown for invalid type");
} catch (Exception e) {
if (!(e instanceof ActivityIdentifierValidationException))
throw e;
}
}
Aggregations