Search in sources :

Example 51 with Fundings

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());
}
Also used : Fundings(org.orcid.jaxb.model.record.summary_v2.Fundings) Test(org.junit.Test)

Example 52 with Fundings

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;
}
Also used : Fundings(org.orcid.jaxb.model.record.summary_v2.Fundings) FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary) Visibility(org.orcid.jaxb.model.common_v2.Visibility) FundingGroup(org.orcid.jaxb.model.record.summary_v2.FundingGroup)

Example 53 with 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());
}
Also used : V2Convertible(org.orcid.core.version.V2Convertible) Fundings(org.orcid.jaxb.model.record.summary_rc1.Fundings) InputStream(java.io.InputStream) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 54 with Fundings

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);
}
Also used : V2Convertible(org.orcid.core.version.V2Convertible) Fundings(org.orcid.jaxb.model.record.summary_rc3.Fundings) InputStream(java.io.InputStream) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 55 with Fundings

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);
}
Also used : FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)60 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)49 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)33 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)33 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)33 PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)30 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)28 Fundings (org.orcid.jaxb.model.record.summary_v2.Fundings)22 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)18 Address (org.orcid.jaxb.model.record_v2.Address)17 Email (org.orcid.jaxb.model.record_v2.Email)17 Keyword (org.orcid.jaxb.model.record_v2.Keyword)17 Name (org.orcid.jaxb.model.record_v2.Name)17 OtherName (org.orcid.jaxb.model.record_v2.OtherName)17 Record (org.orcid.jaxb.model.record_v2.Record)17 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)17 Addresses (org.orcid.jaxb.model.record_v2.Addresses)15 Biography (org.orcid.jaxb.model.record_v2.Biography)15 Emails (org.orcid.jaxb.model.record_v2.Emails)15 Keywords (org.orcid.jaxb.model.record_v2.Keywords)15