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));
}
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());
}
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);
}
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());
}
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());
}
Aggregations