Search in sources :

Example 41 with ActivitiesSummary

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

the class MemberV2ApiServiceDelegator_ActivitiesSummaryTest method testViewActivitiesReadPublic.

@Test
public void testViewActivitiesReadPublic() {
    SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
    Response r = serviceDelegator.viewActivities(ORCID);
    ActivitiesSummary as = (ActivitiesSummary) r.getEntity();
    assertNotNull(as);
    assertEquals("/0000-0000-0000-0003/activities", as.getPath());
    Utils.assertIsPublicOrSource(as, "APP-5555555555555555");
}
Also used : Response(javax.ws.rs.core.Response) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 42 with ActivitiesSummary

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

the class MemberV2ApiServiceDelegator_EducationsTest method testAddEducation.

@Test
public void testAddEducation() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4442", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewActivities("4444-4444-4444-4442");
    assertNotNull(response);
    ActivitiesSummary summary = (ActivitiesSummary) response.getEntity();
    assertNotNull(summary);
    Utils.verifyLastModified(summary.getLastModifiedDate());
    assertNotNull(summary.getEducations());
    Utils.verifyLastModified(summary.getEducations().getLastModifiedDate());
    assertNotNull(summary.getEducations().getSummaries());
    assertNotNull(summary.getEducations().getSummaries().get(0));
    Utils.verifyLastModified(summary.getEducations().getSummaries().get(0).getLastModifiedDate());
    assertEquals(Long.valueOf(1), summary.getEducations().getSummaries().get(0).getPutCode());
    response = serviceDelegator.createEducation("4444-4444-4444-4442", Utils.getEducation());
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    Map<?, ?> map = response.getMetadata();
    assertNotNull(map);
    assertTrue(map.containsKey("Location"));
    List<?> resultWithPutCode = (List<?>) map.get("Location");
    Long putCode = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
    response = serviceDelegator.viewActivities("4444-4444-4444-4442");
    assertNotNull(response);
    summary = (ActivitiesSummary) response.getEntity();
    assertNotNull(summary);
    Utils.verifyLastModified(summary.getLastModifiedDate());
    assertNotNull(summary.getEducations());
    Utils.verifyLastModified(summary.getEducations().getLastModifiedDate());
    assertNotNull(summary.getEducations().getSummaries());
    boolean haveOld = false;
    boolean haveNew = false;
    for (EducationSummary educationSummary : summary.getEducations().getSummaries()) {
        assertNotNull(educationSummary.getPutCode());
        Utils.verifyLastModified(educationSummary.getLastModifiedDate());
        if (educationSummary.getPutCode() == 1L) {
            assertEquals("A Department", educationSummary.getDepartmentName());
            haveOld = true;
        } else {
            assertEquals(putCode, educationSummary.getPutCode());
            assertEquals("My department name", educationSummary.getDepartmentName());
            haveNew = true;
        }
    }
    assertTrue(haveOld);
    assertTrue(haveNew);
}
Also used : Response(javax.ws.rs.core.Response) EducationSummary(org.orcid.jaxb.model.record.summary_v2.EducationSummary) List(java.util.List) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 43 with ActivitiesSummary

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

the class MemberV2ApiServiceDelegator_EmploymentsTest method testAddEmployment.

