Search in sources :

Example 6 with Distinction

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

the class MemberV3ApiServiceDelegator_DistinctionsTest method testUpdateDistinctionChangingVisibilityTest.

@Test(expected = VisibilityMismatchException.class)
public void testUpdateDistinctionChangingVisibilityTest() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewDistinction(ORCID, 27L);
    assertNotNull(response);
    Distinction distinction = (Distinction) response.getEntity();
    assertNotNull(distinction);
    assertEquals(Visibility.PUBLIC, distinction.getVisibility());
    distinction.setVisibility(Visibility.PRIVATE);
    response = serviceDelegator.updateDistinction(ORCID, 27L, distinction);
    fail();
}
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 7 with Distinction

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

the class MemberV3ApiServiceDelegator_DistinctionsTest method testUpdateDistinctionYouAreNotTheSourceOf.

@Test(expected = WrongSourceException.class)
public void testUpdateDistinctionYouAreNotTheSourceOf() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewDistinction(ORCID, 30L);
    assertNotNull(response);
    Distinction distinction = (Distinction) response.getEntity();
    assertNotNull(distinction);
    distinction.setDepartmentName("Updated department name");
    distinction.setRoleTitle("The updated role title");
    serviceDelegator.updateDistinction(ORCID, 30L, distinction);
    fail();
}
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 8 with Distinction

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

the class MemberV3ApiServiceDelegator_DistinctionsTest method testDeleteDistinction.

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

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

the class MemberV3ApiServiceDelegator_DistinctionsTest method testViewLimitedDistinction.

@Test
public void testViewLimitedDistinction() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response response = serviceDelegator.viewDistinction(ORCID, 30L);
    assertNotNull(response);
    Distinction distinction = (Distinction) response.getEntity();
    assertNotNull(distinction);
    Utils.verifyLastModified(distinction.getLastModifiedDate());
    assertEquals(Long.valueOf(30L), distinction.getPutCode());
    assertEquals("/0000-0000-0000-0003/distinction/30", distinction.getPath());
    assertEquals("SELF LIMITED Department", distinction.getDepartmentName());
    assertEquals(Visibility.LIMITED.value(), distinction.getVisibility().value());
}
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 10 with Distinction

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

the class PublicV3ApiServiceDelegatorTest method testViewDistinctions.

@Test
public void testViewDistinctions() {
    Response response = serviceDelegator.viewDistinctions(ORCID);
    assertNotNull(response);
    Distinctions distinctions = (Distinctions) response.getEntity();
    assertNotNull(distinctions);
    assertEquals("/0000-0000-0000-0003/distinctions", distinctions.getPath());
    assertNotNull(distinctions.getLastModifiedDate());
    assertNotNull(distinctions.getLastModifiedDate().getValue());
    assertEquals(1, distinctions.getSummaries().size());
    DistinctionSummary distinction = distinctions.getSummaries().get(0);
    assertEquals(Long.valueOf(27), distinction.getPutCode());
    assertNotNull(distinction.getLastModifiedDate());
    assertNotNull(distinction.getLastModifiedDate().getValue());
    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) 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)

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