Search in sources :

Example 66 with Funding

use of org.orcid.jaxb.model.record_rc3.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());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) Funding(org.orcid.jaxb.model.record_v2.Funding) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 67 with Funding

use of org.orcid.jaxb.model.record_rc3.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;
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) Organization(org.orcid.jaxb.model.common_v2.Organization) Funding(org.orcid.jaxb.model.record_v2.Funding) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) OrganizationAddress(org.orcid.jaxb.model.common_v2.OrganizationAddress) FundingTitle(org.orcid.jaxb.model.record_v2.FundingTitle) Title(org.orcid.jaxb.model.common_v2.Title) FundingTitle(org.orcid.jaxb.model.record_v2.FundingTitle) Url(org.orcid.jaxb.model.common_v2.Url)

Example 68 with Funding

use of org.orcid.jaxb.model.record_rc3.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());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) Funding(org.orcid.jaxb.model.record_v2.Funding) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 69 with Funding

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

the class ContributorUtilsTest method testFilterContributorPrivateDataForFundingWithNoOrcidRecord.

@Test
public void testFilterContributorPrivateDataForFundingWithNoOrcidRecord() {
    Funding funding = getFundingWithContributorWithoutOrcid();
    contributorUtils.filterContributorPrivateData(funding);
    FundingContributor contributor = funding.getContributors().getContributor().get(0);
    assertNull(contributor.getContributorEmail());
    assertEquals("original credit name", contributor.getCreditName().getContent());
}
Also used : Funding(org.orcid.jaxb.model.record_v2.Funding) FundingContributor(org.orcid.jaxb.model.record_v2.FundingContributor) Test(org.junit.Test)

Example 70 with Funding

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

the class ContributorUtilsTest method getFundingWithoutContributors.

private Funding getFundingWithoutContributors() {
    Funding funding = new Funding();
    FundingTitle fundingTitle = new FundingTitle();
    fundingTitle.setTitle(new Title("funding without contributors"));
    funding.setTitle(fundingTitle);
    return funding;
}
Also used : Funding(org.orcid.jaxb.model.record_v2.Funding) FundingTitle(org.orcid.jaxb.model.record_v2.FundingTitle) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) Title(org.orcid.jaxb.model.common_v2.Title) FundingTitle(org.orcid.jaxb.model.record_v2.FundingTitle)

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 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 BaseTest (org.orcid.core.BaseTest)6