use of org.orcid.jaxb.model.v3.dev1.record.Education in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_EducationsTest method testViewLimitedEducation.
@Test
public void testViewLimitedEducation() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response response = serviceDelegator.viewEducation(ORCID, 21L);
assertNotNull(response);
Education education = (Education) response.getEntity();
assertNotNull(education);
Utils.verifyLastModified(education.getLastModifiedDate());
assertEquals(Long.valueOf(21L), education.getPutCode());
assertEquals("/0000-0000-0000-0003/education/21", education.getPath());
assertEquals("LIMITED Department", education.getDepartmentName());
assertEquals(Visibility.LIMITED.value(), education.getVisibility().value());
}
use of org.orcid.jaxb.model.v3.dev1.record.Education in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_EducationsTest method testAddEducationsDuplicateExternalIDs.
@Test(expected = OrcidDuplicatedActivityException.class)
public void testAddEducationsDuplicateExternalIDs() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
ExternalID e1 = new ExternalID();
e1.setRelationship(Relationship.SELF);
e1.setType("erm");
e1.setUrl(new Url("https://orcid.org"));
e1.setValue("err");
ExternalID e2 = new ExternalID();
e2.setRelationship(Relationship.SELF);
e2.setType("err");
e2.setUrl(new Url("http://bbc.co.uk"));
e2.setValue("erm");
ExternalIDs externalIDs = new ExternalIDs();
externalIDs.getExternalIdentifier().add(e1);
externalIDs.getExternalIdentifier().add(e2);
Education education = (Education) Utils.getAffiliation(AffiliationType.EDUCATION);
education.setExternalIDs(externalIDs);
Response response = serviceDelegator.createEducation(ORCID, education);
assertNotNull(response);
assertEquals(HttpStatus.SC_CREATED, 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)));
try {
Education duplicate = (Education) Utils.getAffiliation(AffiliationType.EDUCATION);
duplicate.setExternalIDs(externalIDs);
serviceDelegator.createEducation(ORCID, duplicate);
} finally {
serviceDelegator.deleteAffiliation(ORCID, putCode);
}
}
use of org.orcid.jaxb.model.v3.dev1.record.Education in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_EducationsTest method testUpdateEducationDuplicateExternalIDs.
@Test(expected = OrcidDuplicatedActivityException.class)
public void testUpdateEducationDuplicateExternalIDs() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
ExternalID e1 = new ExternalID();
e1.setRelationship(Relationship.SELF);
e1.setType("erm");
e1.setUrl(new Url("https://orcid.org"));
e1.setValue("err");
ExternalID e2 = new ExternalID();
e2.setRelationship(Relationship.SELF);
e2.setType("err");
e2.setUrl(new Url("http://bbc.co.uk"));
e2.setValue("erm");
ExternalIDs externalIDs = new ExternalIDs();
externalIDs.getExternalIdentifier().add(e1);
externalIDs.getExternalIdentifier().add(e2);
Education education = (Education) Utils.getAffiliation(AffiliationType.EDUCATION);
education.setExternalIDs(externalIDs);
Response response = serviceDelegator.createEducation(ORCID, education);
assertNotNull(response);
assertEquals(HttpStatus.SC_CREATED, response.getStatus());
Map<?, ?> map = response.getMetadata();
assertNotNull(map);
assertTrue(map.containsKey("Location"));
List<?> resultWithPutCode = (List<?>) map.get("Location");
Long putCode1 = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
Education another = (Education) Utils.getAffiliation(AffiliationType.EDUCATION);
response = serviceDelegator.createEducation(ORCID, another);
map = response.getMetadata();
assertNotNull(map);
assertTrue(map.containsKey("Location"));
resultWithPutCode = (List<?>) map.get("Location");
Long putCode2 = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
response = serviceDelegator.viewEducation(ORCID, putCode2);
another = (Education) response.getEntity();
another.setExternalIDs(externalIDs);
try {
serviceDelegator.updateEducation(ORCID, putCode2, another);
} finally {
serviceDelegator.deleteAffiliation(ORCID, putCode1);
serviceDelegator.deleteAffiliation(ORCID, putCode2);
}
}
use of org.orcid.jaxb.model.v3.dev1.record.Education in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_EducationsTest method testViewEducations.
@Test
public void testViewEducations() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response r = serviceDelegator.viewEducations(ORCID);
assertNotNull(r);
Educations educations = (Educations) r.getEntity();
assertNotNull(educations);
assertEquals("/0000-0000-0000-0003/educations", educations.getPath());
Utils.verifyLastModified(educations.getLastModifiedDate());
assertNotNull(educations.getSummaries());
assertEquals(4, educations.getSummaries().size());
boolean found1 = false, found2 = false, found3 = false, found4 = false;
for (EducationSummary summary : educations.getSummaries()) {
Utils.verifyLastModified(summary.getLastModifiedDate());
if (Long.valueOf(20).equals(summary.getPutCode())) {
assertEquals("PUBLIC Department", summary.getDepartmentName());
found1 = true;
} else if (Long.valueOf(21).equals(summary.getPutCode())) {
assertEquals("LIMITED Department", summary.getDepartmentName());
found2 = true;
} else if (Long.valueOf(22).equals(summary.getPutCode())) {
assertEquals("PRIVATE Department", summary.getDepartmentName());
found3 = true;
} else if (Long.valueOf(25).equals(summary.getPutCode())) {
assertEquals("SELF LIMITED Department", summary.getDepartmentName());
found4 = true;
} else {
fail("Invalid education found: " + summary.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
assertTrue(found4);
}
use of org.orcid.jaxb.model.v3.dev1.record.Education in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_EducationsTest method testViewPublicEducation.
@Test
public void testViewPublicEducation() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response response = serviceDelegator.viewEducation(ORCID, 20L);
assertNotNull(response);
Education education = (Education) response.getEntity();
assertNotNull(education);
Utils.verifyLastModified(education.getLastModifiedDate());
assertEquals(Long.valueOf(20L), education.getPutCode());
assertEquals("/0000-0000-0000-0003/education/20", education.getPath());
assertEquals("PUBLIC Department", education.getDepartmentName());
assertEquals(Visibility.PUBLIC.value(), education.getVisibility().value());
}
Aggregations