use of org.orcid.jaxb.model.v3.dev1.record.Employment in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_EmploymentsTest method testUpdateEmployment.
@Test
public void testUpdateEmployment() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewEmployment(ORCID, 18L);
assertNotNull(response);
Employment employment = (Employment) response.getEntity();
assertNotNull(employment);
assertEquals("LIMITED Department", employment.getDepartmentName());
assertEquals("LIMITED", employment.getRoleTitle());
Utils.verifyLastModified(employment.getLastModifiedDate());
LastModifiedDate before = employment.getLastModifiedDate();
employment.setDepartmentName("Updated department name");
employment.setRoleTitle("The updated role title");
// disambiguated org is required in API v3
DisambiguatedOrganization disambiguatedOrg = new DisambiguatedOrganization();
disambiguatedOrg.setDisambiguatedOrganizationIdentifier("abc456");
disambiguatedOrg.setDisambiguationSource("WDB");
employment.getOrganization().setDisambiguatedOrganization(disambiguatedOrg);
response = serviceDelegator.updateEmployment(ORCID, 18L, employment);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.viewEmployment(ORCID, 18L);
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("LIMITED Department");
employment.setRoleTitle("LIMITED");
response = serviceDelegator.updateEmployment(ORCID, 18L, employment);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
}
use of org.orcid.jaxb.model.v3.dev1.record.Employment in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_EmploymentsTest method testViewPrivateEmployment.
@Test
public void testViewPrivateEmployment() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response response = serviceDelegator.viewEmployment(ORCID, 19L);
assertNotNull(response);
Employment employment = (Employment) response.getEntity();
assertNotNull(employment);
Utils.verifyLastModified(employment.getLastModifiedDate());
assertEquals(Long.valueOf(19L), employment.getPutCode());
assertEquals("/0000-0000-0000-0003/employment/19", employment.getPath());
assertEquals("PRIVATE Department", employment.getDepartmentName());
assertEquals(Visibility.PRIVATE.value(), employment.getVisibility().value());
}
use of org.orcid.jaxb.model.v3.dev1.record.Employment in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_EmploymentsTest method testDeleteEmployment.
@Test
public void testDeleteEmployment() {
SecurityContextTestUtils.setUpSecurityContext("0000-0000-0000-0002", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewEmployment("0000-0000-0000-0002", 1002L);
assertNotNull(response);
Employment employment = (Employment) response.getEntity();
assertNotNull(employment);
response = serviceDelegator.deleteAffiliation("0000-0000-0000-0002", 1002L);
assertNotNull(response);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
try {
serviceDelegator.viewEmployment("0000-0000-0000-0002", 1002L);
fail();
} catch (NoResultException nre) {
} catch (Exception e) {
fail();
}
}
use of org.orcid.jaxb.model.v3.dev1.record.Employment in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_GeneralTest method testOrcidProfileCreate_CAN_CRUDOnUnclaimedAccounts.
@Test
public void testOrcidProfileCreate_CAN_CRUDOnUnclaimedAccounts() {
String orcid = "0000-0000-0000-0001";
SecurityContextTestUtils.setUpSecurityContextForClientOnly();
// Test address
Response response = serviceDelegator.createAddress(orcid, Utils.getAddress());
assertNotNull(response);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
Long putCode = Utils.getPutCode(response);
response = serviceDelegator.viewAddress(orcid, putCode);
assertNotNull(response);
Address address = (Address) response.getEntity();
assertNotNull(address);
address.getCountry().setValue(Iso3166Country.ZW);
response = serviceDelegator.updateAddress(orcid, putCode, address);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.deleteAddress(orcid, putCode);
assertNotNull(response);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
// Test education
Education education = (Education) Utils.getAffiliation(AffiliationType.EDUCATION);
response = serviceDelegator.createEducation(orcid, education);
assertNotNull(response);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
putCode = Utils.getPutCode(response);
response = serviceDelegator.viewEducation(orcid, putCode);
assertNotNull(response);
education = (Education) response.getEntity();
assertNotNull(education);
education.setDepartmentName("Updated department name");
response = serviceDelegator.updateEducation(orcid, putCode, education);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.deleteAffiliation(orcid, putCode);
assertNotNull(response);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
// Test employment
response = serviceDelegator.createEmployment(orcid, (Employment) Utils.getAffiliation(AffiliationType.EMPLOYMENT));
assertNotNull(response);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
putCode = Utils.getPutCode(response);
response = serviceDelegator.viewEmployment(orcid, putCode);
assertNotNull(response);
Employment employment = (Employment) response.getEntity();
assertNotNull(employment);
employment.setDepartmentName("Updated department name");
response = serviceDelegator.updateEmployment(orcid, putCode, employment);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.deleteAffiliation(orcid, putCode);
assertNotNull(response);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
// Test external identifiers
response = serviceDelegator.createExternalIdentifier(orcid, Utils.getPersonExternalIdentifier());
assertNotNull(response);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
putCode = Utils.getPutCode(response);
response = serviceDelegator.viewExternalIdentifier(orcid, putCode);
assertNotNull(response);
PersonExternalIdentifier externalIdentifier = (PersonExternalIdentifier) response.getEntity();
assertNotNull(externalIdentifier);
response = serviceDelegator.updateExternalIdentifier(orcid, putCode, externalIdentifier);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.deleteExternalIdentifier(orcid, putCode);
assertNotNull(response);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
// Test funding
response = serviceDelegator.createFunding(orcid, Utils.getFunding());
assertNotNull(response);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
putCode = Utils.getPutCode(response);
response = serviceDelegator.viewFunding(orcid, putCode);
assertNotNull(response);
Funding funding = (Funding) response.getEntity();
assertNotNull(funding);
response = serviceDelegator.updateFunding(orcid, putCode, funding);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.deleteFunding(orcid, putCode);
assertNotNull(response);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
// Test keyword
response = serviceDelegator.createKeyword(orcid, Utils.getKeyword());
assertNotNull(response);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
putCode = Utils.getPutCode(response);
response = serviceDelegator.viewKeyword(orcid, putCode);
assertNotNull(response);
Keyword keyword = (Keyword) response.getEntity();
assertNotNull(keyword);
response = serviceDelegator.updateKeyword(orcid, putCode, keyword);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.deleteKeyword(orcid, putCode);
assertNotNull(response);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
// Test other names
response = serviceDelegator.createOtherName(orcid, Utils.getOtherName());
assertNotNull(response);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
putCode = Utils.getPutCode(response);
response = serviceDelegator.viewOtherName(orcid, putCode);
assertNotNull(response);
OtherName otherName = (OtherName) response.getEntity();
assertNotNull(otherName);
response = serviceDelegator.updateOtherName(orcid, putCode, otherName);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.deleteOtherName(orcid, putCode);
assertNotNull(response);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
// Test peer review
response = serviceDelegator.createPeerReview(orcid, Utils.getPeerReview());
assertNotNull(response);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
putCode = Utils.getPutCode(response);
response = serviceDelegator.viewPeerReview(orcid, putCode);
assertNotNull(response);
PeerReview peerReview = (PeerReview) response.getEntity();
assertNotNull(peerReview);
response = serviceDelegator.updatePeerReview(orcid, putCode, peerReview);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.deletePeerReview(orcid, putCode);
assertNotNull(response);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
// Test researcher url
response = serviceDelegator.createResearcherUrl(orcid, Utils.getResearcherUrl());
assertNotNull(response);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
putCode = Utils.getPutCode(response);
response = serviceDelegator.viewResearcherUrl(orcid, putCode);
assertNotNull(response);
ResearcherUrl rUrl = (ResearcherUrl) response.getEntity();
assertNotNull(rUrl);
response = serviceDelegator.updateResearcherUrl(orcid, putCode, rUrl);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.deleteResearcherUrl(orcid, putCode);
assertNotNull(response);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
// Test work
response = serviceDelegator.createWork(orcid, Utils.getWork("work # 1 " + System.currentTimeMillis()));
assertNotNull(response);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
putCode = Utils.getPutCode(response);
response = serviceDelegator.viewWork(orcid, putCode);
assertNotNull(response);
Work work = (Work) response.getEntity();
assertNotNull(work);
response = serviceDelegator.updateWork(orcid, putCode, work);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.deleteWork(orcid, putCode);
assertNotNull(response);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
}
use of org.orcid.jaxb.model.v3.dev1.record.Employment in project ORCID-Source by ORCID.
the class PublicV3ApiServiceDelegatorTest method testGetPublicEmploymentUsingToken.
// Employment
@Test
public void testGetPublicEmploymentUsingToken() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response r = serviceDelegator.viewEmployment(ORCID, 17L);
assertNotNull(r);
Employment e = (Employment) r.getEntity();
assertNotNull(e);
assertEquals(Long.valueOf(17), e.getPutCode());
assertNotNull(e.getLastModifiedDate());
assertNotNull(e.getLastModifiedDate().getValue());
}
Aggregations