use of org.orcid.jaxb.model.record.summary_v2.Fundings in project ORCID-Source by ORCID.
the class ProfileFundingManagerTest method nonGroupableIdsGenerateEmptyIdsListTest.
@Test
public void nonGroupableIdsGenerateEmptyIdsListTest() {
FundingSummary s1 = getFundingSummary("Element 1", "ext-id-1", Visibility.PUBLIC);
FundingSummary s2 = getFundingSummary("Element 2", "ext-id-2", Visibility.LIMITED);
FundingSummary s3 = getFundingSummary("Element 3", "ext-id-3", Visibility.PRIVATE);
// s1 will be a part of identifier, so, it will go in its own group
s1.getExternalIdentifiers().getExternalIdentifier().get(0).setRelationship(Relationship.PART_OF);
List<FundingSummary> fundingList = Arrays.asList(s1, s2, s3);
/**
* They should be grouped as
*
* Group 1: Element 1
* Group 2: Element 2
* Group 3: Element 3
* */
Fundings fundings = profileFundingManager.groupFundings(fundingList, false);
assertNotNull(fundings);
assertEquals(3, fundings.getFundingGroup().size());
boolean foundEmptyGroup = false;
boolean found2 = false;
boolean found3 = false;
for (FundingGroup group : fundings.getFundingGroup()) {
assertEquals(1, group.getFundingSummary().size());
assertNotNull(group.getIdentifiers().getExternalIdentifier());
if (group.getIdentifiers().getExternalIdentifier().isEmpty()) {
assertEquals("Element 1", group.getFundingSummary().get(0).getTitle().getTitle().getContent());
assertEquals("ext-id-1", group.getFundingSummary().get(0).getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
foundEmptyGroup = true;
} else {
assertEquals(1, group.getIdentifiers().getExternalIdentifier().size());
assertThat(group.getIdentifiers().getExternalIdentifier().get(0).getValue(), anyOf(is("ext-id-2"), is("ext-id-3")));
if (group.getIdentifiers().getExternalIdentifier().get(0).getValue().equals("ext-id-2")) {
assertEquals("Element 2", group.getFundingSummary().get(0).getTitle().getTitle().getContent());
assertEquals("ext-id-2", group.getFundingSummary().get(0).getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
found2 = true;
} else if (group.getIdentifiers().getExternalIdentifier().get(0).getValue().equals("ext-id-3")) {
assertEquals("Element 3", group.getFundingSummary().get(0).getTitle().getTitle().getContent());
assertEquals("ext-id-3", group.getFundingSummary().get(0).getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
found3 = true;
} else {
fail("Invalid ext id found " + group.getIdentifiers().getExternalIdentifier().get(0).getValue());
}
}
}
assertTrue(foundEmptyGroup);
assertTrue(found2);
assertTrue(found3);
}
use of org.orcid.jaxb.model.record.summary_v2.Fundings in project ORCID-Source by ORCID.
the class ProfileFundingManagerTest method testGroupFundings.
@Test
public void testGroupFundings() {
/**
* They should be grouped as
*
* Group 1: Funding 1 + Funding 4
* Group 2: Funding 2 + Funding 5
* Group 3: Funding 3
* Group 4: Funding 6
* */
FundingSummary s1 = getFundingSummary("Funding 1", "ext-id-1", Visibility.PUBLIC);
FundingSummary s2 = getFundingSummary("Funding 2", "ext-id-2", Visibility.LIMITED);
FundingSummary s3 = getFundingSummary("Funding 3", "ext-id-3", Visibility.PRIVATE);
FundingSummary s4 = getFundingSummary("Funding 4", "ext-id-1", Visibility.PRIVATE);
FundingSummary s5 = getFundingSummary("Funding 5", "ext-id-2", Visibility.PUBLIC);
FundingSummary s6 = getFundingSummary("Funding 6", "ext-id-4", Visibility.PRIVATE);
List<FundingSummary> fundingList1 = Arrays.asList(s1, s2, s3, s4, s5, s6);
Fundings fundings1 = profileFundingManager.groupFundings(fundingList1, false);
assertNotNull(fundings1);
assertEquals(4, fundings1.getFundingGroup().size());
//Group 1 have all with ext-id-1
assertEquals(2, fundings1.getFundingGroup().get(0).getFundingSummary().size());
assertEquals(1, fundings1.getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().size());
assertEquals("ext-id-1", fundings1.getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getValue());
//Group 2 have all with ext-id-2
assertEquals(2, fundings1.getFundingGroup().get(1).getFundingSummary().size());
assertEquals(1, fundings1.getFundingGroup().get(1).getIdentifiers().getExternalIdentifier().size());
assertEquals("ext-id-2", fundings1.getFundingGroup().get(1).getIdentifiers().getExternalIdentifier().get(0).getValue());
//Group 3 have ext-id-3
assertEquals(1, fundings1.getFundingGroup().get(2).getFundingSummary().size());
assertEquals(1, fundings1.getFundingGroup().get(2).getIdentifiers().getExternalIdentifier().size());
assertEquals("ext-id-3", fundings1.getFundingGroup().get(2).getIdentifiers().getExternalIdentifier().get(0).getValue());
//Group 4 have ext-id-4
assertEquals(1, fundings1.getFundingGroup().get(3).getFundingSummary().size());
assertEquals(1, fundings1.getFundingGroup().get(3).getIdentifiers().getExternalIdentifier().size());
assertEquals("ext-id-4", fundings1.getFundingGroup().get(3).getIdentifiers().getExternalIdentifier().get(0).getValue());
FundingSummary s7 = getFundingSummary("Funding 7", "ext-id-4", Visibility.PRIVATE);
//Add ext-id-3 to work 7, so, it join group 3 and group 4 in a single group
ExternalID extId = new ExternalID();
extId.setRelationship(Relationship.SELF);
extId.setType("doi");
extId.setUrl(new Url("http://orcid.org"));
extId.setValue("ext-id-3");
s7.getExternalIdentifiers().getExternalIdentifier().add(extId);
/**
* Now, they should be grouped as
*
* Group 1: Funding 1 + Funding 4
* Group 2: Funding 2 + Funding 5
* Group 3: Funding 3 + Funding 6 + Funding 7
* */
List<FundingSummary> fundingsList2 = Arrays.asList(s1, s2, s3, s4, s5, s6, s7);
Fundings fundings2 = profileFundingManager.groupFundings(fundingsList2, false);
assertNotNull(fundings2);
assertEquals(3, fundings2.getFundingGroup().size());
//Group 1 have all with ext-id-1
assertEquals(2, fundings2.getFundingGroup().get(0).getFundingSummary().size());
assertEquals(1, fundings2.getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().size());
assertEquals("ext-id-1", fundings2.getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getValue());
//Group 2 have all with ext-id-2
assertEquals(2, fundings2.getFundingGroup().get(1).getFundingSummary().size());
assertEquals(1, fundings2.getFundingGroup().get(1).getIdentifiers().getExternalIdentifier().size());
assertEquals("ext-id-2", fundings2.getFundingGroup().get(1).getIdentifiers().getExternalIdentifier().get(0).getValue());
//Group 3 have all with ext-id-3 and ext-id-4
assertEquals(3, fundings2.getFundingGroup().get(2).getFundingSummary().size());
assertEquals(2, fundings2.getFundingGroup().get(2).getIdentifiers().getExternalIdentifier().size());
assertThat(fundings2.getFundingGroup().get(2).getIdentifiers().getExternalIdentifier().get(0).getValue(), anyOf(is("ext-id-3"), is("ext-id-4")));
assertThat(fundings2.getFundingGroup().get(2).getIdentifiers().getExternalIdentifier().get(1).getValue(), anyOf(is("ext-id-3"), is("ext-id-4")));
}
use of org.orcid.jaxb.model.record.summary_v2.Fundings in project ORCID-Source by ORCID.
the class ProfileFundingManagerTest method testGroupFundings_groupOnlyPublicFundings2.
@Test
public void testGroupFundings_groupOnlyPublicFundings2() {
FundingSummary s1 = getFundingSummary("Public 1", "ext-id-1", Visibility.PUBLIC);
FundingSummary s2 = getFundingSummary("Limited 1", "ext-id-1", Visibility.LIMITED);
FundingSummary s3 = getFundingSummary("Private 1", "ext-id-1", Visibility.PRIVATE);
FundingSummary s4 = getFundingSummary("Public 2", "ext-id-1", Visibility.PUBLIC);
FundingSummary s5 = getFundingSummary("Limited 2", "ext-id-1", Visibility.LIMITED);
FundingSummary s6 = getFundingSummary("Private 2", "ext-id-1", Visibility.PRIVATE);
FundingSummary s7 = getFundingSummary("Public 3", "ext-id-2", Visibility.PUBLIC);
FundingSummary s8 = getFundingSummary("Limited 3", "ext-id-2", Visibility.LIMITED);
FundingSummary s9 = getFundingSummary("Private 3", "ext-id-2", Visibility.PRIVATE);
List<FundingSummary> fundingList = Arrays.asList(s1, s2, s3, s4, s5, s6, s7, s8, s9);
/**
* They should be grouped as
*
* Group 1: Public 1 + Public 2
* Group 2: Public 3
* */
Fundings fundings = profileFundingManager.groupFundings(fundingList, true);
assertNotNull(fundings);
assertEquals(2, fundings.getFundingGroup().size());
assertEquals(1, fundings.getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().size());
assertEquals("ext-id-1", fundings.getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getValue());
assertEquals(2, fundings.getFundingGroup().get(0).getFundingSummary().size());
assertThat(fundings.getFundingGroup().get(0).getFundingSummary().get(0).getTitle().getTitle().getContent(), anyOf(is("Public 1"), is("Public 2")));
assertThat(fundings.getFundingGroup().get(0).getFundingSummary().get(1).getTitle().getTitle().getContent(), anyOf(is("Public 1"), is("Public 2")));
assertEquals(1, fundings.getFundingGroup().get(1).getIdentifiers().getExternalIdentifier().size());
assertEquals("ext-id-2", fundings.getFundingGroup().get(1).getIdentifiers().getExternalIdentifier().get(0).getValue());
assertEquals(1, fundings.getFundingGroup().get(1).getFundingSummary().size());
assertEquals("Public 3", fundings.getFundingGroup().get(1).getFundingSummary().get(0).getTitle().getTitle().getContent());
}
use of org.orcid.jaxb.model.record.summary_v2.Fundings in project ORCID-Source by ORCID.
the class ActivitiesGroupGenerator_GroupingFundingsTest method groupFundings_2GroupsOf2Fundings_Test.
/**
* Test grouping (funding-1 and funding-2) and (funding-5 and funding-6)
* */
@Test
public void groupFundings_2GroupsOf2Fundings_Test() {
ActivitiesGroupGenerator generator = new ActivitiesGroupGenerator();
Map<String, FundingSummary> fundings = generateFundings();
FundingSummary funding1 = fundings.get("funding-1");
FundingSummary funding2 = fundings.get("funding-2");
FundingSummary funding5 = fundings.get("funding-5");
FundingSummary funding6 = fundings.get("funding-6");
generator.group(funding1);
generator.group(funding2);
generator.group(funding5);
generator.group(funding6);
List<ActivitiesGroup> groups = generator.getGroups();
assertNotNull(groups);
assertEquals(2, groups.size());
//Check there are two activities in each group
assertEquals(2, groups.get(0).getActivities().size());
assertEquals(2, groups.get(1).getActivities().size());
//Check there are five external ids in each group
assertEquals(5, groups.get(0).getGroupKeys().size());
assertEquals(5, groups.get(1).getGroupKeys().size());
//Check each funding
checkActivityIsOnGroups(funding1, groups);
checkActivityIsOnGroups(funding2, groups);
checkActivityIsOnGroups(funding5, groups);
checkActivityIsOnGroups(funding6, groups);
//Check funding1 and funding2 are in the same group
checkActivitiesBelongsToTheSameGroup(groups, funding1, funding2);
//Check funding6 and funding7 are in the same group
checkActivitiesBelongsToTheSameGroup(groups, funding5, funding6);
//Check fundings are not mixed
checkActivitiesDontBelongsToTheSameGroup(groups, funding1, funding5);
checkActivitiesDontBelongsToTheSameGroup(groups, funding1, funding6);
checkActivitiesDontBelongsToTheSameGroup(groups, funding2, funding5);
checkActivitiesDontBelongsToTheSameGroup(groups, funding2, funding6);
}
use of org.orcid.jaxb.model.record.summary_v2.Fundings 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);
}
Aggregations