Search in sources :

Example 76 with Funding

use of org.orcid.jaxb.model.v3.dev1.record.Funding in project ORCID-Source by ORCID.

the class ContributorUtilsTest method getFundingWithOrcidContributor.

private Funding getFundingWithOrcidContributor() {
    Funding funding = new Funding();
    FundingTitle fundingTitle = new FundingTitle();
    fundingTitle.setTitle(new Title("work with contributor who has ORCID record"));
    funding.setTitle(fundingTitle);
    funding.setContributors(getFundingContributorWithOrcid());
    return funding;
}
Also used : Funding(org.orcid.jaxb.model.v3.dev1.record.Funding) Title(org.orcid.jaxb.model.v3.dev1.common.Title) FundingTitle(org.orcid.jaxb.model.v3.dev1.record.FundingTitle) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) FundingTitle(org.orcid.jaxb.model.v3.dev1.record.FundingTitle)

Example 77 with Funding

use of org.orcid.jaxb.model.v3.dev1.record.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.v3.dev1.record.Funding) Title(org.orcid.jaxb.model.v3.dev1.common.Title) FundingTitle(org.orcid.jaxb.model.v3.dev1.record.FundingTitle) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) FundingTitle(org.orcid.jaxb.model.v3.dev1.record.FundingTitle)

Example 78 with Funding

use of org.orcid.jaxb.model.v3.dev1.record.Funding in project ORCID-Source by ORCID.

the class ActivitiesGroupGenerator_GroupingFundingsTest method groupFundings_4GroupsOf1Funding_Test.

@Test
public void groupFundings_4GroupsOf1Funding_Test() {
    ActivitiesGroupGenerator generator = new ActivitiesGroupGenerator();
    Map<String, FundingSummary> fundings = generateFundings();
    // Group the first group
    // funding-2 -> C, D, E
    FundingSummary funding2 = fundings.get("funding-2");
    generator.group(funding2);
    // There should be one group, and the ext ids should be A, B and C
    List<ActivitiesGroup> groups = generator.getGroups();
    assertNotNull(groups);
    assertEquals(1, groups.size());
    ActivitiesGroup g1 = groups.get(0);
    assertNotNull(g1);
    assertNotNull(g1.getActivities());
    assertEquals(1, g1.getActivities().size());
    assertTrue(g1.getActivities().contains(funding2));
    assertNotNull(g1.getGroupKeys());
    assertEquals(3, g1.getGroupKeys().size());
    checkExternalIdentifiers(funding2, g1);
    // Add another funding to the groups
    // funding-5 -> M, N, O
    FundingSummary funding5 = fundings.get("funding-5");
    generator.group(funding5);
    // There should be two groups, one for each funding
    groups = generator.getGroups();
    assertNotNull(groups);
    assertEquals(2, groups.size());
    // There should be one activity in each group
    assertEquals(1, groups.get(0).getActivities().size());
    assertEquals(1, groups.get(1).getActivities().size());
    // There should be 3 ext ids in each group
    assertEquals(3, groups.get(0).getGroupKeys().size());
    assertEquals(3, groups.get(1).getGroupKeys().size());
    // Check funding in groups
    checkActivityIsOnGroups(funding5, groups);
    // Add another funding to the groups
    // funding-7 -> 1, 2, B
    FundingSummary funding7 = fundings.get("funding-7");
    generator.group(funding7);
    groups = generator.getGroups();
    assertNotNull(groups);
    assertEquals(3, groups.size());
    // There should be one activity in each group
    assertEquals(1, groups.get(0).getActivities().size());
    assertEquals(1, groups.get(1).getActivities().size());
    assertEquals(1, groups.get(2).getActivities().size());
    // There should be 3 ext ids in each group
    assertEquals(3, groups.get(0).getGroupKeys().size());
    assertEquals(3, groups.get(1).getGroupKeys().size());
    assertEquals(3, groups.get(2).getGroupKeys().size());
    // Check funding in groups
    checkActivityIsOnGroups(funding7, groups);
    // Add another funding to the groups
    // funding-8 -> No external identifiers
    FundingSummary funding8 = fundings.get("funding-8");
    generator.group(funding8);
    groups = generator.getGroups();
    assertNotNull(groups);
    assertEquals(4, groups.size());
    // There should be one activity in each group
    assertEquals(1, groups.get(0).getActivities().size());
    assertEquals(1, groups.get(1).getActivities().size());
    assertEquals(1, groups.get(2).getActivities().size());
    assertEquals(1, groups.get(3).getActivities().size());
    // There should be 3 ext ids in each group, except for one group that doesnt have any ext id
    boolean funding8found = false;
    for (int i = 0; i < 4; i++) {
        if (groups.get(i).getGroupKeys().size() == 0) {
            funding8found = true;
        } else {
            assertEquals(3, groups.get(i).getGroupKeys().size());
        }
    }
    assertTrue("FundingSummary without ext ids was not found", funding8found);
    // Check funding in groups
    checkActivityIsOnGroups(funding8, groups);
}
Also used : FundingSummary(org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary) Test(org.junit.Test)

