use of org.orcid.jaxb.model.v3.dev1.record.Qualification in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_QualificationsTest method testUpdateQualification.
@Test
public void testUpdateQualification() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewQualification(ORCID, 43L);
assertNotNull(response);
Qualification qualification = (Qualification) response.getEntity();
assertNotNull(qualification);
assertEquals("LIMITED Department", qualification.getDepartmentName());
assertEquals("LIMITED", qualification.getRoleTitle());
Utils.verifyLastModified(qualification.getLastModifiedDate());
LastModifiedDate before = qualification.getLastModifiedDate();
qualification.setDepartmentName("Updated department name");
qualification.setRoleTitle("The updated role title");
// disambiguated org is required in API v3
DisambiguatedOrganization disambiguatedOrg = new DisambiguatedOrganization();
disambiguatedOrg.setDisambiguatedOrganizationIdentifier("abc456");
disambiguatedOrg.setDisambiguationSource("WDB");
qualification.getOrganization().setDisambiguatedOrganization(disambiguatedOrg);
response = serviceDelegator.updateQualification(ORCID, 43L, qualification);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.viewQualification(ORCID, 43L);
assertNotNull(response);
qualification = (Qualification) response.getEntity();
assertNotNull(qualification);
Utils.verifyLastModified(qualification.getLastModifiedDate());
assertTrue(qualification.getLastModifiedDate().after(before));
assertEquals("Updated department name", qualification.getDepartmentName());
assertEquals("The updated role title", qualification.getRoleTitle());
// Rollback changes
qualification.setDepartmentName("LIMITED Department");
qualification.setRoleTitle("QUALIFICATION");
response = serviceDelegator.updateQualification(ORCID, 43L, qualification);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
}
use of org.orcid.jaxb.model.v3.dev1.record.Qualification in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_QualificationsTest method testAddQualificationNoStartDate.
@Test(expected = OrcidValidationException.class)
public void testAddQualificationNoStartDate() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Qualification qualification = (Qualification) Utils.getAffiliation(AffiliationType.QUALIFICATION);
qualification.setStartDate(null);
serviceDelegator.createQualification(ORCID, qualification);
}
use of org.orcid.jaxb.model.v3.dev1.record.Qualification in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_QualificationsTest method testViewLimitedQualification.
@Test
public void testViewLimitedQualification() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response response = serviceDelegator.viewQualification(ORCID, 45L);
assertNotNull(response);
Qualification qualification = (Qualification) response.getEntity();
assertNotNull(qualification);
Utils.verifyLastModified(qualification.getLastModifiedDate());
assertEquals(Long.valueOf(45L), qualification.getPutCode());
assertEquals("/0000-0000-0000-0003/qualification/45", qualification.getPath());
assertEquals("SELF LIMITED Department", qualification.getDepartmentName());
assertEquals(Visibility.LIMITED.value(), qualification.getVisibility().value());
}
use of org.orcid.jaxb.model.v3.dev1.record.Qualification in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_QualificationsTest method testUpdateQualificationDuplicateExternalIDs.
@Test(expected = OrcidDuplicatedActivityException.class)
public void testUpdateQualificationDuplicateExternalIDs() {
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);
Qualification qualification = (Qualification) Utils.getAffiliation(AffiliationType.QUALIFICATION);
qualification.setExternalIDs(externalIDs);
Response response = serviceDelegator.createQualification(ORCID, qualification);
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)));
Qualification another = (Qualification) Utils.getAffiliation(AffiliationType.QUALIFICATION);
response = serviceDelegator.createQualification(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.viewQualification(ORCID, putCode2);
another = (Qualification) response.getEntity();
another.setExternalIDs(externalIDs);
try {
serviceDelegator.updateQualification(ORCID, putCode2, another);
} finally {
serviceDelegator.deleteAffiliation(ORCID, putCode1);
serviceDelegator.deleteAffiliation(ORCID, putCode2);
}
}
use of org.orcid.jaxb.model.v3.dev1.record.Qualification in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_QualificationsTest method testViewQualifications.
@Test
public void testViewQualifications() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response r = serviceDelegator.viewQualifications(ORCID);
assertNotNull(r);
Qualifications qualifications = (Qualifications) r.getEntity();
assertNotNull(qualifications);
assertEquals("/0000-0000-0000-0003/qualifications", qualifications.getPath());
Utils.verifyLastModified(qualifications.getLastModifiedDate());
assertNotNull(qualifications.getSummaries());
assertEquals(4, qualifications.getSummaries().size());
boolean found1 = false, found2 = false, found3 = false, found4 = false;
for (QualificationSummary summary : qualifications.getSummaries()) {
Utils.verifyLastModified(summary.getLastModifiedDate());
if (Long.valueOf(42).equals(summary.getPutCode())) {
assertEquals("PUBLIC Department", summary.getDepartmentName());
found1 = true;
} else if (Long.valueOf(43).equals(summary.getPutCode())) {
assertEquals("LIMITED Department", summary.getDepartmentName());
found2 = true;
} else if (Long.valueOf(44).equals(summary.getPutCode())) {
assertEquals("PRIVATE Department", summary.getDepartmentName());
found3 = true;
} else if (Long.valueOf(45).equals(summary.getPutCode())) {
assertEquals("SELF LIMITED Department", summary.getDepartmentName());
found4 = true;
} else {
fail("Invalid qualification found: " + summary.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
assertTrue(found4);
}
Aggregations