Search in sources :

Example 51 with Employment

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

the class MemberV3ApiServiceDelegator_GeneralTest method testOrcidProfileCreate_CANT_UpdateOnClaimedAccounts.

@Test
public void testOrcidProfileCreate_CANT_UpdateOnClaimedAccounts() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response response = serviceDelegator.viewAddress(ORCID, 9L);
    assertNotNull(response);
    Address a = (Address) response.getEntity();
    assertNotNull(a);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateAddress(ORCID, a.getPutCode(), a);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewEducation(ORCID, 20L);
    assertNotNull(response);
    Education edu = (Education) response.getEntity();
    assertNotNull(edu);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateEducation(ORCID, edu.getPutCode(), edu);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewEmployment(ORCID, 17L);
    assertNotNull(response);
    Employment emp = (Employment) response.getEntity();
    assertNotNull(emp);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateEmployment(ORCID, emp.getPutCode(), emp);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewExternalIdentifier(ORCID, 13L);
    assertNotNull(response);
    PersonExternalIdentifier extId = (PersonExternalIdentifier) response.getEntity();
    assertNotNull(extId);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateExternalIdentifier(ORCID, extId.getPutCode(), extId);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewFunding(ORCID, 10L);
    assertNotNull(response);
    Funding f = (Funding) response.getEntity();
    assertNotNull(f);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateFunding(ORCID, f.getPutCode(), f);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewKeyword(ORCID, 9L);
    assertNotNull(response);
    Keyword k = (Keyword) response.getEntity();
    assertNotNull(k);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateKeyword(ORCID, k.getPutCode(), k);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewOtherName(ORCID, 13L);
    assertNotNull(response);
    OtherName o = (OtherName) response.getEntity();
    assertNotNull(o);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateOtherName(ORCID, o.getPutCode(), o);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewPeerReview(ORCID, 9L);
    assertNotNull(response);
    PeerReview p = (PeerReview) response.getEntity();
    assertNotNull(p);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updatePeerReview(ORCID, p.getPutCode(), p);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewResearcherUrl(ORCID, 13L);
    assertNotNull(response);
    ResearcherUrl r = (ResearcherUrl) response.getEntity();
    assertNotNull(r);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateResearcherUrl(ORCID, r.getPutCode(), r);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewWork(ORCID, 11L);
    assertNotNull(response);
    Work w = (Work) response.getEntity();
    assertNotNull(w);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateWork(ORCID, w.getPutCode(), w);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
}
Also used : Response(javax.ws.rs.core.Response) Address(org.orcid.jaxb.model.v3.dev1.record.Address) Keyword(org.orcid.jaxb.model.v3.dev1.record.Keyword) Education(org.orcid.jaxb.model.v3.dev1.record.Education) Employment(org.orcid.jaxb.model.v3.dev1.record.Employment) Funding(org.orcid.jaxb.model.v3.dev1.record.Funding) OtherName(org.orcid.jaxb.model.v3.dev1.record.OtherName) Work(org.orcid.jaxb.model.v3.dev1.record.Work) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) PersonExternalIdentifier(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier) PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 52 with Employment

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

the class Utils method getAffiliation.

public static Affiliation getAffiliation(AffiliationType type) {
    Affiliation a = null;
    switch(type) {
        case DISTINCTION:
            a = new Distinction();
            break;
        case EDUCATION:
            a = new Education();
            break;
        case EMPLOYMENT:
            a = new Employment();
            break;
        case INVITED_POSITION:
            a = new InvitedPosition();
            break;
        case MEMBERSHIP:
            a = new Membership();
            break;
        case QUALIFICATION:
            a = new Qualification();
            break;
        case SERVICE:
            a = new Service();
            break;
    }
    a.setDepartmentName("My department name");
    a.setRoleTitle("My Role");
    a.setOrganization(getOrganization());
    a.setStartDate(FuzzyDate.valueOf(2017, 1, 1));
    return a;
}
Also used : Qualification(org.orcid.jaxb.model.v3.dev1.record.Qualification) Education(org.orcid.jaxb.model.v3.dev1.record.Education) Employment(org.orcid.jaxb.model.v3.dev1.record.Employment) InvitedPosition(org.orcid.jaxb.model.v3.dev1.record.InvitedPosition) Membership(org.orcid.jaxb.model.v3.dev1.record.Membership) Service(org.orcid.jaxb.model.v3.dev1.record.Service) Distinction(org.orcid.jaxb.model.v3.dev1.record.Distinction) Affiliation(org.orcid.jaxb.model.v3.dev1.record.Affiliation)

