Search in sources :

Example 36 with Employment

use of org.orcid.jaxb.model.record_v2.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 37 with Employment

use of org.orcid.jaxb.model.record_v2.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 38 with Employment

use of org.orcid.jaxb.model.record_v2.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 39 with Employment

use of org.orcid.jaxb.model.record_v2.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 40 with Employment

use of org.orcid.jaxb.model.record_v2.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)43 Employment (org.orcid.jaxb.model.record_v2.Employment)38 ClientResponse (com.sun.jersey.api.client.ClientResponse)22 Response (javax.ws.rs.core.Response)14 DBUnitTest (org.orcid.test.DBUnitTest)14 Education (org.orcid.jaxb.model.record_v2.Education)10 OtherName (org.orcid.jaxb.model.record_v2.OtherName)9 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)9 Employment (org.orcid.jaxb.model.record_rc1.Employment)8 Funding (org.orcid.jaxb.model.record_v2.Funding)8 Work (org.orcid.jaxb.model.record_v2.Work)8 ArrayList (java.util.ArrayList)6 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)6 Address (org.orcid.jaxb.model.record_v2.Address)6 Keyword (org.orcid.jaxb.model.record_v2.Keyword)6 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)6 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)5 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)5 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)5 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)5