Search in sources :

Example 81 with ExternalID

use of org.orcid.jaxb.model.record_rc3.ExternalID in project ORCID-Source by ORCID.

the class ExternalIDValidatorTest method testValidateNotificationItems.

@Test
public void testValidateNotificationItems() {
    Item i = new Item();
    Item i2 = new Item();
    Items items = new Items();
    ExternalID id1 = new ExternalID();
    id1.setRelationship(Relationship.SELF);
    id1.setType("doi");
    id1.setValue("value1");
    id1.setUrl(new Url("http://value1.com"));
    ExternalID id2 = new ExternalID();
    id2.setRelationship(Relationship.SELF);
    id2.setType("source-work-id");
    id2.setValue("value2");
    id2.setUrl(new Url("http://value1.com"));
    i.setExternalIdentifier(id1);
    i2.setExternalIdentifier(id2);
    items.getItems().add(i);
    items.getItems().add(i2);
    // both valid
    validator.validateNotificationItems(items);
    // IDS one valid, one invalid
    id2.setType("blah");
    try {
        validator.validateNotificationItems(items);
        fail("no exception thrown for invalid type");
    } catch (Exception e) {
        if (!(e instanceof ActivityIdentifierValidationException))
            throw e;
    }
    // IDS one valid, one VALID due to null (at least we have to do this if we want other tests to pass!)
    id2.setType(null);
    validator.validateNotificationItems(items);
}
Also used : Item(org.orcid.jaxb.model.notification.permission_v2.Item) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Items(org.orcid.jaxb.model.notification.permission_v2.Items) Url(org.orcid.jaxb.model.common_v2.Url) ActivityIdentifierValidationException(org.orcid.core.exception.ActivityIdentifierValidationException) ActivityIdentifierValidationException(org.orcid.core.exception.ActivityIdentifierValidationException) Test(org.junit.Test)

Example 82 with ExternalID

use of org.orcid.jaxb.model.record_rc3.ExternalID in project ORCID-Source by ORCID.

the class ExternalIDValidatorTest method testValidateFunding.

@Test
public void testValidateFunding() {
    ExternalID id1 = new ExternalID();
    id1.setRelationship(Relationship.SELF);
    id1.setType("grant_number");
    id1.setValue("value1");
    id1.setUrl(new Url("http://value1.com"));
    ExternalIDs ids = new ExternalIDs();
    ids.getExternalIdentifier().add(id1);
    validator.validateFunding(ids);
    ExternalID id2 = new ExternalID();
    id2.setRelationship(Relationship.SELF);
    id2.setType("INVALID");
    id2.setValue("value2");
    id2.setUrl(new Url("http://value1.com"));
    ids.getExternalIdentifier().add(id2);
    // IDS one valid, one invalid
    try {
        validator.validateFunding(ids);
        fail("no exception thrown for invalid type");
    } catch (Exception e) {
        if (!(e instanceof ActivityIdentifierValidationException))
            throw e;
    }
    // both valid
    id2.setType("grant_number");
    validator.validateFunding(ids);
    // IDS one valid, one invalid due to null
    id2.setType(null);
    try {
        validator.validateFunding(ids);
        fail("no exception thrown for invalid type");
    } catch (Exception e) {
        if (!(e instanceof ActivityIdentifierValidationException))
            throw e;
    }
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Url(org.orcid.jaxb.model.common_v2.Url) ActivityIdentifierValidationException(org.orcid.core.exception.ActivityIdentifierValidationException) ActivityIdentifierValidationException(org.orcid.core.exception.ActivityIdentifierValidationException) Test(org.junit.Test)

Example 83 with ExternalID

use of org.orcid.jaxb.model.record_rc3.ExternalID in project ORCID-Source by ORCID.

the class WorkToCiteprocTranslatorTest method testBibtexWorkTranslationHyperAuthorLiteralAndMissingDOI.

@Test
public void testBibtexWorkTranslationHyperAuthorLiteralAndMissingDOI() {
    Work w = makeWork(bibtexHyperLiteral);
    ExternalIDs wei = new ExternalIDs();
    ExternalID eid = new ExternalID();
    eid.setType(WorkExternalIdentifierType.DOI.name());
    // WorkExternalIdentifierId id = new WorkExternalIdentifierId();
    eid.setValue("10.1234/1234");
    wei.getExternalIdentifier().add(eid);
    w.setWorkExternalIdentifiers(wei);
    WorkToCiteprocTranslator t = new WorkToCiteprocTranslator();
    CSLItemData d = t.toCiteproc(w, null, true);
    Assert.assertEquals(d.getAuthor().length, 1);
    Assert.assertEquals(d.getAuthor()[0].getLiteral(), "Altshuler, D.M. and Durbin, R.M. and Abecasis, G.R. and Bentley, D.R. and Chakravarti, A. and Clark, A.G. and Donnelly, P. and Eichler, E.E. and Flicek, P. and Gabriel, S.B. and Gibbs, R.A. and Gre...");
    Assert.assertEquals(d.getDOI(), "10.1234/1234");
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) CSLItemData(de.undercouch.citeproc.csl.CSLItemData) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Work(org.orcid.jaxb.model.record_v2.Work) Test(org.junit.Test)

Example 84 with ExternalID

use of org.orcid.jaxb.model.record_rc3.ExternalID in project ORCID-Source by ORCID.

the class EmailMessageSenderTest method createActivity.

private Item createActivity(ItemType actType, String actName, String doi) {
    Item act = new Item();
    act.setItemType(actType);
    act.setItemName(actName);
    ExternalID extId = new ExternalID();
    extId.setType("doi");
    extId.setValue(doi);
    act.setExternalIdentifier(extId);
    return act;
}
Also used : Item(org.orcid.jaxb.model.notification.permission_v2.Item) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID)

Example 85 with ExternalID

use of org.orcid.jaxb.model.record_rc3.ExternalID in project ORCID-Source by ORCID.

the class OrcidSecurityManagerTestBase method getExtId.

protected ExternalID getExtId(String value) {
    ExternalID extId = new ExternalID();
    extId.setValue(value);
    return extId;
}
Also used : ExternalID(org.orcid.jaxb.model.record_v2.ExternalID)

Aggregations

ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)116 Test (org.junit.Test)104 Url (org.orcid.jaxb.model.common_v2.Url)58 ClientResponse (com.sun.jersey.api.client.ClientResponse)53 ExternalIDs (org.orcid.jaxb.model.record_v2.ExternalIDs)53 Work (org.orcid.jaxb.model.record_v2.Work)34 Title (org.orcid.jaxb.model.common_v2.Title)28 WorkTitle (org.orcid.jaxb.model.record_v2.WorkTitle)22 Funding (org.orcid.jaxb.model.record_v2.Funding)16 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)15 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)14 ExternalID (org.orcid.jaxb.model.record_rc3.ExternalID)13 ExternalID (org.orcid.jaxb.model.record_rc4.ExternalID)13 ArrayList (java.util.ArrayList)12 OrcidError (org.orcid.jaxb.model.error_v2.OrcidError)12 FundingTitle (org.orcid.jaxb.model.record_v2.FundingTitle)11 BaseTest (org.orcid.core.BaseTest)9 WorkGroup (org.orcid.jaxb.model.record.summary_v2.WorkGroup)8 ExternalID (org.orcid.jaxb.model.record_rc2.ExternalID)8 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)8