use of org.orcid.jaxb.model.v3.dev1.record.Employment in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_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.v3.dev1.record.Employment in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_EmploymentsTest method testAddEmploymentNoStartDate.
@Test(expected = OrcidValidationException.class)
public void testAddEmploymentNoStartDate() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Employment employment = (Employment) Utils.getAffiliation(AffiliationType.EMPLOYMENT);
employment.setStartDate(null);
serviceDelegator.createEmployment(ORCID, employment);
}
use of org.orcid.jaxb.model.v3.dev1.record.Employment in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_EmploymentsTest method testAddEmployment.
@Test
public void testAddEmployment() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewActivities(ORCID);
assertNotNull(response);
ActivitiesSummary summary = (ActivitiesSummary) response.getEntity();
assertNotNull(summary);
assertNotNull(summary.getEmployments());
assertNotNull(summary.getEmployments().getSummaries());
assertNotNull(summary.getEmployments().getSummaries().get(0));
assertEquals(4, summary.getEmployments().getSummaries().size());
response = serviceDelegator.createEmployment(ORCID, (Employment) Utils.getAffiliation(AffiliationType.EMPLOYMENT));
assertNotNull(response);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
Map<?, ?> map = response.getMetadata();
assertNotNull(map);
assertTrue(map.containsKey("Location"));
List<?> resultWithPutCode = (List<?>) map.get("Location");
Long putCode = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
response = serviceDelegator.viewActivities(ORCID);
assertNotNull(response);
ActivitiesSummary summaryWithNewElement = (ActivitiesSummary) response.getEntity();
assertNotNull(summaryWithNewElement);
Utils.verifyLastModified(summaryWithNewElement.getLastModifiedDate());
assertNotNull(summaryWithNewElement.getEmployments());
Utils.verifyLastModified(summaryWithNewElement.getEmployments().getLastModifiedDate());
assertNotNull(summaryWithNewElement.getEmployments().getSummaries());
assertEquals(5, summaryWithNewElement.getEmployments().getSummaries().size());
boolean haveNew = false;
for (EmploymentSummary eSummary : summaryWithNewElement.getEmployments().getSummaries()) {
assertNotNull(eSummary.getPutCode());
Utils.verifyLastModified(eSummary.getLastModifiedDate());
if (eSummary.getPutCode().equals(putCode)) {
assertEquals("My department name", eSummary.getDepartmentName());
haveNew = true;
} else {
assertTrue(summary.getEmployments().getSummaries().contains(eSummary));
}
}
assertTrue(haveNew);
// Delete new element
serviceDelegator.deleteAffiliation(ORCID, putCode);
}
use of org.orcid.jaxb.model.v3.dev1.record.Employment in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_EmploymentsTest method testUpdateEmploymentYouAreNotTheSourceOf.
@Test(expected = WrongSourceException.class)
public void testUpdateEmploymentYouAreNotTheSourceOf() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewEmployment(ORCID, 23L);
assertNotNull(response);
Employment employment = (Employment) response.getEntity();
assertNotNull(employment);
employment.setDepartmentName("Updated department name");
employment.setRoleTitle("The updated role title");
serviceDelegator.updateEmployment(ORCID, 23L, employment);
fail();
}
use of org.orcid.jaxb.model.v3.dev1.record.Employment in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_EmploymentsTest method testUpdateEmploymentLeavingVisibilityNullTest.
@Test
public void testUpdateEmploymentLeavingVisibilityNullTest() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewEmployment(ORCID, 19L);
assertNotNull(response);
Employment employment = (Employment) response.getEntity();
assertNotNull(employment);
assertEquals(Visibility.PRIVATE, employment.getVisibility());
employment.setVisibility(null);
response = serviceDelegator.updateEmployment(ORCID, 19L, employment);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
employment = (Employment) response.getEntity();
assertNotNull(employment);
assertEquals(Visibility.PRIVATE, employment.getVisibility());
}
Aggregations