use of org.orcid.jaxb.model.record.summary_v2.Fundings in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV2Test method filterFundingsTest.
@Test
public void filterFundingsTest() {
Fundings f = getFundings(Visibility.PUBLIC, Visibility.PUBLIC, Visibility.PUBLIC);
assertEquals(3, f.getFundingGroup().size());
publicAPISecurityManagerV2.filter(f);
assertEquals(3, f.getFundingGroup().size());
assertGroupContainsOnlyPublicElements(f);
f = getFundings(Visibility.PUBLIC, Visibility.PUBLIC, Visibility.LIMITED);
assertEquals(3, f.getFundingGroup().size());
publicAPISecurityManagerV2.filter(f);
assertEquals(2, f.getFundingGroup().size());
assertGroupContainsOnlyPublicElements(f);
f = getFundings(Visibility.PUBLIC, Visibility.LIMITED, Visibility.PRIVATE);
assertEquals(3, f.getFundingGroup().size());
publicAPISecurityManagerV2.filter(f);
assertEquals(1, f.getFundingGroup().size());
assertGroupContainsOnlyPublicElements(f);
f = getFundings(Visibility.PRIVATE, Visibility.LIMITED, Visibility.PRIVATE);
assertEquals(3, f.getFundingGroup().size());
publicAPISecurityManagerV2.filter(f);
assertTrue(f.getFundingGroup().isEmpty());
}
use of org.orcid.jaxb.model.record.summary_v2.Fundings in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV2Test method getFundings.
private Fundings getFundings(Visibility... vs) {
Fundings fundings = new Fundings();
for (Visibility v : vs) {
FundingGroup g = new FundingGroup();
FundingSummary s = new FundingSummary();
s.setVisibility(v);
g.getFundingSummary().add(s);
fundings.getFundingGroup().add(g);
}
return fundings;
}
use of org.orcid.jaxb.model.record.summary_v2.Fundings in project ORCID-Source by ORCID.
the class ConvertVrc1ToVrc2Test method upgradeFundingsToVrc2Test.
@Test
public void upgradeFundingsToVrc2Test() throws JAXBException {
JAXBContext jaxbContext1 = JAXBContext.newInstance(Fundings.class);
JAXBContext jaxbContext2 = JAXBContext.newInstance(org.orcid.jaxb.model.record.summary_rc2.Fundings.class);
Unmarshaller jaxbUnmarshaller = jaxbContext1.createUnmarshaller();
InputStream rc1Stream = ConvertVrc1ToVrc2Test.class.getClassLoader().getResourceAsStream("test-fundings-2.0_rc1.xml");
InputStream rc2Stream = ConvertVrc1ToVrc2Test.class.getClassLoader().getResourceAsStream("test-fundings-2.0_rc2.xml");
Fundings rc1Fundings = (Fundings) jaxbUnmarshaller.unmarshal(rc1Stream);
jaxbUnmarshaller = jaxbContext2.createUnmarshaller();
org.orcid.jaxb.model.record.summary_rc2.Fundings rc2Fundings1 = (org.orcid.jaxb.model.record.summary_rc2.Fundings) jaxbUnmarshaller.unmarshal(rc2Stream);
V2Convertible result = versionConverterV2_0_rc1ToV2_0_rc2.upgrade(new V2Convertible(rc1Fundings, "v2_rc1"));
org.orcid.jaxb.model.record.summary_rc2.Fundings rc2Fundings2 = (org.orcid.jaxb.model.record.summary_rc2.Fundings) result.getObjectToConvert();
assertEquals(rc2Fundings1.getLastModifiedDate(), rc2Fundings2.getLastModifiedDate());
}
use of org.orcid.jaxb.model.record.summary_v2.Fundings in project ORCID-Source by ORCID.
the class ConvertVrc3ToVrc4Test method upgradeFundingsToVrc3Test.
@Test
public void upgradeFundingsToVrc3Test() throws JAXBException {
JAXBContext jaxbContext1 = JAXBContext.newInstance(Fundings.class);
JAXBContext jaxbContext2 = JAXBContext.newInstance(org.orcid.jaxb.model.record.summary_rc4.Fundings.class);
Unmarshaller jaxbUnmarshaller = jaxbContext1.createUnmarshaller();
InputStream rc3Stream = ConvertVrc3ToVrc4Test.class.getClassLoader().getResourceAsStream("test-fundings-2.0_rc3.xml");
InputStream rc4Stream = ConvertVrc3ToVrc4Test.class.getClassLoader().getResourceAsStream("test-fundings-2.0_rc4.xml");
Fundings rc4Fundings = (Fundings) jaxbUnmarshaller.unmarshal(rc3Stream);
jaxbUnmarshaller = jaxbContext2.createUnmarshaller();
org.orcid.jaxb.model.record.summary_rc4.Fundings rc4Fundings1 = (org.orcid.jaxb.model.record.summary_rc4.Fundings) jaxbUnmarshaller.unmarshal(rc4Stream);
V2Convertible result = versionConverterV2_0_rc3ToV2_0_rc4.upgrade(new V2Convertible(rc4Fundings, "v2_rc3"));
org.orcid.jaxb.model.record.summary_rc4.Fundings rc4Fundings2 = (org.orcid.jaxb.model.record.summary_rc4.Fundings) result.getObjectToConvert();
assertEquals(rc4Fundings1, rc4Fundings2);
}
use of org.orcid.jaxb.model.record.summary_v2.Fundings 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);
}
Aggregations