Search in sources :

Example 41 with ActivitiesSummary

use of org.orcid.jaxb.model.record.summary_rc4.ActivitiesSummary in project ORCID-Source by ORCID.

the class OrcidSecurityManager_ActivitiesSummaryTest method testActivitiesSummary_When_SomePrivate_NoSource_ReadLimitedToken.

@Test
public void testActivitiesSummary_When_SomePrivate_NoSource_ReadLimitedToken() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.ACTIVITIES_READ_LIMITED);
    EducationSummary e1 = createEducationSummary(Visibility.PUBLIC, CLIENT_2);
    EducationSummary e2 = createEducationSummary(Visibility.PRIVATE, CLIENT_2);
    EducationSummary e3 = createEducationSummary(Visibility.PRIVATE, CLIENT_2);
    EmploymentSummary em1 = createEmploymentSummary(Visibility.PUBLIC, CLIENT_2);
    EmploymentSummary em2 = createEmploymentSummary(Visibility.PRIVATE, CLIENT_2);
    EmploymentSummary em3 = createEmploymentSummary(Visibility.PRIVATE, CLIENT_2);
    FundingSummary f1 = createFundingSummary(Visibility.PUBLIC, CLIENT_2, EXTID_1);
    FundingSummary f2 = createFundingSummary(Visibility.PRIVATE, CLIENT_2, EXTID_2);
    FundingSummary f3 = createFundingSummary(Visibility.PRIVATE, CLIENT_2, EXTID_3);
    PeerReviewSummary p1 = createPeerReviewSummary(Visibility.PUBLIC, CLIENT_2, EXTID_1);
    PeerReviewSummary p2 = createPeerReviewSummary(Visibility.PRIVATE, CLIENT_2, EXTID_2);
    PeerReviewSummary p3 = createPeerReviewSummary(Visibility.PRIVATE, CLIENT_2, EXTID_3);
    WorkSummary w1 = createWorkSummary(Visibility.PUBLIC, CLIENT_2, EXTID_1);
    WorkSummary w2 = createWorkSummary(Visibility.PRIVATE, CLIENT_2, EXTID_2);
    WorkSummary w3 = createWorkSummary(Visibility.PRIVATE, CLIENT_2, EXTID_3);
    ActivitiesSummary as = new ActivitiesSummary();
    as.setEducations(createEducations(e1, e2, e3));
    as.setEmployments(createEmployments(em1, em2, em3));
    as.setFundings(createFundings(f1, f2, f3));
    as.setPeerReviews(createPeerReviews(p1, p2, p3));
    as.setWorks(createWorks(w1, w2, w3));
    orcidSecurityManager.checkAndFilter(ORCID_1, as);
    assertNotNull(as);
    // Check educations
    assertEquals(1, as.getEducations().getSummaries().size());
    assertTrue(as.getEducations().getSummaries().contains(e1));
    assertFalse(as.getEducations().getSummaries().contains(e2));
    assertFalse(as.getEducations().getSummaries().contains(e3));
    // Check employments
    assertEquals(1, as.getEmployments().getSummaries().size());
    assertTrue(as.getEmployments().getSummaries().contains(em1));
    assertFalse(as.getEmployments().getSummaries().contains(em2));
    assertFalse(as.getEmployments().getSummaries().contains(em3));
    // Check fundings
    assertEquals(1, as.getFundings().getFundingGroup().size());
    assertEquals(1, as.getFundings().getFundingGroup().get(0).getActivities().size());
    assertTrue(as.getFundings().getFundingGroup().get(0).getActivities().contains(f1));
    assertFalse(as.getFundings().getFundingGroup().get(0).getActivities().contains(f2));
    assertFalse(as.getFundings().getFundingGroup().get(0).getActivities().contains(f3));
    assertEquals(2, as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().size());
    assertTrue(as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_1)));
    assertFalse(as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_2)));
    assertFalse(as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_3)));
    assertTrue(as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_SHARED)));
    // Check peer reviews
    assertEquals(1, as.getPeerReviews().getPeerReviewGroup().size());
    assertEquals(1, as.getPeerReviews().getPeerReviewGroup().get(0).getActivities().size());
    assertTrue(as.getPeerReviews().getPeerReviewGroup().get(0).getActivities().contains(p1));
    assertFalse(as.getPeerReviews().getPeerReviewGroup().get(0).getActivities().contains(p2));
    assertFalse(as.getPeerReviews().getPeerReviewGroup().get(0).getActivities().contains(p3));
    assertEquals(1, as.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().size());
    assertTrue(as.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_SHARED, "peer-review")));
    // Check works
    assertEquals(1, as.getWorks().getWorkGroup().size());
    assertEquals(1, as.getWorks().getWorkGroup().get(0).getActivities().size());
    assertTrue(as.getWorks().getWorkGroup().get(0).getActivities().contains(w1));
    assertFalse(as.getWorks().getWorkGroup().get(0).getActivities().contains(w2));
    assertFalse(as.getWorks().getWorkGroup().get(0).getActivities().contains(w3));
    assertEquals(2, as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().size());
    assertTrue(as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_1)));
    assertFalse(as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_2)));
    assertFalse(as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_3)));
    assertTrue(as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_SHARED)));
}
Also used : WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) EducationSummary(org.orcid.jaxb.model.record.summary_v2.EducationSummary) PeerReviewSummary(org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary) FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary) EmploymentSummary(org.orcid.jaxb.model.record.summary_v2.EmploymentSummary) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) Test(org.junit.Test)

