Search in sources :

Example 21 with ExternalIDs

use of org.orcid.jaxb.model.record_rc4.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()));
    }
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) WorkBulk(org.orcid.jaxb.model.record_v2.WorkBulk) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Work(org.orcid.jaxb.model.record_v2.Work) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) Title(org.orcid.jaxb.model.common_v2.Title) Url(org.orcid.jaxb.model.common_v2.Url) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 22 with ExternalIDs

use of org.orcid.jaxb.model.record_rc4.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;
}
Also used : WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) Title(org.orcid.jaxb.model.common_v2.Title) Url(org.orcid.jaxb.model.common_v2.Url)

Example 23 with ExternalIDs

use of org.orcid.jaxb.model.record_rc4.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);
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Work(org.orcid.jaxb.model.record_v2.Work) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 24 with ExternalIDs

use of org.orcid.jaxb.model.record_rc4.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;
    }
}
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 25 with ExternalIDs

use of org.orcid.jaxb.model.record_rc4.ExternalIDs in project ORCID-Source by ORCID.

the class ExternalIDValidatorTest method testValidExtIdsWorksFine_flagOn.

@Test
public void testValidExtIdsWorksFine_flagOn() {
    validator.setRequireRelationshipOnExternalIdentifier(true);
    ExternalIDs extIds = new ExternalIDs();
    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("doi");
    id2.setValue("value1");
    id2.setUrl(new Url("http://value1.com"));
    ExternalID id3 = new ExternalID();
    id3.setRelationship(Relationship.SELF);
    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);
}
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) Test(org.junit.Test)

Aggregations

ExternalIDs (org.orcid.jaxb.model.record_v2.ExternalIDs)60 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)50 Url (org.orcid.jaxb.model.common_v2.Url)37 Test (org.junit.Test)32 Title (org.orcid.jaxb.model.common_v2.Title)24 WorkTitle (org.orcid.jaxb.model.record_v2.WorkTitle)20 Work (org.orcid.jaxb.model.record_v2.Work)15 FundingTitle (org.orcid.jaxb.model.record_v2.FundingTitle)11 MarshallingTest (org.orcid.jaxb.model.notification.custom.MarshallingTest)8 Funding (org.orcid.jaxb.model.record_v2.Funding)8 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)7 Organization (org.orcid.jaxb.model.common_v2.Organization)6 OrganizationAddress (org.orcid.jaxb.model.common_v2.OrganizationAddress)6 Response (javax.ws.rs.core.Response)5 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)5 FuzzyDate (org.orcid.jaxb.model.common_v2.FuzzyDate)4 TranslatedTitle (org.orcid.jaxb.model.common_v2.TranslatedTitle)4 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)4 BaseTest (org.orcid.core.BaseTest)3 Day (org.orcid.jaxb.model.common_v2.Day)3