Example 53 with Employment

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

the class JSONInputValidatorTest method testValidateJSONValidInputForInvalidV3Employment.

@Test(expected = InvalidJSONException.class)
public void testValidateJSONValidInputForInvalidV3Employment() throws JAXBException, SAXException, IOException {
    Employment employment = (Employment) Utils.getAffiliation(AffiliationType.EMPLOYMENT);
    employment.setStartDate(null);
    validator.validateJSONInput(employment);
}
Also used : Employment(org.orcid.jaxb.model.v3.dev1.record.Employment) Test(org.junit.Test)

Example 54 with Employment

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

the class JSONInputValidatorTest method testValidateJSONInputForValidV3Employment.

@Test
public void testValidateJSONInputForValidV3Employment() throws JAXBException, SAXException, IOException {
    Employment employment = (Employment) Utils.getAffiliation(AffiliationType.EMPLOYMENT);
    validator.validateJSONInput(employment);
}
Also used : Employment(org.orcid.jaxb.model.v3.dev1.record.Employment) Test(org.junit.Test)

Example 55 with Employment

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

the class PublicV3ApiServiceDelegatorTest method testViewEmployment.

@Test
public void testViewEmployment() {
    Response response = serviceDelegator.viewEmployment(ORCID, 17L);
    assertNotNull(response);
    Employment employment = (Employment) response.getEntity();
    assertNotNull(employment);
    assertNotNull(employment.getLastModifiedDate());
    assertNotNull(employment.getLastModifiedDate().getValue());
    assertEquals(Long.valueOf(17), employment.getPutCode());
    assertEquals("/0000-0000-0000-0003/employment/17", employment.getPath());
    assertEquals("PUBLIC Department", employment.getDepartmentName());
    assertEquals(Visibility.PUBLIC.value(), employment.getVisibility().value());
    assertEquals("APP-5555555555555555", employment.getSource().retrieveSourcePath());
}
Also used : Response(javax.ws.rs.core.Response) Employment(org.orcid.jaxb.model.v3.dev1.record.Employment) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Employment (org.orcid.jaxb.model.v3.dev1.record.Employment)61 Test (org.junit.Test)53 DBUnitTest (org.orcid.test.DBUnitTest)21 Response (javax.ws.rs.core.Response)20 Affiliation (org.orcid.jaxb.model.v3.dev1.record.Affiliation)18 Education (org.orcid.jaxb.model.v3.dev1.record.Education)13 Distinction (org.orcid.jaxb.model.v3.dev1.record.Distinction)11 Membership (org.orcid.jaxb.model.v3.dev1.record.Membership)11 Service (org.orcid.jaxb.model.v3.dev1.record.Service)11 FuzzyDate (org.orcid.jaxb.model.v3.dev1.common.FuzzyDate)10 InvitedPosition (org.orcid.jaxb.model.v3.dev1.record.InvitedPosition)10 Qualification (org.orcid.jaxb.model.v3.dev1.record.Qualification)10 Day (org.orcid.jaxb.model.v3.dev1.common.Day)8 Month (org.orcid.jaxb.model.v3.dev1.common.Month)8 Year (org.orcid.jaxb.model.v3.dev1.common.Year)8 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)8 EmploymentSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary)8 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)7 Funding (org.orcid.jaxb.model.v3.dev1.record.Funding)6 Work (org.orcid.jaxb.model.v3.dev1.record.Work)6