Search in sources :

Example 6 with Membership

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

the class MemberV3ApiServiceDelegator_MembershipsTest method testViewPrivateMembership.

@Test
public void testViewPrivateMembership() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response response = serviceDelegator.viewMembership(ORCID, 39L);
    assertNotNull(response);
    Membership membership = (Membership) response.getEntity();
    assertNotNull(membership);
    Utils.verifyLastModified(membership.getLastModifiedDate());
    assertEquals(Long.valueOf(39L), membership.getPutCode());
    assertEquals("/0000-0000-0000-0003/membership/39", membership.getPath());
    assertEquals("PRIVATE Department", membership.getDepartmentName());
    assertEquals(Visibility.PRIVATE.value(), membership.getVisibility().value());
}
Also used : Response(javax.ws.rs.core.Response) Membership(org.orcid.jaxb.model.v3.dev1.record.Membership) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 7 with Membership

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

the class MemberV3ApiServiceDelegator_MembershipsTest method testAddMembershipNoStartDate.

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

Example 8 with Membership

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

the class MemberV3ApiServiceDelegator_MembershipsTest method testDeleteMembership.

@Test
public void testDeleteMembership() {
    SecurityContextTestUtils.setUpSecurityContext("0000-0000-0000-0002", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewMembership("0000-0000-0000-0002", 1004L);
    assertNotNull(response);
    Membership membership = (Membership) response.getEntity();
    assertNotNull(membership);
    response = serviceDelegator.deleteAffiliation("0000-0000-0000-0002", 1004L);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    try {
        serviceDelegator.viewMembership("0000-0000-0000-0002", 1004L);
        fail();
    } catch (NoResultException nre) {
    } catch (Exception e) {
        fail();
    }
}
Also used : Response(javax.ws.rs.core.Response) Membership(org.orcid.jaxb.model.v3.dev1.record.Membership) 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 9 with Membership

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

the class MemberV3ApiServiceDelegator_MembershipsTest method testUpdateMembershipChangingVisibilityTest.

@Test(expected = VisibilityMismatchException.class)
public void testUpdateMembershipChangingVisibilityTest() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewMembership(ORCID, 37L);
    assertNotNull(response);
    Membership membership = (Membership) response.getEntity();
    assertNotNull(membership);
    assertEquals(Visibility.PUBLIC, membership.getVisibility());
    membership.setVisibility(Visibility.PRIVATE);
    response = serviceDelegator.updateMembership(ORCID, 37L, membership);
    fail();
}
Also used : Response(javax.ws.rs.core.Response) Membership(org.orcid.jaxb.model.v3.dev1.record.Membership) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 10 with Membership

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

the class MemberV3ApiServiceDelegator_MembershipsTest method testUpdateMembershipYouAreNotTheSourceOf.

@Test(expected = WrongSourceException.class)
public void testUpdateMembershipYouAreNotTheSourceOf() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewMembership(ORCID, 40L);
    assertNotNull(response);
    Membership membership = (Membership) response.getEntity();
    assertNotNull(membership);
    membership.setDepartmentName("Updated department name");
    membership.setRoleTitle("The updated role title");
    serviceDelegator.updateMembership(ORCID, 40L, membership);
    fail();
}
Also used : Response(javax.ws.rs.core.Response) Membership(org.orcid.jaxb.model.v3.dev1.record.Membership) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Membership (org.orcid.jaxb.model.v3.dev1.record.Membership)41 Test (org.junit.Test)31 DBUnitTest (org.orcid.test.DBUnitTest)18 Response (javax.ws.rs.core.Response)17 Distinction (org.orcid.jaxb.model.v3.dev1.record.Distinction)11 Education (org.orcid.jaxb.model.v3.dev1.record.Education)11 Service (org.orcid.jaxb.model.v3.dev1.record.Service)11 Employment (org.orcid.jaxb.model.v3.dev1.record.Employment)10 InvitedPosition (org.orcid.jaxb.model.v3.dev1.record.InvitedPosition)10 Qualification (org.orcid.jaxb.model.v3.dev1.record.Qualification)10 Affiliation (org.orcid.jaxb.model.v3.dev1.record.Affiliation)8 MembershipSummary (org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary)7 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)5 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)5 OrgAffiliationRelationEntity (org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity)5 ArrayList (java.util.ArrayList)4 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