Search in sources :

Example 31 with InvitedPosition

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

the class MemberV3ApiServiceDelegator_InvitedPositionsTest method testUpdateInvitedPosition.

@Test
public void testUpdateInvitedPosition() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewInvitedPosition(ORCID, 32L);
    assertNotNull(response);
    InvitedPosition invitedPosition = (InvitedPosition) response.getEntity();
    assertNotNull(invitedPosition);
    assertEquals("PUBLIC Department", invitedPosition.getDepartmentName());
    assertEquals("PUBLIC", invitedPosition.getRoleTitle());
    Utils.verifyLastModified(invitedPosition.getLastModifiedDate());
    LastModifiedDate before = invitedPosition.getLastModifiedDate();
    invitedPosition.setDepartmentName("Updated department name");
    invitedPosition.setRoleTitle("The updated role title");
    // disambiguated org is required in API v3
    DisambiguatedOrganization disambiguatedOrg = new DisambiguatedOrganization();
    disambiguatedOrg.setDisambiguatedOrganizationIdentifier("abc456");
    disambiguatedOrg.setDisambiguationSource("WDB");
    invitedPosition.getOrganization().setDisambiguatedOrganization(disambiguatedOrg);
    response = serviceDelegator.updateInvitedPosition(ORCID, 32L, invitedPosition);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewInvitedPosition(ORCID, 32L);
    assertNotNull(response);
    invitedPosition = (InvitedPosition) response.getEntity();
    assertNotNull(invitedPosition);
    Utils.verifyLastModified(invitedPosition.getLastModifiedDate());
    assertTrue(invitedPosition.getLastModifiedDate().after(before));
    assertEquals("Updated department name", invitedPosition.getDepartmentName());
    assertEquals("The updated role title", invitedPosition.getRoleTitle());
    // Rollback changes
    invitedPosition.setDepartmentName("PUBLIC Department");
    invitedPosition.setRoleTitle("PUBLIC");
    response = serviceDelegator.updateInvitedPosition(ORCID, 32L, invitedPosition);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate) DisambiguatedOrganization(org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization) InvitedPosition(org.orcid.jaxb.model.v3.dev1.record.InvitedPosition) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 32 with InvitedPosition

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

the class MemberV3ApiServiceDelegator_InvitedPositionsTest method testAddInvitedPosition.

@Test
public void testAddInvitedPosition() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewActivities(ORCID);
    assertNotNull(response);
    ActivitiesSummary originalSummary = (ActivitiesSummary) response.getEntity();
    assertNotNull(originalSummary);
    Utils.verifyLastModified(originalSummary.getLastModifiedDate());
    assertNotNull(originalSummary.getInvitedPositions());
    Utils.verifyLastModified(originalSummary.getInvitedPositions().getLastModifiedDate());
    assertNotNull(originalSummary.getInvitedPositions().getSummaries());
    assertNotNull(originalSummary.getInvitedPositions().getSummaries().get(0));
    Utils.verifyLastModified(originalSummary.getInvitedPositions().getSummaries().get(0).getLastModifiedDate());
    assertEquals(4, originalSummary.getInvitedPositions().getSummaries().size());
    response = serviceDelegator.createInvitedPosition(ORCID, (InvitedPosition) Utils.getAffiliation(AffiliationType.INVITED_POSITION));
    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(ORCID);
    assertNotNull(response);
    ActivitiesSummary summaryWithNewElement = (ActivitiesSummary) response.getEntity();
    assertNotNull(summaryWithNewElement);
    Utils.verifyLastModified(summaryWithNewElement.getLastModifiedDate());
    assertNotNull(summaryWithNewElement.getInvitedPositions());
    Utils.verifyLastModified(summaryWithNewElement.getInvitedPositions().getLastModifiedDate());
    assertNotNull(summaryWithNewElement.getInvitedPositions().getSummaries());
    assertEquals(5, summaryWithNewElement.getInvitedPositions().getSummaries().size());
    boolean haveNew = false;
    for (InvitedPositionSummary invitedPositionSummary : summaryWithNewElement.getInvitedPositions().getSummaries()) {
        assertNotNull(invitedPositionSummary.getPutCode());
        Utils.verifyLastModified(invitedPositionSummary.getLastModifiedDate());
        if (invitedPositionSummary.getPutCode().equals(putCode)) {
            assertEquals("My department name", invitedPositionSummary.getDepartmentName());
            haveNew = true;
        } else {
            assertTrue(originalSummary.getInvitedPositions().getSummaries().contains(invitedPositionSummary));
        }
    }
    assertTrue(haveNew);
    // Remove new element
    serviceDelegator.deleteAffiliation(ORCID, putCode);
}
Also used : Response(javax.ws.rs.core.Response) InvitedPositionSummary(org.orcid.jaxb.model.v3.dev1.record.summary.InvitedPositionSummary) InvitedPosition(org.orcid.jaxb.model.v3.dev1.record.InvitedPosition) List(java.util.List) ActivitiesSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 33 with InvitedPosition

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

