Search in sources :

Example 61 with Works

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

the class MemberV3ApiServiceDelegator_ActivitiesSummaryTest method testViewActitivies_AffiliationsReadLimited_NoSource.

@Test
public void testViewActitivies_AffiliationsReadLimited_NoSource() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, "APP-5555555555555556", ScopePathType.AFFILIATIONS_READ_LIMITED);
    Response response = serviceDelegator.viewActivities(ORCID);
    ActivitiesSummary as = (ActivitiesSummary) response.getEntity();
    assertNotNull(as);
    assertNotNull(as.getPath());
    Utils.verifyLastModified(as.getLastModifiedDate());
    // Limited educations
    boolean found1 = false, found2 = false, found3 = false;
    assertNotNull(as.getEducations());
    assertEquals(3, as.getEducations().getSummaries().size());
    for (EducationSummary education : as.getEducations().getSummaries()) {
        Long putCode = education.getPutCode();
        if (putCode == 20L) {
            assertEquals(Visibility.PUBLIC, education.getVisibility());
            found1 = true;
        } else if (putCode == 21L) {
            assertEquals(Visibility.LIMITED, education.getVisibility());
            found2 = true;
        } else if (putCode == 25L) {
            assertEquals(Visibility.LIMITED, education.getVisibility());
            found3 = true;
        } else {
            fail("Invalid put code " + putCode);
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    // Limited employments
    found1 = found2 = found3 = false;
    assertNotNull(as.getEmployments());
    assertEquals(3, as.getEmployments().getSummaries().size());
    for (EmploymentSummary employment : as.getEmployments().getSummaries()) {
        Long putCode = employment.getPutCode();
        if (putCode == 17L) {
            assertEquals(Visibility.PUBLIC, employment.getVisibility());
            found1 = true;
        } else if (putCode == 18L) {
            assertEquals(Visibility.LIMITED, employment.getVisibility());
            found2 = true;
        } else if (putCode == 23L) {
            assertEquals(Visibility.LIMITED, employment.getVisibility());
            found3 = true;
        } else {
            fail("Invalid put code " + putCode);
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    // 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());
    // 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) EducationSummary(org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary) EmploymentSummary(org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary) ActivitiesSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 62 with Works

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

the class MemberV3ApiServiceDelegator_AddressesTest method testReadPublicScope_Address.

@Test
public void testReadPublicScope_Address() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
    // Public works
    Response r = serviceDelegator.viewAddresses(ORCID);
    assertNotNull(r);
    assertEquals(Addresses.class.getName(), r.getEntity().getClass().getName());
    Addresses a = (Addresses) r.getEntity();
    assertNotNull(a);
    assertEquals("/0000-0000-0000-0003/address", a.getPath());
    Utils.verifyLastModified(a.getLastModifiedDate());
    assertEquals(3, a.getAddress().size());
    boolean found9 = false, found10 = false, found11 = false;
    for (Address address : a.getAddress()) {
        if (address.getPutCode() == 9) {
            found9 = true;
        } else if (address.getPutCode() == 10) {
            found10 = true;
        } else if (address.getPutCode() == 11) {
            found11 = true;
        } else {
            fail("Invalid put code " + address.getPutCode());
        }
    }
    assertTrue(found9);
    assertTrue(found10);
    assertTrue(found11);
    r = serviceDelegator.viewAddress(ORCID, 9L);
    assertNotNull(r);
    assertEquals(Address.class.getName(), r.getEntity().getClass().getName());
    // Limited where am the source should work
    serviceDelegator.viewAddress(ORCID, 10L);
    try {
        // Limited am not the source should fail
        serviceDelegator.viewAddress(ORCID, 12L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
    // Private where am the source should work
    serviceDelegator.viewAddress(ORCID, 11L);
    try {
        // Private am not the source should fail
        serviceDelegator.viewAddress(ORCID, 13L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
}
Also used : Response(javax.ws.rs.core.Response) Addresses(org.orcid.jaxb.model.v3.dev1.record.Addresses) Address(org.orcid.jaxb.model.v3.dev1.record.Address) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) NoResultException(javax.persistence.NoResultException) VisibilityMismatchException(org.orcid.core.exception.VisibilityMismatchException) WrongSourceException(org.orcid.core.exception.WrongSourceException) 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 63 with Works

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

the class MemberV3ApiServiceDelegator_ExternalIdentifiersTest method testReadPublicScope_ExternalIdentifiers.

@Test
public void testReadPublicScope_ExternalIdentifiers() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
    // Public works
    Response r = serviceDelegator.viewExternalIdentifiers(ORCID);
    assertNotNull(r);
    assertEquals(PersonExternalIdentifiers.class.getName(), r.getEntity().getClass().getName());
    PersonExternalIdentifiers p = (PersonExternalIdentifiers) r.getEntity();
    assertNotNull(p);
    assertEquals("/0000-0000-0000-0003/external-identifiers", p.getPath());
    Utils.verifyLastModified(p.getLastModifiedDate());
    assertEquals(3, p.getExternalIdentifiers().size());
    boolean found13 = false, found14 = false, found15 = false;
    for (PersonExternalIdentifier element : p.getExternalIdentifiers()) {
        if (element.getPutCode() == 13) {
            found13 = true;
        } else if (element.getPutCode() == 14) {
            found14 = true;
        } else if (element.getPutCode() == 15) {
            found15 = true;
        } else {
            fail("Invalid put code " + element.getPutCode());
        }
    }
    assertTrue(found13);
    assertTrue(found14);
    assertTrue(found15);
    r = serviceDelegator.viewExternalIdentifier(ORCID, 13L);
    assertNotNull(r);
    assertEquals(PersonExternalIdentifier.class.getName(), r.getEntity().getClass().getName());
    // Limited am the source of should work
    serviceDelegator.viewExternalIdentifier(ORCID, 14L);
    // Limited fail
    try {
        serviceDelegator.viewExternalIdentifier(ORCID, 16L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
    // Private am the source of should work
    serviceDelegator.viewExternalIdentifier(ORCID, 15L);
    // Private fail
    try {
        serviceDelegator.viewExternalIdentifier(ORCID, 17L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
}
Also used : Response(javax.ws.rs.core.Response) PersonExternalIdentifiers(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers) PersonExternalIdentifier(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) NoResultException(javax.persistence.NoResultException) VisibilityMismatchException(org.orcid.core.exception.VisibilityMismatchException) WrongSourceException(org.orcid.core.exception.WrongSourceException) 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 64 with Works

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

the class MemberV3ApiServiceDelegator_KeywordsTest method testReadPublicScope_Keywords.

@Test
public void testReadPublicScope_Keywords() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
    // Public works
    Response r = serviceDelegator.viewKeywords(ORCID);
    assertNotNull(r);
    assertEquals(Keywords.class.getName(), r.getEntity().getClass().getName());
    Keywords k = (Keywords) r.getEntity();
    assertNotNull(k);
    Utils.verifyLastModified(k.getLastModifiedDate());
    assertEquals(3, k.getKeywords().size());
    boolean found1 = false, found2 = false, found3 = false;
    for (Keyword element : k.getKeywords()) {
        Utils.verifyLastModified(element.getLastModifiedDate());
        if (element.getPutCode() == 9) {
            found1 = true;
        } else if (element.getPutCode() == 10) {
            found2 = true;
        } else if (element.getPutCode() == 11) {
            found3 = true;
        } else {
            fail("Invalid put code " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    r = serviceDelegator.viewKeyword(ORCID, 9L);
    assertNotNull(r);
    assertEquals(Keyword.class.getName(), r.getEntity().getClass().getName());
    // Limited where am the source of should work
    serviceDelegator.viewKeyword(ORCID, 10L);
    // Limited where am not the source of should fail
    try {
        serviceDelegator.viewKeyword(ORCID, 12L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
    // Private where am the source of should work
    serviceDelegator.viewKeyword(ORCID, 11L);
    // Private where am not the source of should fail
    try {
        serviceDelegator.viewKeyword(ORCID, 13L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
}
Also used : Response(javax.ws.rs.core.Response) Keywords(org.orcid.jaxb.model.v3.dev1.record.Keywords) Keyword(org.orcid.jaxb.model.v3.dev1.record.Keyword) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) NoResultException(javax.persistence.NoResultException) VisibilityMismatchException(org.orcid.core.exception.VisibilityMismatchException) WrongSourceException(org.orcid.core.exception.WrongSourceException) 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 65 with Works

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

the class MemberV3ApiServiceDelegator_OtherNamesTest method testReadPublicScope_OtherNames.

@Test
public void testReadPublicScope_OtherNames() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
    // Public works
    Response r = serviceDelegator.viewOtherNames(ORCID);
    assertNotNull(r);
    assertEquals(OtherNames.class.getName(), r.getEntity().getClass().getName());
    OtherNames o = (OtherNames) r.getEntity();
    assertNotNull(o);
    Utils.verifyLastModified(o.getLastModifiedDate());
    assertEquals(3, o.getOtherNames().size());
    boolean found1 = false, found2 = false, found3 = false;
    for (OtherName element : o.getOtherNames()) {
        Utils.verifyLastModified(element.getLastModifiedDate());
        if (element.getPutCode() == 13) {
            found1 = true;
        } else if (element.getPutCode() == 14) {
            found2 = true;
        } else if (element.getPutCode() == 15) {
            found3 = true;
        } else {
            fail("Invalid put code " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    r = serviceDelegator.viewOtherName(ORCID, 13L);
    assertNotNull(r);
    assertEquals(OtherName.class.getName(), r.getEntity().getClass().getName());
    // Limited where am the source should work
    serviceDelegator.viewOtherName(ORCID, 14L);
    // Limited where am not the source of should fail
    try {
        serviceDelegator.viewOtherName(ORCID, 16L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
    // Private where am the source should work
    serviceDelegator.viewOtherName(ORCID, 15L);
    // Private where am not the source should work
    try {
        serviceDelegator.viewOtherName(ORCID, 17L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
}
Also used : Response(javax.ws.rs.core.Response) OtherNames(org.orcid.jaxb.model.v3.dev1.record.OtherNames) OtherName(org.orcid.jaxb.model.v3.dev1.record.OtherName) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) NoResultException(javax.persistence.NoResultException) VisibilityMismatchException(org.orcid.core.exception.VisibilityMismatchException) WrongSourceException(org.orcid.core.exception.WrongSourceException) 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)

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