Search in sources :

Example 71 with ActivitiesSummary

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

the class PublicV2Test method testGetInfoWithEmptyToken.

@Test
public void testGetInfoWithEmptyToken() throws InterruptedException, JSONException {
    ClientResponse activitiesResponse = publicV2ApiClient.viewActivities(getUser1OrcidId(), "");
    assertNotNull(activitiesResponse);
    assertEquals(Response.Status.OK.getStatusCode(), activitiesResponse.getStatus());
    ActivitiesSummary activities = activitiesResponse.getEntity(ActivitiesSummary.class);
    assertNotNull(activities);
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) ActivitiesSummary(org.orcid.jaxb.model.record.summary_rc1.ActivitiesSummary) Test(org.junit.Test)

Example 72 with ActivitiesSummary

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

the class PublicV2ApiServiceDelegatorTest method testFindActivityDetails.

@Test
public void testFindActivityDetails() {
    Response response = serviceDelegator.viewActivities(ORCID);
    assertNotNull(response);
    ActivitiesSummary summary = (ActivitiesSummary) response.getEntity();
    validateActivities(summary);
}
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 73 with ActivitiesSummary

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

the class MemberV2ApiServiceDelegator_ActivitiesSummaryTest method testCleanEmptyFieldsOnActivities.

@Test
public void testCleanEmptyFieldsOnActivities() {
    LastModifiedDate lmd = new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(System.currentTimeMillis()));
    Works works = new Works();
    works.setLastModifiedDate(lmd);
    WorkGroup group = new WorkGroup();
    group.setLastModifiedDate(lmd);
    for (int i = 0; i < 5; i++) {
        WorkSummary summary = new WorkSummary();
        summary.setLastModifiedDate(lmd);
        WorkTitle title = new WorkTitle();
        title.setTitle(new Title("Work " + i));
        title.setTranslatedTitle(new TranslatedTitle("", ""));
        summary.setTitle(title);
        group.getWorkSummary().add(summary);
    }
    works.getWorkGroup().add(group);
    ActivitiesSummary as = new ActivitiesSummary();
    as.setWorks(works);
    ActivityUtils.cleanEmptyFields(as);
    assertNotNull(as);
    assertNotNull(as.getWorks());
    Utils.verifyLastModified(as.getWorks().getLastModifiedDate());
    assertNotNull(as.getWorks().getWorkGroup());
    assertEquals(1, as.getWorks().getWorkGroup().size());
    assertNotNull(as.getWorks().getWorkGroup().get(0).getWorkSummary());
    Utils.verifyLastModified(as.getWorks().getWorkGroup().get(0).getLastModifiedDate());
    assertEquals(5, as.getWorks().getWorkGroup().get(0).getWorkSummary().size());
    for (WorkSummary summary : as.getWorks().getWorkGroup().get(0).getWorkSummary()) {
        Utils.verifyLastModified(summary.getLastModifiedDate());
        assertNotNull(summary.getTitle());
        assertNotNull(summary.getTitle().getTitle());
        assertTrue(summary.getTitle().getTitle().getContent().startsWith("Work "));
        assertNull(summary.getTitle().getTranslatedTitle());
    }
}
Also used : LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) WorkGroup(org.orcid.jaxb.model.record.summary_v2.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) TranslatedTitle(org.orcid.jaxb.model.common_v2.TranslatedTitle) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) TranslatedTitle(org.orcid.jaxb.model.common_v2.TranslatedTitle) Title(org.orcid.jaxb.model.common_v2.Title) Works(org.orcid.jaxb.model.record.summary_v2.Works) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 74 with ActivitiesSummary

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

the class MemberV2ApiServiceDelegator_ActivitiesSummaryTest method testViewActitivies_WorksReadLimited_NoSource.

@Test
public void testViewActitivies_WorksReadLimited_NoSource() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, "APP-5555555555555556", ScopePathType.ORCID_WORKS_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());
    // Only public peer reviews
    assertNotNull(as.getPeerReviews());
    assertEquals(1, as.getPeerReviews().getPeerReviewGroup().size());
    assertEquals(1, as.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().size());
    assertEquals(Long.valueOf(9), as.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC, as.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getVisibility());
    // Limited works
    assertNotNull(as.getWorks());
    assertEquals(3, as.getWorks().getWorkGroup().size());
    boolean found1 = false, found2 = false, found3 = false;
    for (WorkGroup group : as.getWorks().getWorkGroup()) {
        assertEquals(1, group.getWorkSummary().size());
        WorkSummary element = group.getWorkSummary().get(0);
        if (element.getPutCode().equals(Long.valueOf(11))) {
            assertEquals(Visibility.PUBLIC, element.getVisibility());
            found1 = true;
        } else if (element.getPutCode().equals(Long.valueOf(12))) {
            assertEquals(Visibility.LIMITED, element.getVisibility());
            found2 = true;
        } else if (element.getPutCode().equals(Long.valueOf(14))) {
            assertEquals(Visibility.LIMITED, element.getVisibility());
            found3 = true;
        } else {
            fail("Invalid put code " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
}
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) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 75 with ActivitiesSummary

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

the class MemberV2ApiServiceDelegator_ActivitiesSummaryTest method testReadPublicScope_Activities.

@Test
public void testReadPublicScope_Activities() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
    // Check you get only public activities
    Response r = serviceDelegator.viewActivities(ORCID);
    ActivitiesSummary as = (ActivitiesSummary) r.getEntity();
    testActivities(as, ORCID);
}
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)

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