use of org.orcid.jaxb.model.v3.dev1.record.Education in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegatorImpl method createEducation.
@Override
public Response createEducation(String orcid, Education education) {
orcidSecurityManager.checkClientAccessAndScopes(orcid, ScopePathType.AFFILIATIONS_CREATE, ScopePathType.AFFILIATIONS_UPDATE);
clearSource(education);
Education e = affiliationsManager.createEducationAffiliation(orcid, education, true);
sourceUtils.setSourceName(e);
try {
return Response.created(new URI(String.valueOf(e.getPutCode()))).build();
} catch (URISyntaxException ex) {
throw new RuntimeException(localeManager.resolveMessage("apiError.createeducation_response.exception"), ex);
}
}
use of org.orcid.jaxb.model.v3.dev1.record.Education in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_EducationsTest method testUpdateEducationChangingVisibilityTest.
@Test(expected = VisibilityMismatchException.class)
public void testUpdateEducationChangingVisibilityTest() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewEducation(ORCID, 20L);
assertNotNull(response);
Education education = (Education) response.getEntity();
assertNotNull(education);
assertEquals(Visibility.PUBLIC, education.getVisibility());
education.setVisibility(Visibility.PRIVATE);
response = serviceDelegator.updateEducation(ORCID, 20L, education);
fail();
}
use of org.orcid.jaxb.model.v3.dev1.record.Education in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_EducationsTest method testUpdateEducationLeavingVisibilityNullTest.
@Test
public void testUpdateEducationLeavingVisibilityNullTest() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewEducation(ORCID, 20L);
assertNotNull(response);
Education education = (Education) response.getEntity();
assertNotNull(education);
assertEquals(Visibility.PUBLIC, education.getVisibility());
education.setVisibility(null);
response = serviceDelegator.updateEducation(ORCID, 20L, education);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
education = (Education) response.getEntity();
assertNotNull(education);
assertEquals(Visibility.PUBLIC, education.getVisibility());
}
use of org.orcid.jaxb.model.v3.dev1.record.Education in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_EducationsTest method testViewEducationSummaryReadPublic.
@Test
public void testViewEducationSummaryReadPublic() {
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
Response r = serviceDelegator.viewEducationSummary(ORCID, 20L);
EducationSummary element = (EducationSummary) r.getEntity();
assertNotNull(element);
assertEquals("/0000-0000-0000-0003/education/20", element.getPath());
Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
use of org.orcid.jaxb.model.v3.dev1.record.Education in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_EducationsTest method testUpdateEducation.
@Test
public void testUpdateEducation() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewEducation(ORCID, 20L);
assertNotNull(response);
Education education = (Education) response.getEntity();
assertNotNull(education);
assertEquals("PUBLIC Department", education.getDepartmentName());
assertEquals("PUBLIC", education.getRoleTitle());
Utils.verifyLastModified(education.getLastModifiedDate());
LastModifiedDate before = education.getLastModifiedDate();
education.setDepartmentName("Updated department name");
education.setRoleTitle("The updated role title");
// disambiguated org is required in API v3
DisambiguatedOrganization disambiguatedOrg = new DisambiguatedOrganization();
disambiguatedOrg.setDisambiguatedOrganizationIdentifier("abc456");
disambiguatedOrg.setDisambiguationSource("WDB");
education.getOrganization().setDisambiguatedOrganization(disambiguatedOrg);
response = serviceDelegator.updateEducation(ORCID, 20L, education);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.viewEducation(ORCID, 20L);
assertNotNull(response);
education = (Education) response.getEntity();
assertNotNull(education);
Utils.verifyLastModified(education.getLastModifiedDate());
assertTrue(education.getLastModifiedDate().after(before));
assertEquals("Updated department name", education.getDepartmentName());
assertEquals("The updated role title", education.getRoleTitle());
// Rollback changes
education.setDepartmentName("PUBLIC Department");
education.setRoleTitle("PUBLIC");
response = serviceDelegator.updateEducation(ORCID, 20L, education);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
}
Aggregations