use of org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_EmploymentsTest method testViewEmploymentSummaryReadPublic.
@Test
public void testViewEmploymentSummaryReadPublic() {
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
Response r = serviceDelegator.viewEmploymentSummary(ORCID, 17L);
EmploymentSummary element = (EmploymentSummary) 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.summary.EmploymentSummary 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.summary.EmploymentSummary in project ORCID-Source by ORCID.
the class PublicV3ApiServiceDelegatorTest method testViewEmployments.
@Test
public void testViewEmployments() {
Response response = serviceDelegator.viewEmployments(ORCID);
assertNotNull(response);
Employments employments = (Employments) response.getEntity();
assertNotNull(employments);
assertEquals("/0000-0000-0000-0003/employments", employments.getPath());
assertNotNull(employments.getLastModifiedDate());
assertNotNull(employments.getLastModifiedDate().getValue());
assertEquals(1, employments.getSummaries().size());
EmploymentSummary employment = employments.getSummaries().get(0);
assertEquals(Long.valueOf(17), employment.getPutCode());
assertNotNull(employment.getLastModifiedDate());
assertNotNull(employment.getLastModifiedDate().getValue());
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.v3.dev1.record.summary.EmploymentSummary in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV3Test method getEmployments.
private Employments getEmployments(Visibility... vs) {
Employments e = new Employments();
for (Visibility v : vs) {
EmploymentSummary s = new EmploymentSummary();
s.setVisibility(v);
e.getSummaries().add(s);
}
return e;
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary in project ORCID-Source by ORCID.
the class MapperFacadeFactory method getEmploymentMapperFacade.
public MapperFacade getEmploymentMapperFacade() {
MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
ClassMapBuilder<Employment, OrgAffiliationRelationEntity> classMap = mapperFactory.classMap(Employment.class, OrgAffiliationRelationEntity.class);
ClassMapBuilder<EmploymentSummary, OrgAffiliationRelationEntity> summaryClassMap = mapperFactory.classMap(EmploymentSummary.class, OrgAffiliationRelationEntity.class);
return generateMapperFacadeForAffiliation(mapperFactory, classMap, summaryClassMap);
}
Aggregations