Search in sources :

Example 36 with Distinction

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

the class MemberV3ApiServiceDelegator_DistinctionsTest method testViewDistinctions.

@Test
public void testViewDistinctions() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response r = serviceDelegator.viewDistinctions(ORCID);
    assertNotNull(r);
    Distinctions distinctions = (Distinctions) r.getEntity();
    assertNotNull(distinctions);
    assertEquals("/0000-0000-0000-0003/distinctions", distinctions.getPath());
    Utils.verifyLastModified(distinctions.getLastModifiedDate());
    assertNotNull(distinctions.getSummaries());
    assertEquals(4, distinctions.getSummaries().size());
    boolean found1 = false, found2 = false, found3 = false, found4 = false;
    for (DistinctionSummary summary : distinctions.getSummaries()) {
        Utils.verifyLastModified(summary.getLastModifiedDate());
        if (Long.valueOf(27).equals(summary.getPutCode())) {
            assertEquals("PUBLIC Department", summary.getDepartmentName());
            found1 = true;
        } else if (Long.valueOf(28).equals(summary.getPutCode())) {
            assertEquals("LIMITED Department", summary.getDepartmentName());
            found2 = true;
        } else if (Long.valueOf(29).equals(summary.getPutCode())) {
            assertEquals("PRIVATE Department", summary.getDepartmentName());
            found3 = true;
        } else if (Long.valueOf(30).equals(summary.getPutCode())) {
            assertEquals("SELF LIMITED Department", summary.getDepartmentName());
            found4 = true;
        } else {
            fail("Invalid distinction found: " + summary.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
}
Also used : Response(javax.ws.rs.core.Response) DistinctionSummary(org.orcid.jaxb.model.v3.dev1.record.summary.DistinctionSummary) Distinctions(org.orcid.jaxb.model.v3.dev1.record.summary.Distinctions) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 37 with Distinction

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

the class MemberV3ApiServiceDelegator_DistinctionsTest method testAddDistinctionNoStartDate.

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

Example 38 with Distinction

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

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

the class PublicV3ApiServiceDelegatorTest method testViewDistinction.

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

Example 40 with Distinction

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

the class PublicV3ApiServiceDelegatorTest method testGetPublicDistinctionUsingToken.

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

Aggregations

Distinction (org.orcid.jaxb.model.v3.dev1.record.Distinction)41 Test (org.junit.Test)31 DBUnitTest (org.orcid.test.DBUnitTest)18 Response (javax.ws.rs.core.Response)17 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 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 DistinctionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.DistinctionSummary)7 OrgAffiliationRelationEntity (org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity)6 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)5 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)5 ArrayList (java.util.ArrayList)4 Funding (org.orcid.jaxb.model.v3.dev1.record.Funding)4 Work (org.orcid.jaxb.model.v3.dev1.record.Work)4 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)4 ClientResponse (com.sun.jersey.api.client.ClientResponse)3