Search in sources :

Example 36 with Employment

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

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

use of org.orcid.jaxb.model.record_rc4.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)

Example 39 with Employment

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

the class JpaJaxbEmploymentAdapterTest method testToOrgAffiliationRelationEntity.

@Test
public void testToOrgAffiliationRelationEntity() throws JAXBException {
    Employment e = getEmployment(true);
    assertNotNull(e);
    OrgAffiliationRelationEntity oar = jpaJaxbEmploymentAdapter.toOrgAffiliationRelationEntity(e);
    assertNotNull(oar);
    //General info
    assertEquals(Long.valueOf(0), oar.getId());
    assertEquals(Visibility.PRIVATE.value(), oar.getVisibility().value());
    assertEquals("employment:department-name", oar.getDepartment());
    assertEquals("employment:role-title", oar.getTitle());
    //Dates
    assertEquals(Integer.valueOf(2), oar.getStartDate().getDay());
    assertEquals(Integer.valueOf(2), oar.getStartDate().getMonth());
    assertEquals(Integer.valueOf(1848), oar.getStartDate().getYear());
    assertEquals(Integer.valueOf(2), oar.getEndDate().getDay());
    assertEquals(Integer.valueOf(2), oar.getEndDate().getMonth());
    assertEquals(Integer.valueOf(1848), oar.getEndDate().getYear());
    //Source                
    assertNull(oar.getSourceId());
    assertNull(oar.getClientSourceId());
    assertNull(oar.getElementSourceId());
}
Also used : Employment(org.orcid.jaxb.model.record_v2.Employment) OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity) Test(org.junit.Test)

Example 40 with Employment

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

the class ActivityValidatorTest method validateEmployment_validEmploymentTest.

/**
     * VALIDATE AFFILIATIONS
     * */
@Test
public void validateEmployment_validEmploymentTest() {
    Employment employment = getEmployment();
    activityValidator.validateEmployment(employment, null, true, true, Visibility.PUBLIC);
}
Also used : Employment(org.orcid.jaxb.model.record_v2.Employment) 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 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 OrcidError (org.orcid.jaxb.model.error_rc1.OrcidError)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