Example 79 with Funding

use of org.orcid.jaxb.model.v3.dev1.record.Funding in project ORCID-Source by ORCID.

the class ActivitiesGroupGenerator_GroupingFundingsTest method groupFundings_MergeGroupsDontAffectNotMergedGroups_Test.

/**
 * funding-1, funding-3, funding-5 and funding-8 will be in separate groups
 * then funding-4 will merge groups of funding-1 and funding-3
 *
 * Check that after that, there are 3 groups, one with funding-1, funding-3 and funding-4, one with funding-5 and other with funding-8
 */
@Test
public void groupFundings_MergeGroupsDontAffectNotMergedGroups_Test() {
    ActivitiesGroupGenerator generator = new ActivitiesGroupGenerator();
    Map<String, FundingSummary> fundings = generateFundings();
    // Group the first group
    FundingSummary funding1 = fundings.get("funding-1");
    FundingSummary funding3 = fundings.get("funding-3");
    FundingSummary funding4 = fundings.get("funding-4");
    FundingSummary funding5 = fundings.get("funding-5");
    FundingSummary funding8 = fundings.get("funding-8");
    // Respect order
    generator.group(funding1);
    generator.group(funding3);
    generator.group(funding5);
    generator.group(funding8);
    generator.group(funding4);
    List<ActivitiesGroup> groups = generator.getGroups();
    assertNotNull(groups);
    assertEquals(3, groups.size());
    // Check funding1, funding3 and funding4 belongs to the same group
    checkActivitiesBelongsToTheSameGroup(groups, funding1, funding3, funding4);
    // Check funding1, funding5 and funding8 are all in different groups
    checkActivitiesDontBelongsToTheSameGroup(groups, funding1, funding5, funding8);
    checkActivityIsOnGroups(funding1, groups);
    checkActivityIsOnGroups(funding3, groups);
    checkActivityIsOnGroups(funding4, groups);
    checkActivityIsOnGroups(funding5, groups);
    checkActivityIsOnGroups(funding8, groups);
}
Also used : FundingSummary(org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary) Test(org.junit.Test)

Example 80 with Funding

use of org.orcid.jaxb.model.v3.dev1.record.Funding in project ORCID-Source by ORCID.

the class ActivitiesGroupGenerator_GroupingFundingsTest method groupFundings_MergeTwoGroups_Test.

/**
 * funding-1 and funding-3 will be in different groups
 * then funding-2 will go to the same group as funding-1
 * then funding-4 contains Y and B so, the two groups should be merged
 */
@Test
public void groupFundings_MergeTwoGroups_Test() {
    ActivitiesGroupGenerator generator = new ActivitiesGroupGenerator();
    Map<String, FundingSummary> fundings = generateFundings();
    // Group the first group
    FundingSummary funding1 = fundings.get("funding-1");
    FundingSummary funding2 = fundings.get("funding-2");
    FundingSummary funding3 = fundings.get("funding-3");
    FundingSummary funding4 = fundings.get("funding-4");
    generator.group(funding1);
    generator.group(funding2);
    generator.group(funding3);
    /**
     * At this point there are two groups
     * G1 with funding1 and funding2
     * G2 with funding3
     */
    List<ActivitiesGroup> groups = generator.getGroups();
    assertNotNull(groups);
    assertEquals(2, groups.size());
    checkActivitiesBelongsToTheSameGroup(groups, funding1, funding2);
    checkActivitiesDontBelongsToTheSameGroup(groups, funding1, funding3);
    checkActivitiesDontBelongsToTheSameGroup(groups, funding2, funding3);
    // group funding4, which should merge the two groups
    generator.group(funding4);
    groups = generator.getGroups();
    assertNotNull(groups);
    assertEquals(1, groups.size());
    assertEquals(4, groups.get(0).getActivities().size());
    assertEquals(9, groups.get(0).getGroupKeys().size());
    checkActivityIsOnGroups(funding1, groups);
    checkActivityIsOnGroups(funding2, groups);
    checkActivityIsOnGroups(funding3, groups);
    checkActivityIsOnGroups(funding4, groups);
    checkActivitiesBelongsToTheSameGroup(groups, funding1, funding2, funding3, funding4);
}
Also used : FundingSummary(org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)76 Funding (org.orcid.jaxb.model.v3.dev1.record.Funding)72 FundingSummary (org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary)24 Response (javax.ws.rs.core.Response)23 DBUnitTest (org.orcid.test.DBUnitTest)23 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)20 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)15 EducationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary)12 EmploymentSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary)12 PeerReviewSummary (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary)12 WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)12 DistinctionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.DistinctionSummary)10 InvitedPositionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.InvitedPositionSummary)10 MembershipSummary (org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary)10 QualificationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.QualificationSummary)10 ServiceSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ServiceSummary)10 Url (org.orcid.jaxb.model.v3.dev1.common.Url)9 FundingContributor (org.orcid.jaxb.model.v3.dev1.record.FundingContributor)9 ArrayList (java.util.ArrayList)8 ExternalIDs (org.orcid.jaxb.model.v3.dev1.record.ExternalIDs)8