use of org.orcid.jaxb.model.v3.dev1.record.Distinction in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_DistinctionsTest method testViewPrivateDistinction.
@Test
public void testViewPrivateDistinction() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response response = serviceDelegator.viewDistinction(ORCID, 29L);
assertNotNull(response);
Distinction distinction = (Distinction) response.getEntity();
assertNotNull(distinction);
Utils.verifyLastModified(distinction.getLastModifiedDate());
assertEquals(Long.valueOf(29L), distinction.getPutCode());
assertEquals("/0000-0000-0000-0003/distinction/29", distinction.getPath());
assertEquals("PRIVATE Department", distinction.getDepartmentName());
assertEquals(Visibility.PRIVATE.value(), distinction.getVisibility().value());
}
use of org.orcid.jaxb.model.v3.dev1.record.Distinction in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_DistinctionsTest method testViewPublicDistinction.
@Test
public void testViewPublicDistinction() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response response = serviceDelegator.viewDistinction(ORCID, 27L);
assertNotNull(response);
Distinction distinction = (Distinction) response.getEntity();
assertNotNull(distinction);
Utils.verifyLastModified(distinction.getLastModifiedDate());
assertEquals(Long.valueOf(27L), distinction.getPutCode());
assertEquals("/0000-0000-0000-0003/distinction/27", distinction.getPath());
assertEquals("PUBLIC Department", distinction.getDepartmentName());
assertEquals(Visibility.PUBLIC.value(), distinction.getVisibility().value());
}
use of org.orcid.jaxb.model.v3.dev1.record.Distinction in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_DistinctionsTest method testViewDistinctionReadPublic.
@Test
public void testViewDistinctionReadPublic() {
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
Response r = serviceDelegator.viewDistinction(ORCID, 27L);
Distinction element = (Distinction) r.getEntity();
assertNotNull(element);
assertEquals("/0000-0000-0000-0003/distinction/27", element.getPath());
Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
use of org.orcid.jaxb.model.v3.dev1.record.Distinction in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_DistinctionsTest method testUpdateDistinctionDuplicateExternalIDs.
@Test(expected = OrcidDuplicatedActivityException.class)
public void testUpdateDistinctionDuplicateExternalIDs() {
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);
Distinction distinction = (Distinction) Utils.getAffiliation(AffiliationType.DISTINCTION);
distinction.setExternalIDs(externalIDs);
Response response = serviceDelegator.createDistinction(ORCID, distinction);
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)));
Distinction another = (Distinction) Utils.getAffiliation(AffiliationType.DISTINCTION);
response = serviceDelegator.createDistinction(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.viewDistinction(ORCID, putCode2);
another = (Distinction) response.getEntity();
another.setExternalIDs(externalIDs);
try {
serviceDelegator.updateDistinction(ORCID, putCode2, another);
} finally {
serviceDelegator.deleteAffiliation(ORCID, putCode1);
serviceDelegator.deleteAffiliation(ORCID, putCode2);
}
}
use of org.orcid.jaxb.model.v3.dev1.record.Distinction in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_DistinctionsTest method testAddDistinction.
@Test
public void testAddDistinction() {
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.getDistinctions());
Utils.verifyLastModified(originalSummary.getDistinctions().getLastModifiedDate());
assertNotNull(originalSummary.getDistinctions().getSummaries());
assertNotNull(originalSummary.getDistinctions().getSummaries().get(0));
Utils.verifyLastModified(originalSummary.getDistinctions().getSummaries().get(0).getLastModifiedDate());
assertEquals(4, originalSummary.getDistinctions().getSummaries().size());
response = serviceDelegator.createDistinction(ORCID, (Distinction) Utils.getAffiliation(AffiliationType.DISTINCTION));
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.getDistinctions());
Utils.verifyLastModified(summaryWithNewElement.getDistinctions().getLastModifiedDate());
assertNotNull(summaryWithNewElement.getDistinctions().getSummaries());
assertEquals(5, summaryWithNewElement.getDistinctions().getSummaries().size());
boolean haveNew = false;
for (DistinctionSummary distinctionSummary : summaryWithNewElement.getDistinctions().getSummaries()) {
assertNotNull(distinctionSummary.getPutCode());
Utils.verifyLastModified(distinctionSummary.getLastModifiedDate());
if (distinctionSummary.getPutCode().equals(putCode)) {
assertEquals("My department name", distinctionSummary.getDepartmentName());
haveNew = true;
} else {
assertTrue(originalSummary.getDistinctions().getSummaries().contains(distinctionSummary));
}
}
assertTrue(haveNew);
// Remove new element
serviceDelegator.deleteAffiliation(ORCID, putCode);
}
Aggregations