Search in sources :

Example 6 with Works

use of org.orcid.jaxb.model.v3.dev1.record.summary.Works in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_PeerReviewsTest method testReadPublicScope_PeerReview.

@Test
public void testReadPublicScope_PeerReview() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
    // Public works
    Response r = serviceDelegator.viewPeerReview(ORCID, 9L);
    assertNotNull(r);
    assertEquals(PeerReview.class.getName(), r.getEntity().getClass().getName());
    r = serviceDelegator.viewPeerReviewSummary(ORCID, 9L);
    assertNotNull(r);
    assertEquals(PeerReviewSummary.class.getName(), r.getEntity().getClass().getName());
    // Limited where am the source of should work
    serviceDelegator.viewPeerReview(ORCID, 10L);
    serviceDelegator.viewPeerReviewSummary(ORCID, 10L);
    // Limited where am not the source of should fail
    try {
        serviceDelegator.viewPeerReview(ORCID, 12L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
    try {
        serviceDelegator.viewPeerReviewSummary(ORCID, 12L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
    // Limited where am the source of should work
    serviceDelegator.viewPeerReview(ORCID, 11L);
    serviceDelegator.viewPeerReviewSummary(ORCID, 11L);
    // Limited where am not the source of should fail
    try {
        serviceDelegator.viewPeerReview(ORCID, 13L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
    try {
        serviceDelegator.viewPeerReviewSummary(ORCID, 13L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
}
Also used : Response(javax.ws.rs.core.Response) PeerReviewSummary(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview) NoResultException(javax.persistence.NoResultException) VisibilityMismatchException(org.orcid.core.exception.VisibilityMismatchException) WrongSourceException(org.orcid.core.exception.WrongSourceException) ActivityIdentifierValidationException(org.orcid.core.exception.ActivityIdentifierValidationException) OrcidDuplicatedActivityException(org.orcid.core.exception.OrcidDuplicatedActivityException) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) OrcidVisibilityException(org.orcid.core.exception.OrcidVisibilityException) OrcidUnauthorizedException(org.orcid.core.exception.OrcidUnauthorizedException) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 7 with Works

use of org.orcid.jaxb.model.v3.dev1.record.summary.Works in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_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.v3.dev1.record.summary.WorkGroup) WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) Work(org.orcid.jaxb.model.v3.dev1.record.Work) ActivitiesSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 8 with Works

use of org.orcid.jaxb.model.v3.dev1.record.summary.Works in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_WorksTest method testReadPublicScope_Works.

@Test
public void testReadPublicScope_Works() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
    // Public works
    Response r = serviceDelegator.viewWork(ORCID, 11L);
    assertNotNull(r);
    assertEquals(Work.class.getName(), r.getEntity().getClass().getName());
    r = serviceDelegator.viewWorkSummary(ORCID, 11L);
    assertNotNull(r);
    assertEquals(WorkSummary.class.getName(), r.getEntity().getClass().getName());
    // Limited where source is me, should work
    serviceDelegator.viewWork(ORCID, 12L);
    serviceDelegator.viewWorkSummary(ORCID, 12L);
    // Limited with other source should fail
    try {
        serviceDelegator.viewWork(ORCID, 14L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
    try {
        serviceDelegator.viewWorkSummary(ORCID, 14L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
    // Private where am the source should work
    serviceDelegator.viewWork(ORCID, 13L);
    serviceDelegator.viewWorkSummary(ORCID, 13L);
    // Private with other source should fail
    try {
        serviceDelegator.viewWork(ORCID, 15L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
    try {
        serviceDelegator.viewWork(ORCID, 15L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
}
Also used : Response(javax.ws.rs.core.Response) WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) Work(org.orcid.jaxb.model.v3.dev1.record.Work) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) ExceedMaxNumberOfPutCodesException(org.orcid.core.exception.ExceedMaxNumberOfPutCodesException) NoResultException(javax.persistence.NoResultException) VisibilityMismatchException(org.orcid.core.exception.VisibilityMismatchException) OrcidNoResultException(org.orcid.core.exception.OrcidNoResultException) WrongSourceException(org.orcid.core.exception.WrongSourceException) ActivityIdentifierValidationException(org.orcid.core.exception.ActivityIdentifierValidationException) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) OrcidVisibilityException(org.orcid.core.exception.OrcidVisibilityException) OrcidUnauthorizedException(org.orcid.core.exception.OrcidUnauthorizedException) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 9 with Works

use of org.orcid.jaxb.model.v3.dev1.record.summary.Works in project ORCID-Source by ORCID.

the class PublicV3ApiServiceDelegatorTest method testGetPublicWorks.

@Test
public void testGetPublicWorks() {
    Response r = serviceDelegator.viewWorks(ORCID);
    assertNotNull(r);
    Works works = (Works) r.getEntity();
    assertNotNull(works);
    assertNotNull(works.getLastModifiedDate());
    assertNotNull(works.getLastModifiedDate().getValue());
    assertNotNull(works.getWorkGroup());
    assertEquals(1, works.getWorkGroup().size());
    assertNotNull(works.getWorkGroup().get(0).getIdentifiers());
    assertEquals(1, works.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().size());
    assertEquals("1", works.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getValue());
    assertNotNull(works.getWorkGroup().get(0).getWorkSummary());
    assertEquals(Long.valueOf(11), works.getWorkGroup().get(0).getWorkSummary().get(0).getPutCode());
    assertNotNull(works.getWorkGroup().get(0).getWorkSummary().get(0).getLastModifiedDate());
    assertNotNull(works.getWorkGroup().get(0).getWorkSummary().get(0).getLastModifiedDate().getValue());
}
Also used : Response(javax.ws.rs.core.Response) Works(org.orcid.jaxb.model.v3.dev1.record.summary.Works) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 10 with Works

use of org.orcid.jaxb.model.v3.dev1.record.summary.Works in project ORCID-Source by ORCID.

the class PublicAPISecurityManagerV3Test 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.v3.dev1.record.summary.WorkGroup) WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) Visibility(org.orcid.jaxb.model.v3.dev1.common.Visibility) Works(org.orcid.jaxb.model.v3.dev1.record.summary.Works)

Aggregations

Test (org.junit.Test)83 WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)65 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)46 FundingSummary (org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary)38 EducationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary)37 EmploymentSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary)37 PeerReviewSummary (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary)37 Works (org.orcid.jaxb.model.v3.dev1.record.summary.Works)37 DistinctionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.DistinctionSummary)35 InvitedPositionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.InvitedPositionSummary)35 MembershipSummary (org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary)35 QualificationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.QualificationSummary)35 ServiceSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ServiceSummary)35 DBUnitTest (org.orcid.test.DBUnitTest)21 Response (javax.ws.rs.core.Response)20 WorkGroup (org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup)20 PersonExternalIdentifier (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)17 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)17 Address (org.orcid.jaxb.model.v3.dev1.record.Address)16 Biography (org.orcid.jaxb.model.v3.dev1.record.Biography)16