Search in sources :

Example 51 with Educations

use of org.orcid.jaxb.model.record.summary_v2.Educations in project ORCID-Source by ORCID.

the class PublicAPISecurityManagerV2Test method checkIsPublicRecordTest.

@Test
public void checkIsPublicRecordTest() {
    Record r = getRecordElement();
    publicAPISecurityManagerV2.filter(r);
    // Verify activities - nothing filtered
    ActivitiesSummary as = r.getActivitiesSummary();
    assertEquals(3, as.getEducations().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getEducations());
    assertEquals(3, as.getEmployments().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getEmployments());
    assertEquals(3, as.getFundings().getFundingGroup().size());
    assertGroupContainsOnlyPublicElements(as.getFundings());
    assertEquals(3, as.getPeerReviews().getPeerReviewGroup().size());
    assertGroupContainsOnlyPublicElements(as.getPeerReviews());
    assertEquals(3, as.getWorks().getWorkGroup().size());
    assertGroupContainsOnlyPublicElements(as.getWorks());
    // Verify bio sections - nothing filtered
    Person p = r.getPerson();
    assertEquals(3, p.getAddresses().getAddress().size());
    assertAllArePublic(p.getAddresses().getAddress());
    assertEquals(3, p.getEmails().getEmails().size());
    assertAllArePublic(p.getEmails().getEmails());
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    assertAllArePublic(p.getExternalIdentifiers().getExternalIdentifiers());
    assertEquals(3, p.getKeywords().getKeywords().size());
    assertAllArePublic(p.getKeywords().getKeywords());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    assertAllArePublic(p.getOtherNames().getOtherNames());
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    assertAllArePublic(p.getResearcherUrls().getResearcherUrls());
    assertNotNull(p.getBiography());
    assertNotNull(p.getName());
    // Filter biography, name, educations and funding
    r = getRecordElement();
    r.getPerson().getBiography().setVisibility(Visibility.LIMITED);
    r.getPerson().getName().setVisibility(Visibility.LIMITED);
    setVisibility(r.getActivitiesSummary().getEducations().getSummaries(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    setVisibility(r.getActivitiesSummary().getFundings(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV2.filter(r);
    // Verify activities - educations and funding filtered
    as = r.getActivitiesSummary();
    assertNotNull(as.getEducations());
    assertTrue(as.getEducations().getSummaries().isEmpty());
    assertEquals(3, as.getEmployments().getSummaries().size());
    assertTrue(as.getFundings().getFundingGroup().isEmpty());
    assertEquals(3, as.getPeerReviews().getPeerReviewGroup().size());
    assertEquals(3, as.getWorks().getWorkGroup().size());
    // Verify bio sections - bio and name filtered
    p = r.getPerson();
    assertEquals(3, p.getAddresses().getAddress().size());
    assertEquals(3, p.getEmails().getEmails().size());
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    assertEquals(3, p.getKeywords().getKeywords().size());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    assertNull(p.getBiography());
    assertNull(p.getName());
    // Filter emails, external identifiers, peer reviews and works
    r = getRecordElement();
    setVisibility(r.getPerson().getEmails().getEmails(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    setVisibility(r.getPerson().getExternalIdentifiers().getExternalIdentifiers(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    setVisibility(r.getActivitiesSummary().getPeerReviews(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    setVisibility(r.getActivitiesSummary().getWorks(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV2.filter(r);
    // Verify activities - peer reviews and works filtered
    as = r.getActivitiesSummary();
    assertEquals(3, as.getEducations().getSummaries().size());
    assertEquals(3, as.getEmployments().getSummaries().size());
    assertEquals(3, as.getFundings().getFundingGroup().size());
    assertTrue(as.getPeerReviews().getPeerReviewGroup().isEmpty());
    assertTrue(as.getWorks().getWorkGroup().isEmpty());
    // Verify bio sections - emails, external identifiers filtered
    p = r.getPerson();
    assertEquals(3, p.getAddresses().getAddress().size());
    assertNotNull(p.getEmails());
    assertTrue(p.getEmails().getEmails().isEmpty());
    assertNotNull(p.getExternalIdentifiers());
    assertTrue(p.getExternalIdentifiers().getExternalIdentifiers().isEmpty());
    assertEquals(3, p.getKeywords().getKeywords().size());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    assertNotNull(p.getBiography());
    assertNotNull(p.getName());
    // Filter keywords and other names
    r = getRecordElement();
    setVisibility(r.getPerson().getOtherNames().getOtherNames(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    setVisibility(r.getPerson().getKeywords().getKeywords(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV2.filter(r);
    // Verify activities - nothing filtered
    as = r.getActivitiesSummary();
    assertEquals(3, as.getEducations().getSummaries().size());
    assertEquals(3, as.getEmployments().getSummaries().size());
    assertEquals(3, as.getFundings().getFundingGroup().size());
    assertEquals(3, as.getPeerReviews().getPeerReviewGroup().size());
    assertEquals(3, as.getWorks().getWorkGroup().size());
    // Verify bio sections - keywords and other names filtered
    p = r.getPerson();
    assertEquals(3, p.getAddresses().getAddress().size());
    assertEquals(3, p.getEmails().getEmails().size());
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    assertNotNull(p.getKeywords());
    assertTrue(p.getKeywords().getKeywords().isEmpty());
    assertNotNull(p.getOtherNames());
    assertTrue(p.getOtherNames().getOtherNames().isEmpty());
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    assertNotNull(p.getBiography());
    assertNotNull(p.getName());
}
Also used : Record(org.orcid.jaxb.model.record_v2.Record) Person(org.orcid.jaxb.model.record_v2.Person) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) Test(org.junit.Test)

Example 52 with Educations

use of org.orcid.jaxb.model.record.summary_v2.Educations in project ORCID-Source by ORCID.

the class PublicAPISecurityManagerV2Test method checkIsPublicActivitiesSummaryTest.

@Test
public void checkIsPublicActivitiesSummaryTest() {
    ActivitiesSummary as = getActivitiesSummaryElement();
    publicAPISecurityManagerV2.filter(as);
    // Assert it have all activities
    assertEquals(3, as.getEducations().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getEducations());
    assertEquals(3, as.getEmployments().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getEmployments());
    assertEquals(3, as.getFundings().getFundingGroup().size());
    assertGroupContainsOnlyPublicElements(as.getFundings());
    assertEquals(3, as.getPeerReviews().getPeerReviewGroup().size());
    assertGroupContainsOnlyPublicElements(as.getPeerReviews());
    assertEquals(3, as.getWorks().getWorkGroup().size());
    assertGroupContainsOnlyPublicElements(as.getWorks());
    // Assert it filters educations
    as = getActivitiesSummaryElement();
    setVisibility(as.getEducations().getSummaries(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV2.filter(as);
    assertNotNull(as.getEducations());
    assertTrue(as.getEducations().getSummaries().isEmpty());
    assertEquals(3, as.getEmployments().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getEmployments());
    assertEquals(3, as.getFundings().getFundingGroup().size());
    assertGroupContainsOnlyPublicElements(as.getFundings());
    assertEquals(3, as.getPeerReviews().getPeerReviewGroup().size());
    assertGroupContainsOnlyPublicElements(as.getPeerReviews());
    assertEquals(3, as.getWorks().getWorkGroup().size());
    assertGroupContainsOnlyPublicElements(as.getWorks());
    // Assert it filters employments
    as = getActivitiesSummaryElement();
    setVisibility(as.getEmployments().getSummaries(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV2.filter(as);
    assertEquals(3, as.getEducations().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getEducations());
    assertNotNull(as.getEmployments());
    assertTrue(as.getEmployments().getSummaries().isEmpty());
    assertEquals(3, as.getFundings().getFundingGroup().size());
    assertGroupContainsOnlyPublicElements(as.getFundings());
    assertEquals(3, as.getPeerReviews().getPeerReviewGroup().size());
    assertGroupContainsOnlyPublicElements(as.getPeerReviews());
    assertEquals(3, as.getWorks().getWorkGroup().size());
    assertGroupContainsOnlyPublicElements(as.getWorks());
    // Assert it filters funding
    as = getActivitiesSummaryElement();
    setVisibility(as.getFundings(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV2.filter(as);
    assertEquals(3, as.getEducations().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getEducations());
    assertEquals(3, as.getEmployments().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getEmployments());
    assertTrue(as.getFundings().getFundingGroup().isEmpty());
    assertEquals(3, as.getPeerReviews().getPeerReviewGroup().size());
    assertGroupContainsOnlyPublicElements(as.getPeerReviews());
    assertEquals(3, as.getWorks().getWorkGroup().size());
    assertGroupContainsOnlyPublicElements(as.getWorks());
    // Assert it filters peer reviews
    as = getActivitiesSummaryElement();
    setVisibility(as.getPeerReviews(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV2.filter(as);
    assertEquals(3, as.getEducations().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getEducations());
    assertEquals(3, as.getEmployments().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getEmployments());
    assertEquals(3, as.getFundings().getFundingGroup().size());
    assertGroupContainsOnlyPublicElements(as.getFundings());
    assertTrue(as.getPeerReviews().getPeerReviewGroup().isEmpty());
    assertEquals(3, as.getWorks().getWorkGroup().size());
    assertGroupContainsOnlyPublicElements(as.getWorks());
    // Assert it filters works
    as = getActivitiesSummaryElement();
    setVisibility(as.getWorks(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV2.filter(as);
    assertEquals(3, as.getEducations().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getEducations());
    assertEquals(3, as.getEmployments().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getEmployments());
    assertEquals(3, as.getFundings().getFundingGroup().size());
    assertGroupContainsOnlyPublicElements(as.getFundings());
    assertEquals(3, as.getPeerReviews().getPeerReviewGroup().size());
    assertGroupContainsOnlyPublicElements(as.getPeerReviews());
    assertTrue(as.getWorks().getWorkGroup().isEmpty());
}
Also used : ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) Test(org.junit.Test)

Example 53 with Educations

use of org.orcid.jaxb.model.record.summary_v2.Educations in project ORCID-Source by ORCID.

the class PublicV2ApiServiceDelegatorTest method testViewEducations.

@Test
public void testViewEducations() {
    Response response = serviceDelegator.viewEducations(ORCID);
    assertNotNull(response);
    Educations educations = (Educations) response.getEntity();
    assertNotNull(educations);
    assertEquals("/0000-0000-0000-0003/educations", educations.getPath());
    assertNotNull(educations.getLastModifiedDate());
    assertNotNull(educations.getLastModifiedDate().getValue());
    assertEquals(1, educations.getSummaries().size());
    EducationSummary education = educations.getSummaries().get(0);
    assertEquals(Long.valueOf(20), education.getPutCode());
    assertNotNull(education.getLastModifiedDate());
    assertNotNull(education.getLastModifiedDate().getValue());
    assertEquals("/0000-0000-0000-0003/education/20", education.getPath());
    assertEquals("PUBLIC Department", education.getDepartmentName());
    assertEquals(Visibility.PUBLIC.value(), education.getVisibility().value());
    assertEquals("APP-5555555555555555", education.getSource().retrieveSourcePath());
}
Also used : Response(javax.ws.rs.core.Response) EducationSummary(org.orcid.jaxb.model.record.summary_v2.EducationSummary) Educations(org.orcid.jaxb.model.record.summary_v2.Educations) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 54 with Educations

use of org.orcid.jaxb.model.record.summary_v2.Educations in project ORCID-Source by ORCID.

the class ConvertVrc1ToVrc2Test method upgradeEducationsToVrc2Test.

@Test
public void upgradeEducationsToVrc2Test() throws JAXBException {
    JAXBContext jaxbContext1 = JAXBContext.newInstance(Educations.class);
    JAXBContext jaxbContext2 = JAXBContext.newInstance(org.orcid.jaxb.model.record.summary_rc2.Educations.class);
    Unmarshaller jaxbUnmarshaller = jaxbContext1.createUnmarshaller();
    InputStream rc1Stream = ConvertVrc1ToVrc2Test.class.getClassLoader().getResourceAsStream("test-educations-2.0_rc1.xml");
    InputStream rc2Stream = ConvertVrc1ToVrc2Test.class.getClassLoader().getResourceAsStream("test-educations-2.0_rc2.xml");
    Educations rc1Educations = (Educations) jaxbUnmarshaller.unmarshal(rc1Stream);
    jaxbUnmarshaller = jaxbContext2.createUnmarshaller();
    org.orcid.jaxb.model.record.summary_rc2.Educations rc2Educations1 = (org.orcid.jaxb.model.record.summary_rc2.Educations) jaxbUnmarshaller.unmarshal(rc2Stream);
    V2Convertible result = versionConverterV2_0_rc1ToV2_0_rc2.upgrade(new V2Convertible(rc1Educations, "v2_rc1"));
    org.orcid.jaxb.model.record.summary_rc2.Educations rc2Educations2 = (org.orcid.jaxb.model.record.summary_rc2.Educations) result.getObjectToConvert();
    assertEquals(rc2Educations1.getLastModifiedDate(), rc2Educations2.getLastModifiedDate());
}
Also used : V2Convertible(org.orcid.core.version.V2Convertible) InputStream(java.io.InputStream) JAXBContext(javax.xml.bind.JAXBContext) Educations(org.orcid.jaxb.model.record.summary_rc1.Educations) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 55 with Educations

use of org.orcid.jaxb.model.record.summary_v2.Educations in project ORCID-Source by ORCID.

the class ConvertVrc2ToVrc3Test method upgradeEducationsToVrc3Test.

@Test
public void upgradeEducationsToVrc3Test() throws JAXBException {
    JAXBContext jaxbContext1 = JAXBContext.newInstance(Educations.class);
    JAXBContext jaxbContext2 = JAXBContext.newInstance(org.orcid.jaxb.model.record.summary_rc3.Educations.class);
    Unmarshaller jaxbUnmarshaller = jaxbContext1.createUnmarshaller();
    InputStream rc2Stream = ConvertVrc2ToVrc3Test.class.getClassLoader().getResourceAsStream("test-educations-2.0_rc2.xml");
    InputStream rc3Stream = ConvertVrc2ToVrc3Test.class.getClassLoader().getResourceAsStream("test-educations-2.0_rc3.xml");
    Educations rc2Educations = (Educations) jaxbUnmarshaller.unmarshal(rc2Stream);
    jaxbUnmarshaller = jaxbContext2.createUnmarshaller();
    org.orcid.jaxb.model.record.summary_rc3.Educations rc3Educations1 = (org.orcid.jaxb.model.record.summary_rc3.Educations) jaxbUnmarshaller.unmarshal(rc3Stream);
    V2Convertible result = versionConverterV2_0_rc2ToV2_0_rc3.upgrade(new V2Convertible(rc2Educations, "v2_rc2"));
    org.orcid.jaxb.model.record.summary_rc3.Educations rc3Educations2 = (org.orcid.jaxb.model.record.summary_rc3.Educations) result.getObjectToConvert();
    assertEquals(rc3Educations1, rc3Educations2);
}
Also used : V2Convertible(org.orcid.core.version.V2Convertible) InputStream(java.io.InputStream) JAXBContext(javax.xml.bind.JAXBContext) Educations(org.orcid.jaxb.model.record.summary_rc2.Educations) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Aggregations

Test (org.junit.Test)63 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)44 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)40 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)39 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)39 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)39 PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)37 Educations (org.orcid.jaxb.model.record.summary_v2.Educations)18 Record (org.orcid.jaxb.model.record_v2.Record)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 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)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