use of org.orcid.jaxb.model.v3.dev1.record.ExternalIDs in project ORCID-Source by ORCID.
the class WorkManagerTest method testCreateWorksWithBulkAllErrors.
@Test
public void testCreateWorksWithBulkAllErrors() {
String orcid = "0000-0000-0000-0003";
when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
// Set up data:
// Create one work with a DOI doi-1 so we can create a duplicate
Work work = new Work();
WorkTitle workTitle = new WorkTitle();
workTitle.setTitle(new Title("work #1"));
work.setWorkTitle(workTitle);
ExternalIDs extIds = new ExternalIDs();
extIds.getExternalIdentifier().add(getDuplicateExternalId());
work.setWorkExternalIdentifiers(extIds);
work.setWorkType(WorkType.BOOK);
Work newWork = workManager.createWork(orcid, work, true);
Long putCode = newWork.getPutCode();
WorkBulk bulk = new WorkBulk();
// Work # 1: No ext ids
Work work1 = getWork("work # 1 " + System.currentTimeMillis());
work1.getExternalIdentifiers().getExternalIdentifier().clear();
// Work # 2: No title
Work work2 = getWork("work # 2 " + System.currentTimeMillis());
work2.getWorkTitle().getTitle().setContent(null);
// Work # 3: No work type
Work work3 = getWork("work # 3 " + System.currentTimeMillis());
work3.setWorkType(null);
// Work # 4: Ext id already exists
Work work4 = getWork("work # 4 " + System.currentTimeMillis());
work4.getExternalIdentifiers().getExternalIdentifier().add(getDuplicateExternalId());
bulk.getBulk().add(work1);
bulk.getBulk().add(work2);
bulk.getBulk().add(work3);
bulk.getBulk().add(work4);
bulk = workManager.createWorks(orcid, bulk);
assertNotNull(bulk);
assertEquals(4, bulk.getBulk().size());
for (int i = 0; i < bulk.getBulk().size(); i++) {
BulkElement element = bulk.getBulk().get(i);
assertTrue(OrcidError.class.isAssignableFrom(element.getClass()));
OrcidError error = (OrcidError) element;
switch(i) {
case 0:
assertEquals(Integer.valueOf(9023), error.getErrorCode());
break;
case 1:
assertEquals(Integer.valueOf(9022), error.getErrorCode());
break;
case 2:
assertEquals(Integer.valueOf(9037), error.getErrorCode());
break;
case 3:
assertEquals(Integer.valueOf(9021), error.getErrorCode());
break;
}
}
// Delete the work
assertTrue(workManager.checkSourceAndRemoveWork(orcid, putCode));
}
use of org.orcid.jaxb.model.v3.dev1.record.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.v3.dev1.record.ExternalIDs in project ORCID-Source by ORCID.
the class ActivityValidatorTest method getExternalIDs.
public ExternalIDs getExternalIDs() {
ExternalID id1 = getExternalID();
ExternalIDs extIds = new ExternalIDs();
extIds.getExternalIdentifier().add(id1);
return extIds;
}
use of org.orcid.jaxb.model.v3.dev1.record.ExternalIDs in project ORCID-Source by ORCID.
the class PeerReviewManagerTest method getPeerReviewSummary.
private PeerReviewSummary getPeerReviewSummary(String titleValue, String extIdValue, Visibility visibility) {
PeerReviewSummary summary = new PeerReviewSummary();
summary.setGroupId(titleValue);
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.v3.dev1.record.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);
DisambiguatedOrganization disambiguatedOrg = new DisambiguatedOrganization();
disambiguatedOrg.setDisambiguatedOrganizationIdentifier("abc456");
disambiguatedOrg.setDisambiguationSource("WDB");
org.setDisambiguatedOrganization(disambiguatedOrg);
peerReview.setOrganization(org);
peerReview.setType(PeerReviewType.EVALUATION);
peerReview.setVisibility(Visibility.PUBLIC);
return peerReview;
}
Aggregations