Search in sources :

Example 21 with Employment

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

the class PublicV2ApiServiceDelegatorTest method testViewEmployment.

@Test
public void testViewEmployment() {
    Response response = serviceDelegator.viewEmployment(ORCID, 17L);
    assertNotNull(response);
    Employment employment = (Employment) response.getEntity();
    assertNotNull(employment);
    assertNotNull(employment.getLastModifiedDate());
    assertNotNull(employment.getLastModifiedDate().getValue());
    assertEquals(Long.valueOf(17), employment.getPutCode());
    assertEquals("/0000-0000-0000-0003/employment/17", employment.getPath());
    assertEquals("PUBLIC Department", employment.getDepartmentName());
    assertEquals(Visibility.PUBLIC.value(), employment.getVisibility().value());
    assertEquals("APP-5555555555555555", employment.getSource().retrieveSourcePath());
}
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 22 with Employment

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

the class MemberV2ApiServiceDelegator_EmploymentsTest method testUpdateEmployment.

@Test
public void testUpdateEmployment() {
    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("Employment Dept # 1", employment.getDepartmentName());
    assertEquals("Researcher", employment.getRoleTitle());
    Utils.verifyLastModified(employment.getLastModifiedDate());
    LastModifiedDate before = employment.getLastModifiedDate();
    employment.setDepartmentName("Updated department name");
    employment.setRoleTitle("The updated role title");
    response = serviceDelegator.updateEmployment("4444-4444-4444-4446", 5L, employment);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewEmployment("4444-4444-4444-4446", 5L);
    assertNotNull(response);
    employment = (Employment) response.getEntity();
    assertNotNull(employment);
    Utils.verifyLastModified(employment.getLastModifiedDate());
    assertTrue(employment.getLastModifiedDate().after(before));
    assertEquals("Updated department name", employment.getDepartmentName());
    assertEquals("The updated role title", employment.getRoleTitle());
    // Rollback changes
    employment.setDepartmentName("Employment Dept # 1");
    employment.setRoleTitle("Researcher");
    response = serviceDelegator.updateEmployment("4444-4444-4444-4446", 5L, employment);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) Employment(org.orcid.jaxb.model.record_v2.Employment) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 23 with Employment

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

the class MemberV2ApiServiceDelegator_EmploymentsTest method testViewPrivateEmployment.

@Test
public void testViewPrivateEmployment() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.READ_LIMITED);
    Response response = serviceDelegator.viewEmployment("4444-4444-4444-4446", 5L);
    assertNotNull(response);
    Employment employment = (Employment) response.getEntity();
    assertNotNull(employment);
    Utils.verifyLastModified(employment.getLastModifiedDate());
    assertEquals(Long.valueOf(5L), employment.getPutCode());
    assertEquals("/4444-4444-4444-4446/employment/5", employment.getPath());
    assertEquals("Employment Dept # 1", employment.getDepartmentName());
    assertEquals(Visibility.PRIVATE.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 24 with Employment

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

the class MemberV2ApiServiceDelegator_EmploymentsTest method testViewEmploymentReadPublic.

@Test
public void testViewEmploymentReadPublic() {
    SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
    Response r = serviceDelegator.viewEmployment(ORCID, 17L);
    Employment element = (Employment) r.getEntity();
    assertNotNull(element);
    assertEquals("/0000-0000-0000-0003/employment/17", element.getPath());
    Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
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 25 with Employment

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

the class JpaJaxbEmploymentAdapterTest method getEmployment.

private Employment getEmployment(boolean full) throws JAXBException {
    JAXBContext context = JAXBContext.newInstance(new Class[] { Employment.class });
    Unmarshaller unmarshaller = context.createUnmarshaller();
    String name = "/record_2.0/samples/read_samples/employment-2.0.xml";
    if (full) {
        name = "/record_2.0/samples/read_samples/employment-full-2.0.xml";
    }
    InputStream inputStream = getClass().getResourceAsStream(name);
    return (Employment) unmarshaller.unmarshal(inputStream);
}
Also used : Employment(org.orcid.jaxb.model.record_v2.Employment) InputStream(java.io.InputStream) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller)

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