Search in sources :

Example 6 with WorkGroup

use of org.orcid.jaxb.model.record.summary_rc3.WorkGroup in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_ActivitiesSummaryTest method testViewActitivies.

@Test
public void testViewActitivies() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response response = serviceDelegator.viewActivities(ORCID);
    boolean found1 = false, found2 = false, found3 = false, found4 = false;
    ActivitiesSummary as = (ActivitiesSummary) response.getEntity();
    assertNotNull(as);
    assertEquals("/0000-0000-0000-0003/activities", as.getPath());
    Utils.verifyLastModified(as.getLastModifiedDate());
    assertNotNull(as.getEducations());
    assertEquals(4, as.getEducations().getSummaries().size());
    for (EducationSummary element : as.getEducations().getSummaries()) {
        if (element.getPutCode().equals(Long.valueOf(20))) {
            found1 = true;
        } else if (element.getPutCode().equals(Long.valueOf(21))) {
            found2 = true;
        } else if (element.getPutCode().equals(Long.valueOf(22))) {
            found3 = true;
        } else if (element.getPutCode().equals(Long.valueOf(25))) {
            found4 = true;
        } else {
            fail("Invalid put code " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
    found1 = found2 = found3 = found4 = false;
    assertNotNull(as.getEmployments());
    assertEquals(4, as.getEmployments().getSummaries().size());
    for (EmploymentSummary element : as.getEmployments().getSummaries()) {
        if (element.getPutCode().equals(Long.valueOf(17))) {
            found1 = true;
        } else if (element.getPutCode().equals(Long.valueOf(18))) {
            found2 = true;
        } else if (element.getPutCode().equals(Long.valueOf(19))) {
            found3 = true;
        } else if (element.getPutCode().equals(Long.valueOf(23))) {
            found4 = true;
        } else {
            fail("Invalid put code " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
    found1 = found2 = found3 = found4 = false;
    assertNotNull(as.getFundings());
    assertEquals(4, as.getFundings().getFundingGroup().size());
    for (FundingGroup group : as.getFundings().getFundingGroup()) {
        assertEquals(1, group.getFundingSummary().size());
        FundingSummary element = group.getFundingSummary().get(0);
        if (element.getPutCode().equals(Long.valueOf(10))) {
            found1 = true;
        } else if (element.getPutCode().equals(Long.valueOf(11))) {
            found2 = true;
        } else if (element.getPutCode().equals(Long.valueOf(12))) {
            found3 = true;
        } else if (element.getPutCode().equals(Long.valueOf(13))) {
            found4 = true;
        } else {
            fail("Invalid put code " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
    found1 = found2 = found3 = found4 = false;
    assertNotNull(as.getPeerReviews());
    assertEquals(4, as.getPeerReviews().getPeerReviewGroup().size());
    for (PeerReviewGroup group : as.getPeerReviews().getPeerReviewGroup()) {
        assertEquals(1, group.getPeerReviewSummary().size());
        PeerReviewSummary element = group.getPeerReviewSummary().get(0);
        if (element.getPutCode().equals(Long.valueOf(9))) {
            found1 = true;
        } else if (element.getPutCode().equals(Long.valueOf(10))) {
            found2 = true;
        } else if (element.getPutCode().equals(Long.valueOf(11))) {
            found3 = true;
        } else if (element.getPutCode().equals(Long.valueOf(12))) {
            found4 = true;
        } else {
            fail("Invalid put code " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
    found1 = found2 = found3 = found4 = false;
    assertNotNull(as.getWorks());
    assertEquals(4, as.getWorks().getWorkGroup().size());
    for (WorkGroup group : as.getWorks().getWorkGroup()) {
        assertEquals(1, group.getWorkSummary().size());
        WorkSummary element = group.getWorkSummary().get(0);
        if (element.getPutCode().equals(Long.valueOf(11))) {
            found1 = true;
        } else if (element.getPutCode().equals(Long.valueOf(12))) {
            found2 = true;
        } else if (element.getPutCode().equals(Long.valueOf(13))) {
            found3 = true;
        } else if (element.getPutCode().equals(Long.valueOf(14))) {
            found4 = true;
        } else {
            fail("Invalid put code " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
}
Also used : Response(javax.ws.rs.core.Response) PeerReviewGroup(org.orcid.jaxb.model.record.summary_v2.PeerReviewGroup) WorkGroup(org.orcid.jaxb.model.record.summary_v2.WorkGroup) 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) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 7 with WorkGroup

use of org.orcid.jaxb.model.record.summary_rc3.WorkGroup in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_WorksTest method viewWorksTest.

@Test
public void viewWorksTest() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response r = serviceDelegator.viewWorks(ORCID);
    assertNotNull(r);
    Works works = (Works) r.getEntity();
    assertNotNull(works);
    assertEquals("/0000-0000-0000-0003/works", works.getPath());
    Utils.verifyLastModified(works.getLastModifiedDate());
    assertNotNull(works.getWorkGroup());
    assertNotNull(works.getPath());
    assertEquals(4, works.getWorkGroup().size());
    boolean found1 = false, found2 = false, found3 = false, found4 = false;
    for (WorkGroup workGroup : works.getWorkGroup()) {
        Utils.verifyLastModified(workGroup.getLastModifiedDate());
        assertNotNull(workGroup.getIdentifiers());
        assertNotNull(workGroup.getIdentifiers().getExternalIdentifier());
        assertEquals(1, workGroup.getIdentifiers().getExternalIdentifier().size());
        assertNotNull(workGroup.getWorkSummary());
        assertEquals(1, workGroup.getWorkSummary().size());
        WorkSummary summary = workGroup.getWorkSummary().get(0);
        Utils.verifyLastModified(summary.getLastModifiedDate());
        assertNotNull(summary.getTitle());
        assertNotNull(summary.getTitle().getTitle());
        switch(workGroup.getIdentifiers().getExternalIdentifier().get(0).getValue()) {
            case "1":
                assertEquals("PUBLIC", summary.getTitle().getTitle().getContent());
                assertEquals(Long.valueOf(11), summary.getPutCode());
                found1 = true;
                break;
            case "2":
                assertEquals("LIMITED", summary.getTitle().getTitle().getContent());
                assertEquals(Long.valueOf(12), summary.getPutCode());
                found2 = true;
                break;
            case "3":
                assertEquals("PRIVATE", summary.getTitle().getTitle().getContent());
                assertEquals(Long.valueOf(13), summary.getPutCode());
                found3 = true;
                break;
            case "4":
                assertEquals("SELF LIMITED", summary.getTitle().getTitle().getContent());
                assertEquals(Long.valueOf(14), summary.getPutCode());
                found4 = true;
                break;
            default:
                fail("Invalid external id found: " + workGroup.getIdentifiers().getExternalIdentifier().get(0).getValue());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
}
Also used : Response(javax.ws.rs.core.Response) WorkGroup(org.orcid.jaxb.model.record.summary_v2.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) Works(org.orcid.jaxb.model.record.summary_v2.Works) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 8 with WorkGroup

use of org.orcid.jaxb.model.record.summary_rc3.WorkGroup in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_WorksTest method testAddWork.

@Test
public void testAddWork() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4445", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewActivities("4444-4444-4444-4445");
    assertNotNull(response);
    ActivitiesSummary summary = (ActivitiesSummary) response.getEntity();
    assertNotNull(summary);
    Utils.verifyLastModified(summary.getLastModifiedDate());
    // Check works
    assertNotNull(summary.getWorks());
    assertNotNull(summary.getWorks().getWorkGroup());
    assertEquals(1, summary.getWorks().getWorkGroup().size());
    Utils.verifyLastModified(summary.getWorks().getLastModifiedDate());
    assertNotNull(summary.getWorks().getWorkGroup().get(0));
    Utils.verifyLastModified(summary.getWorks().getWorkGroup().get(0).getLastModifiedDate());
    assertNotNull(summary.getWorks().getWorkGroup().get(0).getWorkSummary());
    assertEquals(1, summary.getWorks().getWorkGroup().get(0).getWorkSummary().size());
    String title = "work # 1 " + System.currentTimeMillis();
    Work work = Utils.getWork(title);
    response = serviceDelegator.createWork("4444-4444-4444-4445", work);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    Long putCode = Utils.getPutCode(response);
    response = serviceDelegator.viewActivities("4444-4444-4444-4445");
    assertNotNull(response);
    summary = (ActivitiesSummary) response.getEntity();
    assertNotNull(summary);
    Utils.verifyLastModified(summary.getLastModifiedDate());
    // Check works
    assertNotNull(summary.getWorks());
    assertNotNull(summary.getWorks().getWorkGroup());
    assertEquals(2, summary.getWorks().getWorkGroup().size());
    boolean haveOld = false;
    boolean haveNew = false;
    for (WorkGroup group : summary.getWorks().getWorkGroup()) {
        Utils.verifyLastModified(group.getLastModifiedDate());
        assertNotNull(group.getWorkSummary());
        assertNotNull(group.getWorkSummary().get(0));
        WorkSummary workSummary = group.getWorkSummary().get(0);
        Utils.verifyLastModified(workSummary.getLastModifiedDate());
        assertNotNull(workSummary.getTitle());
        assertNotNull(workSummary.getTitle().getTitle());
        if ("A Book With Contributors JSON".equals(workSummary.getTitle().getTitle().getContent())) {
            haveOld = true;
        } else if (title.equals(workSummary.getTitle().getTitle().getContent())) {
            haveNew = true;
        }
    }
    assertTrue(haveOld);
    assertTrue(haveNew);
    // Delete them
    serviceDelegator.deleteWork("4444-4444-4444-4445", putCode);
}
Also used : Response(javax.ws.rs.core.Response) WorkGroup(org.orcid.jaxb.model.record.summary_v2.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) Work(org.orcid.jaxb.model.record_v2.Work) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 9 with WorkGroup

use of org.orcid.jaxb.model.record.summary_rc3.WorkGroup 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 10 with WorkGroup

use of org.orcid.jaxb.model.record.summary_rc3.WorkGroup in project ORCID-Source by ORCID.

the class PublicAPISecurityManagerV2Test method getWorks.

private Works getWorks(Visibility... vs) {
    Works works = new Works();
    for (Visibility v : vs) {
        WorkGroup g = new WorkGroup();
        WorkSummary s = new WorkSummary();
        s.setVisibility(v);
        g.getWorkSummary().add(s);
        works.getWorkGroup().add(g);
    }
    return works;
}
Also used : WorkGroup(org.orcid.jaxb.model.record.summary_v2.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) Visibility(org.orcid.jaxb.model.common_v2.Visibility) Works(org.orcid.jaxb.model.record.summary_v2.Works)

Aggregations

Test (org.junit.Test)35 WorkGroup (org.orcid.jaxb.model.record.summary_v2.WorkGroup)31 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)30 ClientResponse (com.sun.jersey.api.client.ClientResponse)26 Works (org.orcid.jaxb.model.record.summary_v2.Works)17 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)14 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)13 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)13 FundingGroup (org.orcid.jaxb.model.record.summary_v2.FundingGroup)13 PeerReviewGroup (org.orcid.jaxb.model.record.summary_v2.PeerReviewGroup)13 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)12 PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)12 ArrayList (java.util.ArrayList)9 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)8 Response (javax.ws.rs.core.Response)5 ActivitiesSummary (org.orcid.jaxb.model.record.summary_rc1.ActivitiesSummary)5 WorkGroup (org.orcid.jaxb.model.record.summary_rc1.WorkGroup)5 WorkSummary (org.orcid.jaxb.model.record.summary_rc1.WorkSummary)5 Educations (org.orcid.jaxb.model.record.summary_v2.Educations)5 Employments (org.orcid.jaxb.model.record.summary_v2.Employments)5