the class MemberV3ApiServiceDelegator_InvitedPositionsTest method testViewLimitedInvitedPosition.

@Test
public void testViewLimitedInvitedPosition() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response response = serviceDelegator.viewInvitedPosition(ORCID, 35L);
    assertNotNull(response);
    InvitedPosition invitedPosition = (InvitedPosition) response.getEntity();
    assertNotNull(invitedPosition);
    Utils.verifyLastModified(invitedPosition.getLastModifiedDate());
    assertEquals(Long.valueOf(35L), invitedPosition.getPutCode());
    assertEquals("/0000-0000-0000-0003/invited-position/35", invitedPosition.getPath());
    assertEquals("SELF LIMITED Department", invitedPosition.getDepartmentName());
    assertEquals(Visibility.LIMITED.value(), invitedPosition.getVisibility().value());
}
Also used : Response(javax.ws.rs.core.Response) InvitedPosition(org.orcid.jaxb.model.v3.dev1.record.InvitedPosition) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 34 with InvitedPosition

use of org.orcid.jaxb.model.v3.dev1.record.InvitedPosition 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 35 with InvitedPosition

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

the class PublicV3ApiServiceDelegatorTest method testGetPublicInvitedPositionUsingToken.

@Test
public void testGetPublicInvitedPositionUsingToken() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response r = serviceDelegator.viewInvitedPosition(ORCID, 32L);
    assertNotNull(r);
    InvitedPosition e = (InvitedPosition) r.getEntity();
    assertNotNull(e);
    assertEquals(Long.valueOf(32), e.getPutCode());
    assertNotNull(e.getLastModifiedDate());
    assertNotNull(e.getLastModifiedDate().getValue());
}
Also used : Response(javax.ws.rs.core.Response) InvitedPosition(org.orcid.jaxb.model.v3.dev1.record.InvitedPosition) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

InvitedPosition (org.orcid.jaxb.model.v3.dev1.record.InvitedPosition)40 Test (org.junit.Test)28 DBUnitTest (org.orcid.test.DBUnitTest)17 Response (javax.ws.rs.core.Response)16 Distinction (org.orcid.jaxb.model.v3.dev1.record.Distinction)11 Education (org.orcid.jaxb.model.v3.dev1.record.Education)11 Membership (org.orcid.jaxb.model.v3.dev1.record.Membership)11 Service (org.orcid.jaxb.model.v3.dev1.record.Service)11 Employment (org.orcid.jaxb.model.v3.dev1.record.Employment)10 Qualification (org.orcid.jaxb.model.v3.dev1.record.Qualification)10 Affiliation (org.orcid.jaxb.model.v3.dev1.record.Affiliation)7 InvitedPositionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.InvitedPositionSummary)6 List (java.util.List)4 Url (org.orcid.jaxb.model.v3.dev1.common.Url)4 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)4 Funding (org.orcid.jaxb.model.v3.dev1.record.Funding)4 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)4 Work (org.orcid.jaxb.model.v3.dev1.record.Work)4 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)4 OrgAffiliationRelationEntity (org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity)4