Search in sources :

Example 31 with Funding

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

the class ProfileFundingManagerTest method testGetAll.

@Test
public void testGetAll() {
    String orcid = "0000-0000-0000-0003";
    List<Funding> elements = profileFundingManager.getFundingList(orcid, System.currentTimeMillis());
    assertNotNull(elements);
    assertEquals(5, elements.size());
    boolean found1 = false, found2 = false, found3 = false, found4 = false, found5 = false;
    for (Funding element : elements) {
        if (10 == element.getPutCode()) {
            found1 = true;
        } else if (11 == element.getPutCode()) {
            found2 = true;
        } else if (12 == element.getPutCode()) {
            found3 = true;
        } else if (13 == element.getPutCode()) {
            found4 = true;
        } else if (14 == element.getPutCode()) {
            found5 = true;
        } else {
            fail("Invalid put code found: " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
    assertTrue(found5);
}
Also used : Funding(org.orcid.jaxb.model.record_v2.Funding) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 32 with Funding

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

the class ProfileFundingManagerTest method testAddMultipleModifiesIndexingStatus.

@Test
public void testAddMultipleModifiesIndexingStatus() {
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    Funding f1 = getFunding("F1");
    f1 = profileFundingManager.createFunding(claimedOrcid, f1, true);
    Funding f2 = getFunding("F2");
    f2 = profileFundingManager.createFunding(claimedOrcid, f2, true);
    Funding f3 = getFunding("F3");
    f3 = profileFundingManager.createFunding(claimedOrcid, f3, true);
    ProfileFundingEntity entity1 = profileFundingDao.find(f1.getPutCode());
    ProfileFundingEntity entity2 = profileFundingDao.find(f2.getPutCode());
    ProfileFundingEntity entity3 = profileFundingDao.find(f3.getPutCode());
    assertNotNull(entity1.getDisplayIndex());
    assertNotNull(entity2.getDisplayIndex());
    assertNotNull(entity3.getDisplayIndex());
    assertEquals(Long.valueOf(0), entity3.getDisplayIndex());
    //Rollback all changes
    profileFundingDao.remove(entity1.getId());
    profileFundingDao.remove(entity2.getId());
    profileFundingDao.remove(entity3.getId());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) Funding(org.orcid.jaxb.model.record_v2.Funding) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) ProfileFundingEntity(org.orcid.persistence.jpa.entities.ProfileFundingEntity) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 33 with Funding

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

the class ProfileFundingManagerTest method displayIndexIsSetTo_1_FromUI.

@Test
public void displayIndexIsSetTo_1_FromUI() {
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    Funding f1 = getFunding("fromUI-1");
    f1 = profileFundingManager.createFunding(claimedOrcid, f1, false);
    ProfileFundingEntity f = profileFundingDao.find(f1.getPutCode());
    assertNotNull(f);
    assertEquals(Long.valueOf(1), f.getDisplayIndex());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) Funding(org.orcid.jaxb.model.record_v2.Funding) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) ProfileFundingEntity(org.orcid.persistence.jpa.entities.ProfileFundingEntity) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 34 with Funding

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

the class ActivityValidatorTest method validateFunding_invalidCurrencyCodeTest.

@Test
public void validateFunding_invalidCurrencyCodeTest() {
    try {
        Funding funding = getFunding();
        funding.getAmount().setCurrencyCode(null);
        activityValidator.validateFunding(funding, null, true, true, Visibility.PUBLIC);
        fail();
    } catch (OrcidValidationException e) {
    }
    try {
        Funding funding = getFunding();
        funding.getAmount().setContent(null);
        activityValidator.validateFunding(funding, null, true, true, Visibility.PUBLIC);
        fail();
    } catch (OrcidValidationException e) {
    }
}
Also used : Funding(org.orcid.jaxb.model.record_v2.Funding) OrcidValidationException(org.orcid.core.exception.OrcidValidationException) Test(org.junit.Test)

Example 35 with Funding

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

the class ActivityValidatorTest method validateFunding_invalidExternalIdentifiersTest.

@Test(expected = ActivityIdentifierValidationException.class)
public void validateFunding_invalidExternalIdentifiersTest() {
    Funding funding = getFunding();
    funding.getExternalIdentifiers().getExternalIdentifier().get(0).setType(null);
    activityValidator.validateFunding(funding, null, true, true, Visibility.PUBLIC);
}
Also used : Funding(org.orcid.jaxb.model.record_v2.Funding) Test(org.junit.Test)

Aggregations

Funding (org.orcid.jaxb.model.record_v2.Funding)82 Test (org.junit.Test)70 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 IOException (java.io.IOException)8 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 InputStreamReader (java.io.InputStreamReader)7 Reader (java.io.Reader)7