Search in sources :

Example 51 with Employment

use of org.orcid.jaxb.model.record_rc2.Employment in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_EmploymentsTest method testUpdateEmploymentLeavingVisibilityNullTest.

@Test
public void testUpdateEmploymentLeavingVisibilityNullTest() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewEmployment("4444-4444-4444-4446", 5L);
    assertNotNull(response);
    Employment employment = (Employment) response.getEntity();
    assertNotNull(employment);
    assertEquals(Visibility.PRIVATE, employment.getVisibility());
    employment.setVisibility(null);
    response = serviceDelegator.updateEmployment("4444-4444-4444-4446", 5L, employment);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    employment = (Employment) response.getEntity();
    assertNotNull(employment);
    assertEquals(Visibility.PRIVATE, employment.getVisibility());
}
Also used : Response(javax.ws.rs.core.Response) Employment(org.orcid.jaxb.model.record_v2.Employment) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 52 with Employment

use of org.orcid.jaxb.model.record_rc2.Employment in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_EmploymentsTest method testViewLimitedEmployment.

@Test
public void testViewLimitedEmployment() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.READ_LIMITED);
    Response response = serviceDelegator.viewEmployment("4444-4444-4444-4446", 11L);
    assertNotNull(response);
    Employment employment = (Employment) response.getEntity();
    assertNotNull(employment);
    Utils.verifyLastModified(employment.getLastModifiedDate());
    assertEquals(Long.valueOf(11L), employment.getPutCode());
    assertEquals("/4444-4444-4444-4446/employment/11", employment.getPath());
    assertEquals("Employment Dept # 4", employment.getDepartmentName());
    assertEquals(Visibility.LIMITED.value(), employment.getVisibility().value());
}
Also used : Response(javax.ws.rs.core.Response) Employment(org.orcid.jaxb.model.record_v2.Employment) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 53 with Employment

use of org.orcid.jaxb.model.record_rc2.Employment in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_EmploymentsTest method testDeleteEmployment.

@Test(expected = NoResultException.class)
public void testDeleteEmployment() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4444", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewEmployment("4444-4444-4444-4444", 14L);
    assertNotNull(response);
    Employment employment = (Employment) response.getEntity();
    assertNotNull(employment);
    response = serviceDelegator.deleteAffiliation("4444-4444-4444-4444", 14L);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    serviceDelegator.viewEmployment("4444-4444-4444-4444", 14L);
}
Also used : Response(javax.ws.rs.core.Response) Employment(org.orcid.jaxb.model.record_v2.Employment) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 54 with Employment

use of org.orcid.jaxb.model.record_rc2.Employment in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_EmploymentsTest method testUpdateEmploymentChangingVisibilityTest.

@Test(expected = VisibilityMismatchException.class)
public void testUpdateEmploymentChangingVisibilityTest() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewEmployment("4444-4444-4444-4446", 5L);
    assertNotNull(response);
    Employment employment = (Employment) response.getEntity();
    assertNotNull(employment);
    assertEquals(Visibility.PRIVATE, employment.getVisibility());
    employment.setVisibility(Visibility.LIMITED);
    response = serviceDelegator.updateEmployment("4444-4444-4444-4446", 5L, employment);
    fail();
}
Also used : Response(javax.ws.rs.core.Response) Employment(org.orcid.jaxb.model.record_v2.Employment) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 55 with Employment

use of org.orcid.jaxb.model.record_rc2.Employment in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_EmploymentsTest method testUpdateEmploymentYouAreNotTheSourceOf.

@Test(expected = WrongSourceException.class)
public void testUpdateEmploymentYouAreNotTheSourceOf() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewEmployment("4444-4444-4444-4446", 11L);
    assertNotNull(response);
    Employment employment = (Employment) response.getEntity();
    assertNotNull(employment);
    employment.setDepartmentName("Updated department name");
    employment.setRoleTitle("The updated role title");
    serviceDelegator.updateEmployment("4444-4444-4444-4446", 11L, employment);
    fail();
}
Also used : Response(javax.ws.rs.core.Response) Employment(org.orcid.jaxb.model.record_v2.Employment) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)41 Employment (org.orcid.jaxb.model.record_v2.Employment)38 ClientResponse (com.sun.jersey.api.client.ClientResponse)22 Response (javax.ws.rs.core.Response)13 DBUnitTest (org.orcid.test.DBUnitTest)13 Employment (org.orcid.jaxb.model.record_rc1.Employment)8 ArrayList (java.util.ArrayList)6 Education (org.orcid.jaxb.model.record_v2.Education)6 OrcidError (org.orcid.jaxb.model.error_rc1.OrcidError)4 Funding (org.orcid.jaxb.model.record_v2.Funding)4 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)4 Work (org.orcid.jaxb.model.record_v2.Work)4 Day (org.orcid.jaxb.model.common_v2.Day)3 Month (org.orcid.jaxb.model.common_v2.Month)3 Year (org.orcid.jaxb.model.common_v2.Year)3 Address (org.orcid.jaxb.model.record_v2.Address)3 Keyword (org.orcid.jaxb.model.record_v2.Keyword)3 OtherName (org.orcid.jaxb.model.record_v2.OtherName)3 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)3 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)3