@Test
public void testAddEmployment() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewActivities("4444-4444-4444-4447");
    assertNotNull(response);
    ActivitiesSummary summary = (ActivitiesSummary) response.getEntity();
    assertNotNull(summary);
    assertNotNull(summary.getEmployments());
    assertNotNull(summary.getEmployments().getSummaries());
    assertNotNull(summary.getEmployments().getSummaries().get(0));
    assertEquals(Long.valueOf(13), summary.getEmployments().getSummaries().get(0).getPutCode());
    response = serviceDelegator.createEmployment("4444-4444-4444-4447", Utils.getEmployment());
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    Map<?, ?> map = response.getMetadata();
    assertNotNull(map);
    assertTrue(map.containsKey("Location"));
    List<?> resultWithPutCode = (List<?>) map.get("Location");
    Long putCode = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
    response = serviceDelegator.viewActivities("4444-4444-4444-4447");
    assertNotNull(response);
    summary = (ActivitiesSummary) response.getEntity();
    assertNotNull(summary);
    Utils.verifyLastModified(summary.getLastModifiedDate());
    assertNotNull(summary.getEmployments());
    Utils.verifyLastModified(summary.getEmployments().getLastModifiedDate());
    assertNotNull(summary.getEmployments().getSummaries());
    boolean haveOld = false;
    boolean haveNew = false;
    for (EmploymentSummary eSummary : summary.getEmployments().getSummaries()) {
        assertNotNull(eSummary.getPutCode());
        Utils.verifyLastModified(eSummary.getLastModifiedDate());
        if (eSummary.getPutCode() == 13L) {
            assertEquals("Employment Dept # 1", eSummary.getDepartmentName());
            haveOld = true;
        } else {
            assertEquals(putCode, eSummary.getPutCode());
            assertEquals("My department name", eSummary.getDepartmentName());
            haveNew = true;
        }
    }
    assertTrue(haveOld);
    assertTrue(haveNew);
}
Also used : Response(javax.ws.rs.core.Response) EmploymentSummary(org.orcid.jaxb.model.record.summary_v2.EmploymentSummary) List(java.util.List) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 44 with ActivitiesSummary

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

the class MemberV2ApiServiceDelegator_ActivitiesSummaryTest method testViewActitivies_PeerReviewReadLimited_NoSource.

@Test
public void testViewActitivies_PeerReviewReadLimited_NoSource() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, "APP-5555555555555556", ScopePathType.PEER_REVIEW_READ_LIMITED);
    Response response = serviceDelegator.viewActivities(ORCID);
    ActivitiesSummary as = (ActivitiesSummary) response.getEntity();
    assertNotNull(as);
    assertNotNull(as.getPath());
    Utils.verifyLastModified(as.getLastModifiedDate());
    // Only public educations
    assertNotNull(as.getEducations());
    assertEquals(1, as.getEducations().getSummaries().size());
    assertEquals(Long.valueOf(20), as.getEducations().getSummaries().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC, as.getEducations().getSummaries().get(0).getVisibility());
    // Only public employments
    assertNotNull(as.getEmployments());
    assertEquals(1, as.getEmployments().getSummaries().size());
    assertEquals(Long.valueOf(17), as.getEmployments().getSummaries().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC, as.getEmployments().getSummaries().get(0).getVisibility());
    // Only public funding
    assertNotNull(as.getFundings());
    assertEquals(1, as.getFundings().getFundingGroup().size());
    assertEquals(1, as.getFundings().getFundingGroup().get(0).getFundingSummary().size());
    assertEquals(Long.valueOf(10), as.getFundings().getFundingGroup().get(0).getFundingSummary().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC, as.getFundings().getFundingGroup().get(0).getFundingSummary().get(0).getVisibility());
    // Limited peer reviews
    boolean found1 = false, found2 = false, found3 = false;
    assertNotNull(as.getPeerReviews());
    assertEquals(3, 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))) {
            assertEquals(Visibility.PUBLIC, element.getVisibility());
            found1 = true;
        } else if (element.getPutCode().equals(Long.valueOf(10))) {
            assertEquals(Visibility.LIMITED, element.getVisibility());
            found2 = true;
        } else if (element.getPutCode().equals(Long.valueOf(12))) {
            assertEquals(Visibility.LIMITED, element.getVisibility());
            found3 = true;
        } else {
            fail("Invalid put code " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    // Only public works
    assertNotNull(as.getWorks());
    assertEquals(1, as.getWorks().getWorkGroup().size());
    assertEquals(1, as.getWorks().getWorkGroup().get(0).getWorkSummary().size());
    assertEquals(Long.valueOf(11), as.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC, as.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getVisibility());
}
Also used : Response(javax.ws.rs.core.Response) PeerReviewGroup(org.orcid.jaxb.model.record.summary_v2.PeerReviewGroup) PeerReviewSummary(org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 45 with ActivitiesSummary

use of org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary 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)

Aggregations

Test (org.junit.Test)101 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)81 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)47 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)43 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)43 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)42 PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)40 DBUnitTest (org.orcid.test.DBUnitTest)23 Record (org.orcid.jaxb.model.record_v2.Record)21 Person (org.orcid.jaxb.model.record_v2.Person)19 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)15 OtherName (org.orcid.jaxb.model.record_v2.OtherName)14 Biography (org.orcid.jaxb.model.record_v2.Biography)13