Search in sources :

Example 1 with FundingExternalIdentifiers

use of org.orcid.core.adapter.impl.jsonidentifiers.FundingExternalIdentifiers 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 FundingExternalIdentifiers

use of org.orcid.core.adapter.impl.jsonidentifiers.FundingExternalIdentifiers 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 FundingExternalIdentifiers

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

the class FundingExternalIdentifiersConversionsTest method coreObjectToMessageTest.

@Test
public void coreObjectToMessageTest() {
    FundingExternalIdentifiers fei = getFundingExternalIdentifiers();
    org.orcid.jaxb.model.message.FundingExternalIdentifiers messageObject = fei.toMessagePojo();
    assertNotNull(messageObject);
    assertEquals(3, messageObject.getFundingExternalIdentifier().size());
    boolean found1 = false, found2 = false, found3 = false;
    for (org.orcid.jaxb.model.message.FundingExternalIdentifier f : messageObject.getFundingExternalIdentifier()) {
        if (f.getValue().equals("f1")) {
            found1 = true;
            assertEquals("www.f1.com", f.getUrl().getValue());
            assertEquals(FundingExternalIdentifierType.GRANT_NUMBER, f.getType());
        } else if (f.getValue().equals("f2")) {
            found2 = true;
            assertEquals("www.f2.com", f.getUrl().getValue());
            assertEquals(FundingExternalIdentifierType.GRANT_NUMBER, f.getType());
        } else if (f.getValue().equals("f3")) {
            found3 = true;
            assertEquals("www.f3.com", f.getUrl().getValue());
            assertEquals(FundingExternalIdentifierType.GRANT_NUMBER, f.getType());
        } else {
            fail();
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
}
Also used : FundingExternalIdentifiers(org.orcid.core.adapter.impl.jsonidentifiers.FundingExternalIdentifiers) Test(org.junit.Test)

Example 4 with FundingExternalIdentifiers

use of org.orcid.core.adapter.impl.jsonidentifiers.FundingExternalIdentifiers 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)

Example 5 with FundingExternalIdentifiers

use of org.orcid.core.adapter.impl.jsonidentifiers.FundingExternalIdentifiers 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);
}
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) Test(org.junit.Test)

Aggregations

FundingExternalIdentifiers (org.orcid.core.adapter.impl.jsonidentifiers.FundingExternalIdentifiers)7 Test (org.junit.Test)4 FundingExternalIdentifier (org.orcid.core.adapter.impl.jsonidentifiers.FundingExternalIdentifier)3 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)2 ExternalIDs (org.orcid.jaxb.model.record_v2.ExternalIDs)2 BigDecimal (java.math.BigDecimal)1 FundingTitle (org.orcid.jaxb.model.message.FundingTitle)1 FuzzyDate (org.orcid.jaxb.model.message.FuzzyDate)1 EndDateEntity (org.orcid.persistence.jpa.entities.EndDateEntity)1 FuzzyDateEntity (org.orcid.persistence.jpa.entities.FuzzyDateEntity)1 OrgDisambiguatedEntity (org.orcid.persistence.jpa.entities.OrgDisambiguatedEntity)1 OrgEntity (org.orcid.persistence.jpa.entities.OrgEntity)1 ProfileFundingEntity (org.orcid.persistence.jpa.entities.ProfileFundingEntity)1 StartDateEntity (org.orcid.persistence.jpa.entities.StartDateEntity)1