Search in sources :

Example 56 with Funding

use of org.orcid.jaxb.model.record_rc2.Funding in project ORCID-Source by ORCID.

the class ValidateV2RC4Identifiers method testFunding.

@Test
public void testFunding() throws SAXException, IOException, JAXBException, ParserConfigurationException {
    Funding funding = unmarshallFromPath("/record_2.0_rc4/samples/funding-2.0_rc4.xml", Funding.class);
    assertEquals("funding:organization-defined-type", funding.getOrganizationDefinedType().getContent());
    assertNotNull(funding.getExternalIdentifiers());
    assertNotNull(funding.getExternalIdentifiers().getExternalIdentifier());
    Assert.notEmpty(funding.getExternalIdentifiers().getExternalIdentifier());
    assertEquals("grant_number", funding.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
    assertEquals("funding:external-identifier-value", funding.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals(new Url("http://tempuri.org"), funding.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl());
    assertEquals(Relationship.SELF, funding.getExternalIdentifiers().getExternalIdentifier().get(0).getRelationship());
    Validator validator = getValidator("funding");
    validator.validate(marshall(Funding.class, funding));
    validator.validate(marshallToDOM(Funding.class, funding));
}
Also used : Funding(org.orcid.jaxb.model.record_rc4.Funding) Url(org.orcid.jaxb.model.common_rc4.Url) Validator(javax.xml.validation.Validator) MarshallingTest(org.orcid.jaxb.model.notification.custom.MarshallingTest) Test(org.junit.Test)

Example 57 with Funding

use of org.orcid.jaxb.model.record_rc2.Funding in project ORCID-Source by ORCID.

the class PublicV2ApiServiceDelegatorTest method testViewFunding.

@Test
public void testViewFunding() {
    Response response = serviceDelegator.viewFunding(ORCID, 10L);
    assertNotNull(response);
    Funding funding = (Funding) response.getEntity();
    assertNotNull(funding);
    assertNotNull(funding.getLastModifiedDate());
    assertNotNull(funding.getLastModifiedDate().getValue());
    assertNotNull(funding.getTitle());
    assertNotNull(funding.getTitle().getTitle());
    assertEquals(Long.valueOf(10), funding.getPutCode());
    assertEquals("/0000-0000-0000-0003/funding/10", funding.getPath());
    assertEquals("PUBLIC", funding.getTitle().getTitle().getContent());
    assertEquals(Visibility.PUBLIC.value(), funding.getVisibility().value());
    assertEquals("APP-5555555555555555", funding.getSource().retrieveSourcePath());
}
Also used : Response(javax.ws.rs.core.Response) Funding(org.orcid.jaxb.model.record_v2.Funding) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 58 with Funding

use of org.orcid.jaxb.model.record_rc2.Funding in project ORCID-Source by ORCID.

the class JpaJaxbFundingAdapterTest method getFunding.

private Funding getFunding(boolean full) throws JAXBException {
    JAXBContext context = JAXBContext.newInstance(new Class[] { Funding.class });
    Unmarshaller unmarshaller = context.createUnmarshaller();
    String name = "/record_2.0/samples/read_samples/funding-2.0.xml";
    if (full) {
        name = "/record_2.0/samples/read_samples/funding-full-2.0.xml";
    }
    InputStream inputStream = getClass().getResourceAsStream(name);
    return (Funding) unmarshaller.unmarshal(inputStream);
}
Also used : Funding(org.orcid.jaxb.model.record_v2.Funding) InputStream(java.io.InputStream) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller)

Example 59 with Funding

use of org.orcid.jaxb.model.record_rc2.Funding in project ORCID-Source by ORCID.

the class JpaJaxbFundingAdapterTest method toFundingEntityTest.

@Test
public void toFundingEntityTest() throws JAXBException {
    Funding f = getFunding(true);
    assertNotNull(f);
    ProfileFundingEntity pfe = jpaJaxbFundingAdapter.toProfileFundingEntity(f);
    assertNotNull(pfe);
    // Enums
    assertEquals(Visibility.PRIVATE.value(), pfe.getVisibility().value());
    assertEquals(FundingType.GRANT.value(), pfe.getType().value());
    // General info
    assertEquals(Long.valueOf(0), pfe.getId());
    assertEquals("common:title", pfe.getTitle());
    assertEquals("common:translated-title", pfe.getTranslatedTitle());
    assertEquals("en", pfe.getTranslatedTitleLanguageCode());
    assertEquals("funding:organization-defined-type", pfe.getOrganizationDefinedType());
    assertEquals("funding:short-description", pfe.getDescription());
    assertEquals("1234", pfe.getNumericAmount().toString());
    assertEquals("ADP", pfe.getCurrencyCode());
    assertEquals("http://tempuri.org", pfe.getUrl());
    // Dates
    assertEquals(Integer.valueOf(2), pfe.getStartDate().getDay());
    assertEquals(Integer.valueOf(2), pfe.getStartDate().getMonth());
    assertEquals(Integer.valueOf(1848), pfe.getStartDate().getYear());
    assertEquals(Integer.valueOf(2), pfe.getEndDate().getDay());
    assertEquals(Integer.valueOf(2), pfe.getEndDate().getMonth());
    assertEquals(Integer.valueOf(1848), pfe.getEndDate().getYear());
    // Contributors
    assertEquals("{\"contributor\":[{\"contributorOrcid\":{\"uri\":\"http://orcid.org/8888-8888-8888-8880\",\"path\":\"8888-8888-8888-8880\",\"host\":\"orcid.org\"},\"creditName\":{\"content\":\"funding:credit-name\"},\"contributorEmail\":{\"value\":\"funding@contributor.email\"},\"contributorAttributes\":{\"contributorRole\":\"LEAD\"}}]}", pfe.getContributorsJson());
    // External identifiers
    assertEquals("{\"fundingExternalIdentifier\":[{\"type\":\"GRANT_NUMBER\",\"value\":\"funding:external-identifier-value\",\"url\":{\"value\":\"http://tempuri.org\"},\"relationship\":\"SELF\"},{\"type\":\"GRANT_NUMBER\",\"value\":\"funding:external-identifier-value2\",\"url\":{\"value\":\"http://tempuri.org/2\"},\"relationship\":\"SELF\"}]}", pfe.getExternalIdentifiersJson());
    // Check org is null
    assertNull(pfe.getOrg());
    // Source
    assertNull(pfe.getSourceId());
    assertNull(pfe.getClientSourceId());
    assertNull(pfe.getElementSourceId());
}
Also used : Funding(org.orcid.jaxb.model.record_v2.Funding) ProfileFundingEntity(org.orcid.persistence.jpa.entities.ProfileFundingEntity) Test(org.junit.Test)

Example 60 with Funding

use of org.orcid.jaxb.model.record_rc2.Funding in project ORCID-Source by ORCID.

the class JpaJaxbFundingAdapterTest method fromFundingEntityTest.

@Test
public void fromFundingEntityTest() throws JAXBException {
    ProfileFundingEntity entity = getProfileFundingEntity();
    assertNotNull(entity);
    assertEquals("123456", entity.getNumericAmount().toString());
    Funding funding = jpaJaxbFundingAdapter.toFunding(entity);
    assertNotNull(funding);
    assertEquals(Long.valueOf(12345), funding.getPutCode());
    assertNotNull(funding.getAmount());
    assertEquals("123456", funding.getAmount().getContent());
    assertEquals("CRC", funding.getAmount().getCurrencyCode());
    assertNotNull(funding.getContributors());
    assertNotNull(funding.getContributors().getContributor());
    assertEquals(1, funding.getContributors().getContributor().size());
    assertEquals("8888-8888-8888-8880", funding.getContributors().getContributor().get(0).getContributorOrcid().getPath());
    assertEquals("orcid.org", funding.getContributors().getContributor().get(0).getContributorOrcid().getHost());
    assertEquals("http://orcid.org/8888-8888-8888-8880", funding.getContributors().getContributor().get(0).getContributorOrcid().getUri());
    assertEquals("funding:creditName", funding.getContributors().getContributor().get(0).getCreditName().getContent());
    assertEquals("funding:description", funding.getDescription());
    assertNotNull(funding.getStartDate());
    assertEquals("01", funding.getStartDate().getDay().getValue());
    assertEquals("01", funding.getStartDate().getMonth().getValue());
    assertEquals("2000", funding.getStartDate().getYear().getValue());
    assertNotNull(funding.getEndDate());
    assertEquals("01", funding.getEndDate().getDay().getValue());
    assertEquals("01", funding.getEndDate().getMonth().getValue());
    assertEquals("2020", funding.getEndDate().getYear().getValue());
    assertEquals("funding:title", funding.getTitle().getTitle().getContent());
    assertEquals("funding:translatedTitle", funding.getTitle().getTranslatedTitle().getContent());
    assertEquals("ES", funding.getTitle().getTranslatedTitle().getLanguageCode());
    assertEquals(FundingType.SALARY_AWARD, funding.getType());
    assertEquals(Visibility.PRIVATE, funding.getVisibility());
}
Also used : Funding(org.orcid.jaxb.model.record_v2.Funding) ProfileFundingEntity(org.orcid.persistence.jpa.entities.ProfileFundingEntity) Test(org.junit.Test)

Aggregations

Funding (org.orcid.jaxb.model.record_v2.Funding)82 Test (org.junit.Test)71 ClientResponse (com.sun.jersey.api.client.ClientResponse)28 ArrayList (java.util.ArrayList)17 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)16 Response (javax.ws.rs.core.Response)15 Url (org.orcid.jaxb.model.common_v2.Url)15 DBUnitTest (org.orcid.test.DBUnitTest)15 Title (org.orcid.jaxb.model.common_v2.Title)11 Work (org.orcid.jaxb.model.record_v2.Work)10 List (java.util.List)9 FundingTitle (org.orcid.jaxb.model.record_v2.FundingTitle)9 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)9 Funding (org.orcid.jaxb.model.record_rc1.Funding)8 Education (org.orcid.jaxb.model.record_v2.Education)8 ExternalIDs (org.orcid.jaxb.model.record_v2.ExternalIDs)8 WorkTitle (org.orcid.jaxb.model.record_v2.WorkTitle)8 IOException (java.io.IOException)7 InputStreamReader (java.io.InputStreamReader)6 Reader (java.io.Reader)6