Search in sources :

Example 36 with Membership

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

the class MemberV3ApiServiceDelegator_MembershipsTest method testViewMembershipReadPublic.

@Test
public void testViewMembershipReadPublic() {
    SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
    Response r = serviceDelegator.viewMembership(ORCID, 37L);
    Membership element = (Membership) r.getEntity();
    assertNotNull(element);
    assertEquals("/0000-0000-0000-0003/membership/37", element.getPath());
    Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
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 37 with Membership

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

the class MemberV3ApiServiceDelegator_MembershipsTest method testAddMembershipsDuplicateExternalIDs.

@Test(expected = OrcidDuplicatedActivityException.class)
public void testAddMembershipsDuplicateExternalIDs() {
    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);
    Membership membership = (Membership) Utils.getAffiliation(AffiliationType.MEMBERSHIP);
    membership.setExternalIDs(externalIDs);
    Response response = serviceDelegator.createMembership(ORCID, membership);
    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 {
        Membership duplicate = (Membership) Utils.getAffiliation(AffiliationType.MEMBERSHIP);
        duplicate.setExternalIDs(externalIDs);
        serviceDelegator.createMembership(ORCID, duplicate);
    } finally {
        serviceDelegator.deleteAffiliation(ORCID, putCode);
    }
}
Also used : Response(javax.ws.rs.core.Response) ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) Membership(org.orcid.jaxb.model.v3.dev1.record.Membership) 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 38 with Membership

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

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

the class PublicV3ApiServiceDelegatorTest method testViewMemberships.

@Test
public void testViewMemberships() {
    Response response = serviceDelegator.viewMemberships(ORCID);
    assertNotNull(response);
    Memberships memberships = (Memberships) response.getEntity();
    assertNotNull(memberships);
    assertEquals("/0000-0000-0000-0003/memberships", memberships.getPath());
    assertNotNull(memberships.getLastModifiedDate());
    assertNotNull(memberships.getLastModifiedDate().getValue());
    assertEquals(1, memberships.getSummaries().size());
    MembershipSummary membership = memberships.getSummaries().get(0);
    assertEquals(Long.valueOf(37), membership.getPutCode());
    assertNotNull(membership.getLastModifiedDate());
    assertNotNull(membership.getLastModifiedDate().getValue());
    assertEquals("/0000-0000-0000-0003/membership/37", membership.getPath());
    assertEquals("PUBLIC Department", membership.getDepartmentName());
    assertEquals(Visibility.PUBLIC.value(), membership.getVisibility().value());
    assertEquals("APP-5555555555555555", membership.getSource().retrieveSourcePath());
}
Also used : Response(javax.ws.rs.core.Response) Memberships(org.orcid.jaxb.model.v3.dev1.record.summary.Memberships) MembershipSummary(org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 40 with Membership

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

the class PublicV3ApiServiceDelegatorTest method testGetPublicMembershipUsingToken.

@Test
public void testGetPublicMembershipUsingToken() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response r = serviceDelegator.viewMembership(ORCID, 37L);
    assertNotNull(r);
    Membership e = (Membership) r.getEntity();
    assertNotNull(e);
    assertEquals(Long.valueOf(37), e.getPutCode());
    assertNotNull(e.getLastModifiedDate());
    assertNotNull(e.getLastModifiedDate().getValue());
}
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