use of org.orcid.jaxb.model.record_rc4.Funding in project ORCID-Source by ORCID.
the class SourceInActivitiesTest method getFunding.
private Funding getFunding(String userOrcid) {
Funding funding = new Funding();
funding.setOrganization(getOrganization());
FundingTitle title = new FundingTitle();
title.setTitle(new Title("Title " + System.currentTimeMillis()));
funding.setTitle(title);
funding.setType(org.orcid.jaxb.model.record_v2.FundingType.AWARD);
ExternalID extId = new ExternalID();
extId.setValue("111");
extId.setType(FundingExternalIdentifierType.GRANT_NUMBER.value());
extId.setUrl(new Url("http://test.com"));
extId.setRelationship(Relationship.PART_OF);
ExternalIDs extIdentifiers = new ExternalIDs();
extIdentifiers.getExternalIdentifier().add(extId);
funding.setExternalIdentifiers(extIdentifiers);
funding = profileFundingManager.createFunding(userOrcid, funding, true);
return profileFundingManager.getFunding(userOrcid, funding.getPutCode());
}
use of org.orcid.jaxb.model.record_rc4.Funding in project ORCID-Source by ORCID.
the class ProfileFundingManagerTest method testAddFundingToClaimedRecordPreserveUserDefaultVisibility.
@Test
public void testAddFundingToClaimedRecordPreserveUserDefaultVisibility() {
when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
Funding funding = getFunding(null);
funding = profileFundingManager.createFunding(claimedOrcid, funding, true);
funding = profileFundingManager.getFunding(claimedOrcid, funding.getPutCode());
assertNotNull(funding);
assertEquals("Funding title", funding.getTitle().getTitle().getContent());
assertEquals(Visibility.LIMITED, funding.getVisibility());
}
use of org.orcid.jaxb.model.record_rc4.Funding in project ORCID-Source by ORCID.
the class ProfileFundingManagerTest method getFunding.
private Funding getFunding(String grantNumber) {
Funding funding = new Funding();
ExternalIDs extIds = new ExternalIDs();
ExternalID extId = new ExternalID();
extId.setRelationship(Relationship.SELF);
extId.setType("grant_number");
extId.setUrl(new Url("http://orcid.org"));
if (grantNumber == null) {
extId.setValue("ext-id-value");
} else {
extId.setValue(grantNumber);
}
extIds.getExternalIdentifier().add(extId);
funding.setExternalIdentifiers(extIds);
FundingTitle title = new FundingTitle();
if (grantNumber == null) {
title.setTitle(new Title("Funding title"));
} else {
title.setTitle(new Title("Funding title " + grantNumber));
}
funding.setTitle(title);
Organization org = new Organization();
org.setName("org-name");
OrganizationAddress address = new OrganizationAddress();
address.setCity("city");
address.setCountry(Iso3166Country.US);
org.setAddress(address);
funding.setOrganization(org);
funding.setVisibility(Visibility.PUBLIC);
funding.setType(FundingType.AWARD);
return funding;
}
use of org.orcid.jaxb.model.record_rc4.Funding in project ORCID-Source by ORCID.
the class ProfileFundingManagerTest method testAddFundingToUnclaimedRecordPreserveFundingVisibility.
@Test
public void testAddFundingToUnclaimedRecordPreserveFundingVisibility() {
when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
Funding funding = getFunding(null);
funding = profileFundingManager.createFunding(unclaimedOrcid, funding, true);
funding = profileFundingManager.getFunding(unclaimedOrcid, funding.getPutCode());
assertNotNull(funding);
assertEquals("Funding title", funding.getTitle().getTitle().getContent());
assertEquals(Visibility.PUBLIC, funding.getVisibility());
}
use of org.orcid.jaxb.model.record_rc4.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);
}
Aggregations