use of org.orcid.jaxb.model.record_rc2.Employment in project ORCID-Source by ORCID.
the class JpaJaxbEmploymentAdapterTest method testToOrgAffiliationRelationEntity.
@Test
public void testToOrgAffiliationRelationEntity() throws JAXBException {
Employment e = getEmployment(true);
assertNotNull(e);
OrgAffiliationRelationEntity oar = jpaJaxbEmploymentAdapter.toOrgAffiliationRelationEntity(e);
assertNotNull(oar);
//General info
assertEquals(Long.valueOf(0), oar.getId());
assertEquals(Visibility.PRIVATE.value(), oar.getVisibility().value());
assertEquals("employment:department-name", oar.getDepartment());
assertEquals("employment:role-title", oar.getTitle());
//Dates
assertEquals(Integer.valueOf(2), oar.getStartDate().getDay());
assertEquals(Integer.valueOf(2), oar.getStartDate().getMonth());
assertEquals(Integer.valueOf(1848), oar.getStartDate().getYear());
assertEquals(Integer.valueOf(2), oar.getEndDate().getDay());
assertEquals(Integer.valueOf(2), oar.getEndDate().getMonth());
assertEquals(Integer.valueOf(1848), oar.getEndDate().getYear());
//Source
assertNull(oar.getSourceId());
assertNull(oar.getClientSourceId());
assertNull(oar.getElementSourceId());
}
use of org.orcid.jaxb.model.record_rc2.Employment in project ORCID-Source by ORCID.
the class ActivityValidatorTest method validateEmployment_validEmploymentTest.
/**
* VALIDATE AFFILIATIONS
* */
@Test
public void validateEmployment_validEmploymentTest() {
Employment employment = getEmployment();
activityValidator.validateEmployment(employment, null, true, true, Visibility.PUBLIC);
}
use of org.orcid.jaxb.model.record_rc2.Employment in project ORCID-Source by ORCID.
the class ActivityValidatorTest method validateEmployment_dontChangeVisibilityTest.
@Test(expected = VisibilityMismatchException.class)
public void validateEmployment_dontChangeVisibilityTest() {
Employment employment = getEmployment();
employment.setVisibility(Visibility.LIMITED);
activityValidator.validateEmployment(employment, null, false, true, Visibility.PUBLIC);
}
use of org.orcid.jaxb.model.record_rc2.Employment in project ORCID-Source by ORCID.
the class MemberV2_1Test method testUpdateEmploymentWithProfileCreationTokenWhenClaimedAndNotSource.
@Test
public void testUpdateEmploymentWithProfileCreationTokenWhenClaimedAndNotSource() throws JSONException, InterruptedException, URISyntaxException {
Employment employment = (Employment) unmarshallFromPath("/record_2.1/samples/read_samples/employment-2.1.xml", Employment.class);
employment.setPutCode(null);
employment.setVisibility(Visibility.PUBLIC);
String accessToken = getAccessToken();
ClientResponse postResponse = memberV2_1ApiClient.createEmploymentXml(this.getUser1OrcidId(), employment, accessToken);
assertNotNull(postResponse);
assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
String locationPath = postResponse.getLocation().getPath();
assertTrue("Location header path should match pattern, but was " + locationPath, locationPath.matches(".*/v2.1/" + this.getUser1OrcidId() + "/employment/\\d+"));
ClientResponse getResponse = memberV2_1ApiClient.viewLocationXml(postResponse.getLocation(), accessToken);
assertEquals(Response.Status.OK.getStatusCode(), getResponse.getStatus());
Employment gotEmployment = getResponse.getEntity(Employment.class);
assertEquals("employment:department-name", gotEmployment.getDepartmentName());
assertEquals("employment:role-title", gotEmployment.getRoleTitle());
gotEmployment.setDepartmentName("updated dept. name");
gotEmployment.setRoleTitle("updated role title");
String profileCreateToken = oauthHelper.getClientCredentialsAccessToken(this.getClient2ClientId(), this.getClient2ClientSecret(), ScopePathType.ORCID_PROFILE_CREATE);
ClientResponse putResponse = memberV2_1ApiClient.updateLocationXml(postResponse.getLocation(), profileCreateToken, gotEmployment);
assertEquals(Response.Status.FORBIDDEN.getStatusCode(), putResponse.getStatus());
ClientResponse getAfterUpdateResponse = memberV2_1ApiClient.viewLocationXml(postResponse.getLocation(), accessToken);
assertEquals(Response.Status.OK.getStatusCode(), getAfterUpdateResponse.getStatus());
Employment gotAfterUpdateEmployment = getAfterUpdateResponse.getEntity(Employment.class);
assertEquals("employment:department-name", gotAfterUpdateEmployment.getDepartmentName());
assertEquals("employment:role-title", gotAfterUpdateEmployment.getRoleTitle());
ClientResponse deleteResponse = memberV2_1ApiClient.deleteEmploymentXml(this.getUser1OrcidId(), gotEmployment.getPutCode(), accessToken);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
}
use of org.orcid.jaxb.model.record_rc2.Employment in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_EmploymentsTest method testViewEmployment.
@Test
public void testViewEmployment() {
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());
}
Aggregations