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());
}
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());
}
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());
}
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");
}
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);
}
Aggregations