Example 42 with ActivitiesSummary

use of org.orcid.jaxb.model.record.summary_rc4.ActivitiesSummary in project ORCID-Source by ORCID.

the class ConvertVrc2ToVrc3Test method upgradeActivitiesToVrc3Test.

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

Example 43 with ActivitiesSummary

use of org.orcid.jaxb.model.record.summary_rc4.ActivitiesSummary in project ORCID-Source by ORCID.

the class ConvertVrc3ToVrc4Test method upgradeActivitiesToVrc3Test.

@Test
public void upgradeActivitiesToVrc3Test() throws JAXBException {
    JAXBContext jaxbContext1 = JAXBContext.newInstance(ActivitiesSummary.class);
    JAXBContext jaxbContext2 = JAXBContext.newInstance(org.orcid.jaxb.model.record.summary_rc4.ActivitiesSummary.class);
    Unmarshaller jaxbUnmarshaller1 = jaxbContext1.createUnmarshaller();
    Unmarshaller jaxbUnmarshaller2 = jaxbContext2.createUnmarshaller();
    InputStream rc3Stream = ConvertVrc3ToVrc4Test.class.getClassLoader().getResourceAsStream("test-activities-2.0_rc3.xml");
    InputStream rc4Stream = ConvertVrc3ToVrc4Test.class.getClassLoader().getResourceAsStream("test-activities-2.0_rc4.xml");
    ActivitiesSummary rc3Activities = (ActivitiesSummary) jaxbUnmarshaller1.unmarshal(rc3Stream);
    org.orcid.jaxb.model.record.summary_rc4.ActivitiesSummary rc4Activities1 = (org.orcid.jaxb.model.record.summary_rc4.ActivitiesSummary) jaxbUnmarshaller2.unmarshal(rc4Stream);
    V2Convertible result = versionConverterV2_0_rc3ToV2_0_rc4.upgrade(new V2Convertible(rc3Activities, "v2_rc3"));
    org.orcid.jaxb.model.record.summary_rc4.ActivitiesSummary rc4Activities2 = (org.orcid.jaxb.model.record.summary_rc4.ActivitiesSummary) result.getObjectToConvert();
    assertEquals(rc4Activities1, rc4Activities2);
}
Also used : V2Convertible(org.orcid.core.version.V2Convertible) InputStream(java.io.InputStream) JAXBContext(javax.xml.bind.JAXBContext) ActivitiesSummary(org.orcid.jaxb.model.record.summary_rc3.ActivitiesSummary) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 44 with ActivitiesSummary

use of org.orcid.jaxb.model.record.summary_rc4.ActivitiesSummary in project ORCID-Source by ORCID.

the class MemberV2PerformanceTest method cleanActivities.

private void cleanActivities() throws JSONException, InterruptedException, URISyntaxException {
    String token = getAccessToken();
    // Remove all activities
    ClientResponse activitiesResponse = memberV2ApiClient.viewActivities(this.getUser1OrcidId(), token);
    assertNotNull(activitiesResponse);
    ActivitiesSummary summary = activitiesResponse.getEntity(ActivitiesSummary.class);
    assertNotNull(summary);
    if (summary.getEducations() != null && !summary.getEducations().getSummaries().isEmpty()) {
        for (EducationSummary education : summary.getEducations().getSummaries()) {
            memberV2ApiClient.deleteEducationXml(this.getUser1OrcidId(), education.getPutCode(), token);
        }
    }
    if (summary.getEmployments() != null && !summary.getEmployments().getSummaries().isEmpty()) {
        for (EmploymentSummary employment : summary.getEmployments().getSummaries()) {
            memberV2ApiClient.deleteEmploymentXml(this.getUser1OrcidId(), employment.getPutCode(), token);
        }
    }
    if (summary.getFundings() != null && !summary.getFundings().getFundingGroup().isEmpty()) {
        for (FundingGroup group : summary.getFundings().getFundingGroup()) {
            for (FundingSummary funding : group.getFundingSummary()) {
                memberV2ApiClient.deleteFundingXml(this.getUser1OrcidId(), funding.getPutCode(), token);
            }
        }
    }
    if (summary.getWorks() != null && !summary.getWorks().getWorkGroup().isEmpty()) {
        for (WorkGroup group : summary.getWorks().getWorkGroup()) {
            for (WorkSummary work : group.getWorkSummary()) {
                memberV2ApiClient.deleteWorkXml(this.getUser1OrcidId(), work.getPutCode(), token);
            }
        }
    }
    if (summary.getPeerReviews() != null && !summary.getPeerReviews().getPeerReviewGroup().isEmpty()) {
        for (PeerReviewGroup group : summary.getPeerReviews().getPeerReviewGroup()) {
            for (PeerReviewSummary peerReview : group.getPeerReviewSummary()) {
                memberV2ApiClient.deletePeerReviewXml(this.getUser1OrcidId(), peerReview.getPutCode(), token);
            }
        }
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) WorkGroup(org.orcid.jaxb.model.record.summary_v2.WorkGroup) PeerReviewGroup(org.orcid.jaxb.model.record.summary_v2.PeerReviewGroup) WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) EducationSummary(org.orcid.jaxb.model.record.summary_v2.EducationSummary) PeerReviewSummary(org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary) FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary) EmploymentSummary(org.orcid.jaxb.model.record.summary_v2.EmploymentSummary) FundingGroup(org.orcid.jaxb.model.record.summary_v2.FundingGroup) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)

