use of org.orcid.jaxb.model.v3.dev1.record.Qualification in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_QualificationsTest method testDeleteQualification.
@Test
public void testDeleteQualification() {
SecurityContextTestUtils.setUpSecurityContext("0000-0000-0000-0002", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewQualification("0000-0000-0000-0002", 1005L);
assertNotNull(response);
Qualification qualification = (Qualification) response.getEntity();
assertNotNull(qualification);
response = serviceDelegator.deleteAffiliation("0000-0000-0000-0002", 1005L);
assertNotNull(response);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
try {
serviceDelegator.viewQualification("0000-0000-0000-0002", 1005L);
fail();
} catch (NoResultException nre) {
} catch (Exception e) {
fail();
}
}
use of org.orcid.jaxb.model.v3.dev1.record.Qualification in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_QualificationsTest method testUpdateQualificationYouAreNotTheSourceOf.
@Test(expected = WrongSourceException.class)
public void testUpdateQualificationYouAreNotTheSourceOf() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewQualification(ORCID, 45L);
assertNotNull(response);
Qualification qualification = (Qualification) response.getEntity();
assertNotNull(qualification);
qualification.setDepartmentName("Updated department name");
qualification.setRoleTitle("The updated role title");
serviceDelegator.updateQualification(ORCID, 45L, qualification);
fail();
}
use of org.orcid.jaxb.model.v3.dev1.record.Qualification in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_QualificationsTest method testViewQualificationReadPublic.
@Test
public void testViewQualificationReadPublic() {
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
Response r = serviceDelegator.viewQualification(ORCID, 42L);
Qualification element = (Qualification) r.getEntity();
assertNotNull(element);
assertEquals("/0000-0000-0000-0003/qualification/42", element.getPath());
Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
use of org.orcid.jaxb.model.v3.dev1.record.Qualification in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_QualificationsTest method testAddQualification.
@Test
public void testAddQualification() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewActivities(ORCID);
assertNotNull(response);
ActivitiesSummary originalSummary = (ActivitiesSummary) response.getEntity();
assertNotNull(originalSummary);
Utils.verifyLastModified(originalSummary.getLastModifiedDate());
assertNotNull(originalSummary.getQualifications());
Utils.verifyLastModified(originalSummary.getQualifications().getLastModifiedDate());
assertNotNull(originalSummary.getQualifications().getSummaries());
assertNotNull(originalSummary.getQualifications().getSummaries().get(0));
Utils.verifyLastModified(originalSummary.getQualifications().getSummaries().get(0).getLastModifiedDate());
assertEquals(4, originalSummary.getQualifications().getSummaries().size());
response = serviceDelegator.createQualification(ORCID, (Qualification) Utils.getAffiliation(AffiliationType.QUALIFICATION));
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.getQualifications());
Utils.verifyLastModified(summaryWithNewElement.getQualifications().getLastModifiedDate());
assertNotNull(summaryWithNewElement.getQualifications().getSummaries());
assertEquals(5, summaryWithNewElement.getQualifications().getSummaries().size());
boolean haveNew = false;
for (QualificationSummary qualificationSummary : summaryWithNewElement.getQualifications().getSummaries()) {
assertNotNull(qualificationSummary.getPutCode());
Utils.verifyLastModified(qualificationSummary.getLastModifiedDate());
if (qualificationSummary.getPutCode().equals(putCode)) {
assertEquals("My department name", qualificationSummary.getDepartmentName());
haveNew = true;
} else {
assertTrue(originalSummary.getQualifications().getSummaries().contains(qualificationSummary));
}
}
assertTrue(haveNew);
// Remove new element
serviceDelegator.deleteAffiliation(ORCID, putCode);
}
use of org.orcid.jaxb.model.v3.dev1.record.Qualification in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_QualificationsTest method testUpdateQualificationChangingVisibilityTest.
@Test(expected = VisibilityMismatchException.class)
public void testUpdateQualificationChangingVisibilityTest() {
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(Visibility.LIMITED, qualification.getVisibility());
qualification.setVisibility(Visibility.PUBLIC);
response = serviceDelegator.updateQualification(ORCID, 43L, qualification);
fail();
}
Aggregations