use of org.orcid.jaxb.model.record_rc4.ExternalIDs in project ORCID-Source by ORCID.
the class ExternalIDValidatorTest method testValidExtIdsWorksFine_flagOff.
@Test
public void testValidExtIdsWorksFine_flagOff() {
ExternalIDs extIds = new ExternalIDs();
ExternalID id1 = new ExternalID();
id1.setRelationship(null);
id1.setType("doi");
id1.setValue("value1");
id1.setUrl(new Url("http://value1.com"));
ExternalID id2 = new ExternalID();
id2.setRelationship(null);
id2.setType("doi");
id2.setValue("value1");
id2.setUrl(new Url("http://value1.com"));
ExternalID id3 = new ExternalID();
id3.setRelationship(null);
id3.setType("doi");
id3.setValue("value1");
id3.setUrl(new Url("http://value1.com"));
extIds.getExternalIdentifier().add(id1);
extIds.getExternalIdentifier().add(id2);
extIds.getExternalIdentifier().add(id3);
validator.validateWorkOrPeerReview(extIds);
}
use of org.orcid.jaxb.model.record_rc4.ExternalIDs in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_WorksTest method testCreateWorksWithBulkAllOK.
@Test
public void testCreateWorksWithBulkAllOK() {
Long time = System.currentTimeMillis();
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
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);
}
Response response = serviceDelegator.createWorks(ORCID, bulk);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
bulk = (WorkBulk) response.getEntity();
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);
Utils.verifyLastModified(w.getLastModifiedDate());
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());
Response r = serviceDelegator.viewWork(ORCID, w.getPutCode());
assertNotNull(r);
assertEquals(Response.Status.OK.getStatusCode(), r.getStatus());
assertEquals("Bulk work " + i + " " + time, ((Work) r.getEntity()).getWorkTitle().getTitle().getContent());
// Delete the work
r = serviceDelegator.deleteWork(ORCID, w.getPutCode());
assertNotNull(r);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), r.getStatus());
}
}
use of org.orcid.jaxb.model.record_rc4.ExternalIDs 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_rc4.ExternalIDs 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_rc4.ExternalIDs 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);
}
Aggregations