Search in sources :

Example 56 with Group

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

the class ActivitiesGroupGeneratorBaseTest method checkActivitiesBelongsToTheSameGroup.

/**
 * Check that the given activitys belongs to the same group in a list of given groups
 */
public void checkActivitiesBelongsToTheSameGroup(List<ActivitiesGroup> groups, GroupableActivity... activities) {
    GroupableActivity first = activities[0];
    assertNotNull(first);
    ActivitiesGroup theGroup = getGroupThatContainsActivity(groups, first);
    assertNotNull(theGroup);
    for (GroupableActivity activity : activities) {
        assertTrue(theGroup.belongsToGroup(activity));
    }
}
Also used : GroupableActivity(org.orcid.jaxb.model.v3.dev1.record.GroupableActivity)

Example 57 with Group

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

the class ActivitiesGroupGeneratorBaseTest method checkActivitiesDontBelongsToTheSameGroup.

/**
 * Check that the given activities belongs to the same group in a list of given groups
 */
public void checkActivitiesDontBelongsToTheSameGroup(List<ActivitiesGroup> groups, GroupableActivity... activities) {
    for (int i = 0; i < activities.length; i++) {
        GroupableActivity a1 = activities[i];
        ActivitiesGroup theGroup = getGroupThatContainsActivity(groups, a1);
        for (int j = i + 1; j < activities.length; j++) {
            assertFalse("activity[" + i + "] and activity[" + j + "] belongs to the same group", theGroup.belongsToGroup(activities[j]));
        }
    }
}
Also used : GroupableActivity(org.orcid.jaxb.model.v3.dev1.record.GroupableActivity)

Example 58 with Group

use of org.orcid.jaxb.model.v3.dev1.record.Group 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 59 with Group

use of org.orcid.jaxb.model.v3.dev1.record.Group 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 60 with Group

use of org.orcid.jaxb.model.v3.dev1.record.Group 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)47 WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)26 WorkGroup (org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup)18 FundingSummary (org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary)17 BaseTest (org.orcid.core.BaseTest)16 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)15 PeerReviewSummary (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary)14 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)13 PeerReviewGroup (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewGroup)13 Works (org.orcid.jaxb.model.v3.dev1.record.summary.Works)13 FundingGroup (org.orcid.jaxb.model.v3.dev1.record.summary.FundingGroup)12 DBUnitTest (org.orcid.test.DBUnitTest)11 ArrayList (java.util.ArrayList)10 Response (javax.ws.rs.core.Response)10 Url (org.orcid.jaxb.model.v3.dev1.common.Url)8 GroupIdRecord (org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecord)8 GroupableActivity (org.orcid.jaxb.model.v3.dev1.record.GroupableActivity)8 PeerReview (org.orcid.jaxb.model.v3.dev1.record.PeerReview)8 ClientResponse (com.sun.jersey.api.client.ClientResponse)7 TransientNonEmptyString (org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString)7