Example 45 with ActivitiesSummary

use of org.orcid.jaxb.model.record.summary_rc4.ActivitiesSummary in project ORCID-Source by ORCID.

the class ValidateV2RC3Identifiers method testActivities.

@Test
public void testActivities() {
    ActivitiesSummary as = unmarshallFromPath("/record_2.0_rc3/samples/activities-2.0_rc3.xml", ActivitiesSummary.class);
    ExternalIDs fundingIDs = as.getFundings().getFundingGroup().get(0).getFundingSummary().get(0).getExternalIdentifiers();
    ExternalIDs fundingIDs2 = as.getFundings().getFundingGroup().get(0).getIdentifiers();
    assertEquals("grant_number", fundingIDs.getExternalIdentifier().get(0).getType());
    assertEquals("external-id-value", fundingIDs.getExternalIdentifier().get(0).getValue());
    assertEquals(new Url("http://tempuri.org"), fundingIDs.getExternalIdentifier().get(0).getUrl());
    assertEquals(Relationship.SELF, fundingIDs.getExternalIdentifier().get(0).getRelationship());
    assertEquals(fundingIDs.getExternalIdentifier().get(0).getType(), fundingIDs2.getExternalIdentifier().get(0).getType());
    assertEquals(fundingIDs.getExternalIdentifier().get(0).getValue(), fundingIDs2.getExternalIdentifier().get(0).getValue());
    ExternalIDs peerIDs = as.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getExternalIdentifiers();
    ExternalIDs peerIDs2 = as.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers();
    assertEquals("something", peerIDs.getExternalIdentifier().get(0).getType());
    assertEquals("external-id-value", peerIDs.getExternalIdentifier().get(0).getValue());
    assertEquals(new Url("http://orcid.org"), peerIDs.getExternalIdentifier().get(0).getUrl());
    assertEquals(Relationship.SELF, peerIDs.getExternalIdentifier().get(0).getRelationship());
    assertEquals(peerIDs.getExternalIdentifier().get(0).getType(), peerIDs2.getExternalIdentifier().get(0).getType());
    assertEquals(peerIDs.getExternalIdentifier().get(0).getValue(), peerIDs2.getExternalIdentifier().get(0).getValue());
    ExternalIDs workIDs = as.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getExternalIdentifiers();
    ExternalIDs workIDs2 = as.getWorks().getWorkGroup().get(0).getIdentifiers();
    assertEquals("agr", workIDs.getExternalIdentifier().get(0).getType());
    assertEquals("external-id-value", workIDs.getExternalIdentifier().get(0).getValue());
    assertEquals(new Url("http://orcid.org"), workIDs.getExternalIdentifier().get(0).getUrl());
    assertEquals(Relationship.SELF, workIDs.getExternalIdentifier().get(0).getRelationship());
    assertEquals(workIDs.getExternalIdentifier().get(0).getType(), workIDs2.getExternalIdentifier().get(0).getType());
    assertEquals(workIDs.getExternalIdentifier().get(0).getValue(), workIDs2.getExternalIdentifier().get(0).getValue());
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_rc3.ExternalIDs) Url(org.orcid.jaxb.model.common_rc3.Url) ActivitiesSummary(org.orcid.jaxb.model.record.summary_rc3.ActivitiesSummary) MarshallingTest(org.orcid.jaxb.model.notification.custom.MarshallingTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)107 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)90 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)47 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)40 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)40 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)39 PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)37 Record (org.orcid.jaxb.model.record_v2.Record)25 DBUnitTest (org.orcid.test.DBUnitTest)23 Person (org.orcid.jaxb.model.record_v2.Person)20 ClientResponse (com.sun.jersey.api.client.ClientResponse)18 Response (javax.ws.rs.core.Response)18 Address (org.orcid.jaxb.model.record_v2.Address)16 Email (org.orcid.jaxb.model.record_v2.Email)16 Keyword (org.orcid.jaxb.model.record_v2.Keyword)16 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)16 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)16 WorkGroup (org.orcid.jaxb.model.record.summary_v2.WorkGroup)14 Name (org.orcid.jaxb.model.record_v2.Name)14 OtherName (org.orcid.jaxb.model.record_v2.OtherName)14