Search in sources :

Example 6 with InvitedPosition

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

the class MemberV3ApiServiceDelegator_InvitedPositionsTest method testUpdateInvitedPositionYouAreNotTheSourceOf.

@Test(expected = WrongSourceException.class)
public void testUpdateInvitedPositionYouAreNotTheSourceOf() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewInvitedPosition(ORCID, 35L);
    assertNotNull(response);
    InvitedPosition invitedPosition = (InvitedPosition) response.getEntity();
    assertNotNull(invitedPosition);
    invitedPosition.setDepartmentName("Updated department name");
    invitedPosition.setRoleTitle("The updated role title");
    serviceDelegator.updateInvitedPosition(ORCID, 35L, invitedPosition);
    fail();
}
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 7 with InvitedPosition

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

the class MemberV3ApiServiceDelegator_InvitedPositionsTest method testDeleteInvitedPosition.

@Test
public void testDeleteInvitedPosition() {
    SecurityContextTestUtils.setUpSecurityContext("0000-0000-0000-0002", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewInvitedPosition("0000-0000-0000-0002", 1003L);
    assertNotNull(response);
    InvitedPosition invitedPosition = (InvitedPosition) response.getEntity();
    assertNotNull(invitedPosition);
    response = serviceDelegator.deleteAffiliation("0000-0000-0000-0002", 1003L);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    try {
        serviceDelegator.viewInvitedPosition("0000-0000-0000-0002", 1003L);
        fail();
    } catch (NoResultException nre) {
    } catch (Exception e) {
        fail();
    }
}
Also used : Response(javax.ws.rs.core.Response) InvitedPosition(org.orcid.jaxb.model.v3.dev1.record.InvitedPosition) NoResultException(javax.persistence.NoResultException) NoResultException(javax.persistence.NoResultException) VisibilityMismatchException(org.orcid.core.exception.VisibilityMismatchException) WrongSourceException(org.orcid.core.exception.WrongSourceException) OrcidDuplicatedActivityException(org.orcid.core.exception.OrcidDuplicatedActivityException) OrcidValidationException(org.orcid.core.exception.OrcidValidationException) 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 8 with InvitedPosition

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

the class MemberV3ApiServiceDelegator_InvitedPositionsTest method testAddInvitedPositionNoStartDate.

@Test(expected = OrcidValidationException.class)
public void testAddInvitedPositionNoStartDate() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    InvitedPosition invitedPosition = (InvitedPosition) Utils.getAffiliation(AffiliationType.INVITED_POSITION);
    invitedPosition.setStartDate(null);
    serviceDelegator.createInvitedPosition(ORCID, invitedPosition);
}
Also used : InvitedPosition(org.orcid.jaxb.model.v3.dev1.record.InvitedPosition) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 9 with InvitedPosition

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

the class MemberV3ApiServiceDelegator_InvitedPositionsTest method testAddInvitedPositionsDuplicateExternalIDs.

@Test(expected = OrcidDuplicatedActivityException.class)
public void testAddInvitedPositionsDuplicateExternalIDs() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    ExternalID e1 = new ExternalID();
    e1.setRelationship(Relationship.SELF);
    e1.setType("erm");
    e1.setUrl(new Url("https://orcid.org"));
    e1.setValue("err");
    ExternalID e2 = new ExternalID();
    e2.setRelationship(Relationship.SELF);
    e2.setType("err");
    e2.setUrl(new Url("http://bbc.co.uk"));
    e2.setValue("erm");
    ExternalIDs externalIDs = new ExternalIDs();
    externalIDs.getExternalIdentifier().add(e1);
    externalIDs.getExternalIdentifier().add(e2);
    InvitedPosition invitedPosition = (InvitedPosition) Utils.getAffiliation(AffiliationType.INVITED_POSITION);
    invitedPosition.setExternalIDs(externalIDs);
    Response response = serviceDelegator.createInvitedPosition(ORCID, invitedPosition);
    assertNotNull(response);
    assertEquals(HttpStatus.SC_CREATED, 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)));
    try {
        InvitedPosition duplicate = (InvitedPosition) Utils.getAffiliation(AffiliationType.INVITED_POSITION);
        duplicate.setExternalIDs(externalIDs);
        serviceDelegator.createInvitedPosition(ORCID, duplicate);
    } finally {
        serviceDelegator.deleteAffiliation(ORCID, putCode);
    }
}
Also used : Response(javax.ws.rs.core.Response) ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) InvitedPosition(org.orcid.jaxb.model.v3.dev1.record.InvitedPosition) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) List(java.util.List) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) Url(org.orcid.jaxb.model.v3.dev1.common.Url) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 10 with InvitedPosition

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

the class MemberV3ApiServiceDelegator_InvitedPositionsTest method testUpdateInvitedPositionLeavingVisibilityNullTest.

@Test
public void testUpdateInvitedPositionLeavingVisibilityNullTest() {
    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(Visibility.PUBLIC, invitedPosition.getVisibility());
    invitedPosition.setVisibility(null);
    response = serviceDelegator.updateInvitedPosition(ORCID, 32L, invitedPosition);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    invitedPosition = (InvitedPosition) response.getEntity();
    assertNotNull(invitedPosition);
    assertEquals(Visibility.PUBLIC, invitedPosition.getVisibility());
}
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