Search in sources :

Example 1 with FundingExternalIdentifier

use of org.orcid.core.adapter.impl.jsonidentifiers.FundingExternalIdentifier in project ORCID-Source by ORCID.

the class FundingExternalIdentifiersConversionsTest method recordToCoreObjectTest.

@Test
public void recordToCoreObjectTest() {
    ExternalIDs recordFei = new ExternalIDs();
    ExternalID f1 = new ExternalID();
    f1.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
    f1.setUrl(new org.orcid.jaxb.model.common_v2.Url("www.f1.com"));
    f1.setValue("f1");
    recordFei.getExternalIdentifier().add(f1);
    ExternalID f2 = new ExternalID();
    f2.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
    f2.setUrl(new org.orcid.jaxb.model.common_v2.Url("www.f2.com"));
    f2.setValue("f2");
    recordFei.getExternalIdentifier().add(f2);
    ExternalID f3 = new ExternalID();
    f3.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
    f3.setUrl(new org.orcid.jaxb.model.common_v2.Url("www.f3.com"));
    f3.setValue("f3");
    recordFei.getExternalIdentifier().add(f3);
    FundingExternalIdentifiers fei = new FundingExternalIdentifiers(recordFei);
    assertNotNull(fei);
    assertEquals(3, fei.getFundingExternalIdentifier().size());
    boolean found1 = false, found2 = false, found3 = false;
    for (FundingExternalIdentifier f : fei.getFundingExternalIdentifier()) {
        if (f.getValue().equals("f1")) {
            found1 = true;
            assertEquals("www.f1.com", f.getUrl().getValue());
            assertEquals(FundingExternalIdentifierType.GRANT_NUMBER.value().toUpperCase(), f.getType());
        } else if (f.getValue().equals("f2")) {
            found2 = true;
            assertEquals("www.f2.com", f.getUrl().getValue());
            assertEquals(FundingExternalIdentifierType.GRANT_NUMBER.value().toUpperCase(), f.getType());
        } else if (f.getValue().equals("f3")) {
            found3 = true;
            assertEquals("www.f3.com", f.getUrl().getValue());
            assertEquals(FundingExternalIdentifierType.GRANT_NUMBER.value().toUpperCase(), f.getType());
        } else {
            fail();
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) FundingExternalIdentifiers(org.orcid.core.adapter.impl.jsonidentifiers.FundingExternalIdentifiers) FundingExternalIdentifier(org.orcid.core.adapter.impl.jsonidentifiers.FundingExternalIdentifier) Test(org.junit.Test)

Example 2 with FundingExternalIdentifier

use of org.orcid.core.adapter.impl.jsonidentifiers.FundingExternalIdentifier in project ORCID-Source by ORCID.

the class FundingExternalIdentifiersConversionsTest method getFundingExternalIdentifiers.

private FundingExternalIdentifiers getFundingExternalIdentifiers() {
    FundingExternalIdentifiers fei = new FundingExternalIdentifiers();
    FundingExternalIdentifier f1 = new FundingExternalIdentifier(FundingExternalIdentifierType.GRANT_NUMBER, "www.f1.com", "f1");
    fei.getFundingExternalIdentifier().add(f1);
    FundingExternalIdentifier f2 = new FundingExternalIdentifier(FundingExternalIdentifierType.GRANT_NUMBER, "www.f2.com", "f2");
    fei.getFundingExternalIdentifier().add(f2);
    FundingExternalIdentifier f3 = new FundingExternalIdentifier(FundingExternalIdentifierType.GRANT_NUMBER, "www.f3.com", "f3");
    fei.getFundingExternalIdentifier().add(f3);
    return fei;
}
Also used : FundingExternalIdentifiers(org.orcid.core.adapter.impl.jsonidentifiers.FundingExternalIdentifiers) FundingExternalIdentifier(org.orcid.core.adapter.impl.jsonidentifiers.FundingExternalIdentifier)

Example 3 with FundingExternalIdentifier

use of org.orcid.core.adapter.impl.jsonidentifiers.FundingExternalIdentifier in project ORCID-Source by ORCID.

the class FundingExternalIdentifiersConversionsTest method messageToCoreObjectTest.

//TODO: write same test for WorkExternalIdentifiers
//TODO: refactor out separate pojos for the different identifiers (requires DB work?)
@Test
public void messageToCoreObjectTest() {
    org.orcid.jaxb.model.message.FundingExternalIdentifiers recordFei = new org.orcid.jaxb.model.message.FundingExternalIdentifiers();
    org.orcid.jaxb.model.message.FundingExternalIdentifier f1 = new org.orcid.jaxb.model.message.FundingExternalIdentifier();
    f1.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER);
    f1.setUrl(new org.orcid.jaxb.model.message.Url("www.f1.com"));
    f1.setValue("f1");
    recordFei.getFundingExternalIdentifier().add(f1);
    org.orcid.jaxb.model.message.FundingExternalIdentifier f2 = new org.orcid.jaxb.model.message.FundingExternalIdentifier();
    f2.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER);
    f2.setUrl(new org.orcid.jaxb.model.message.Url("www.f2.com"));
    f2.setValue("f2");
    recordFei.getFundingExternalIdentifier().add(f2);
    org.orcid.jaxb.model.message.FundingExternalIdentifier f3 = new org.orcid.jaxb.model.message.FundingExternalIdentifier();
    f3.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER);
    f3.setUrl(new org.orcid.jaxb.model.message.Url("www.f3.com"));
    f3.setValue("f3");
    recordFei.getFundingExternalIdentifier().add(f3);
    FundingExternalIdentifiers fei = new FundingExternalIdentifiers(recordFei);
    assertNotNull(fei);
    assertEquals(3, fei.getFundingExternalIdentifier().size());
    boolean found1 = false, found2 = false, found3 = false;
    for (FundingExternalIdentifier f : fei.getFundingExternalIdentifier()) {
        if (f.getValue().equals("f1")) {
            found1 = true;
            assertEquals("www.f1.com", f.getUrl().getValue());
            assertEquals(FundingExternalIdentifierType.GRANT_NUMBER.value().toUpperCase(), f.getType());
        } else if (f.getValue().equals("f2")) {
            found2 = true;
            assertEquals("www.f2.com", f.getUrl().getValue());
            assertEquals(FundingExternalIdentifierType.GRANT_NUMBER.value().toUpperCase(), f.getType());
        } else if (f.getValue().equals("f3")) {
            found3 = true;
            assertEquals("www.f3.com", f.getUrl().getValue());
            assertEquals(FundingExternalIdentifierType.GRANT_NUMBER.value().toUpperCase(), f.getType());
        } else {
            fail();
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
}
Also used : FundingExternalIdentifiers(org.orcid.core.adapter.impl.jsonidentifiers.FundingExternalIdentifiers) FundingExternalIdentifier(org.orcid.core.adapter.impl.jsonidentifiers.FundingExternalIdentifier) Test(org.junit.Test)

Aggregations

FundingExternalIdentifier (org.orcid.core.adapter.impl.jsonidentifiers.FundingExternalIdentifier)3 FundingExternalIdentifiers (org.orcid.core.adapter.impl.jsonidentifiers.FundingExternalIdentifiers)3 Test (org.junit.Test)2 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)1 ExternalIDs (org.orcid.jaxb.model.record_v2.ExternalIDs)1