use of org.orcid.jaxb.model.record_v2.Keyword in project ORCID-Source by ORCID.
the class ValidateV2SamplesTest method unmarshallFromPath.
private Object unmarshallFromPath(String path, Class<?> type, String schemaPath) throws SAXException, URISyntaxException {
try (Reader reader = new InputStreamReader(getClass().getResourceAsStream(path))) {
Object obj = unmarshall(reader, type, schemaPath);
Object result = null;
if (ResearcherUrls.class.equals(type)) {
result = (ResearcherUrls) obj;
} else if (ResearcherUrl.class.equals(type)) {
result = (ResearcherUrl) obj;
} else if (PersonalDetails.class.equals(type)) {
result = (PersonalDetails) obj;
} else if (PersonExternalIdentifier.class.equals(type)) {
result = (PersonExternalIdentifier) obj;
} else if (PersonExternalIdentifiers.class.equals(type)) {
result = (PersonExternalIdentifiers) obj;
} else if (Biography.class.equals(type)) {
result = (Biography) obj;
} else if (Name.class.equals(type)) {
result = (Name) obj;
} else if (CreditName.class.equals(type)) {
result = (CreditName) obj;
} else if (OtherName.class.equals(type)) {
result = (OtherName) obj;
} else if (OtherNames.class.equals(type)) {
result = (OtherNames) obj;
} else if (Keywords.class.equals(type)) {
result = (Keywords) obj;
} else if (Keyword.class.equals(type)) {
result = (Keyword) obj;
} else if (Addresses.class.equals(type)) {
result = (Addresses) obj;
} else if (Address.class.equals(type)) {
result = (Address) obj;
} else if (Emails.class.equals(type)) {
result = (Emails) obj;
} else if (Email.class.equals(type)) {
result = (Email) obj;
} else if (Person.class.equals(type)) {
result = (Person) obj;
} else if (Deprecated.class.equals(type)) {
result = (Deprecated) obj;
} else if (Preferences.class.equals(type)) {
result = (Preferences) obj;
} else if (History.class.equals(type)) {
result = (History) obj;
} else if (Record.class.equals(type)) {
result = (Record) obj;
} else if (ActivitiesSummary.class.equals(type)) {
result = (ActivitiesSummary) obj;
} else if (Works.class.equals(type)) {
result = (Works) obj;
}
return result;
} catch (IOException e) {
throw new RuntimeException("Error reading notification from classpath", e);
}
}
use of org.orcid.jaxb.model.record_v2.Keyword in project ORCID-Source by ORCID.
the class ValidateV2SamplesTest method testMarshallKeyword.
@Test
public void testMarshallKeyword() throws JAXBException, SAXException, URISyntaxException {
Keywords object = (Keywords) unmarshallFromPath("/record_2.0/samples/read_samples/keywords-2.0.xml", Keywords.class);
marshall(object, "/record_2.0/keyword-2.0.xsd");
}
use of org.orcid.jaxb.model.record_v2.Keyword in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_GeneralTest method testOrcidProfileCreate_CAN_CRUDOnUnclaimedAccounts.
@Test
public void testOrcidProfileCreate_CAN_CRUDOnUnclaimedAccounts() {
String orcid = "0000-0000-0000-0001";
SecurityContextTestUtils.setUpSecurityContextForClientOnly();
// Test address
Response response = serviceDelegator.createAddress(orcid, Utils.getAddress());
assertNotNull(response);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
Long putCode = Utils.getPutCode(response);
response = serviceDelegator.viewAddress(orcid, putCode);
assertNotNull(response);
Address address = (Address) response.getEntity();
assertNotNull(address);
address.getCountry().setValue(Iso3166Country.ZW);
response = serviceDelegator.updateAddress(orcid, putCode, address);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.deleteAddress(orcid, putCode);
assertNotNull(response);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
// Test education
response = serviceDelegator.createEducation(orcid, Utils.getEducation());
assertNotNull(response);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
putCode = Utils.getPutCode(response);
response = serviceDelegator.viewEducation(orcid, putCode);
assertNotNull(response);
Education education = (Education) response.getEntity();
assertNotNull(education);
education.setDepartmentName("Updated department name");
response = serviceDelegator.updateEducation(orcid, putCode, education);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.deleteAffiliation(orcid, putCode);
assertNotNull(response);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
// Test employment
response = serviceDelegator.createEmployment(orcid, Utils.getEmployment());
assertNotNull(response);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
putCode = Utils.getPutCode(response);
response = serviceDelegator.viewEmployment(orcid, putCode);
assertNotNull(response);
Employment employment = (Employment) response.getEntity();
assertNotNull(employment);
employment.setDepartmentName("Updated department name");
response = serviceDelegator.updateEmployment(orcid, putCode, employment);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.deleteAffiliation(orcid, putCode);
assertNotNull(response);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
// Test external identifiers
response = serviceDelegator.createExternalIdentifier(orcid, Utils.getPersonExternalIdentifier());
assertNotNull(response);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
putCode = Utils.getPutCode(response);
response = serviceDelegator.viewExternalIdentifier(orcid, putCode);
assertNotNull(response);
PersonExternalIdentifier externalIdentifier = (PersonExternalIdentifier) response.getEntity();
assertNotNull(externalIdentifier);
response = serviceDelegator.updateExternalIdentifier(orcid, putCode, externalIdentifier);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.deleteExternalIdentifier(orcid, putCode);
assertNotNull(response);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
// Test funding
response = serviceDelegator.createFunding(orcid, Utils.getFunding());
assertNotNull(response);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
putCode = Utils.getPutCode(response);
response = serviceDelegator.viewFunding(orcid, putCode);
assertNotNull(response);
Funding funding = (Funding) response.getEntity();
assertNotNull(funding);
response = serviceDelegator.updateFunding(orcid, putCode, funding);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.deleteFunding(orcid, putCode);
assertNotNull(response);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
// Test keyword
response = serviceDelegator.createKeyword(orcid, Utils.getKeyword());
assertNotNull(response);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
putCode = Utils.getPutCode(response);
response = serviceDelegator.viewKeyword(orcid, putCode);
assertNotNull(response);
Keyword keyword = (Keyword) response.getEntity();
assertNotNull(keyword);
response = serviceDelegator.updateKeyword(orcid, putCode, keyword);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.deleteKeyword(orcid, putCode);
assertNotNull(response);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
// Test other names
response = serviceDelegator.createOtherName(orcid, Utils.getOtherName());
assertNotNull(response);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
putCode = Utils.getPutCode(response);
response = serviceDelegator.viewOtherName(orcid, putCode);
assertNotNull(response);
OtherName otherName = (OtherName) response.getEntity();
assertNotNull(otherName);
response = serviceDelegator.updateOtherName(orcid, putCode, otherName);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.deleteOtherName(orcid, putCode);
assertNotNull(response);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
// Test peer review
response = serviceDelegator.createPeerReview(orcid, Utils.getPeerReview());
assertNotNull(response);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
putCode = Utils.getPutCode(response);
response = serviceDelegator.viewPeerReview(orcid, putCode);
assertNotNull(response);
PeerReview peerReview = (PeerReview) response.getEntity();
assertNotNull(peerReview);
response = serviceDelegator.updatePeerReview(orcid, putCode, peerReview);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.deletePeerReview(orcid, putCode);
assertNotNull(response);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
// Test researcher url
response = serviceDelegator.createResearcherUrl(orcid, Utils.getResearcherUrl());
assertNotNull(response);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
putCode = Utils.getPutCode(response);
response = serviceDelegator.viewResearcherUrl(orcid, putCode);
assertNotNull(response);
ResearcherUrl rUrl = (ResearcherUrl) response.getEntity();
assertNotNull(rUrl);
response = serviceDelegator.updateResearcherUrl(orcid, putCode, rUrl);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.deleteResearcherUrl(orcid, putCode);
assertNotNull(response);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
// Test work
response = serviceDelegator.createWork(orcid, Utils.getWork("work # 1 " + System.currentTimeMillis()));
assertNotNull(response);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
putCode = Utils.getPutCode(response);
response = serviceDelegator.viewWork(orcid, putCode);
assertNotNull(response);
Work work = (Work) response.getEntity();
assertNotNull(work);
response = serviceDelegator.updateWork(orcid, putCode, work);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.deleteWork(orcid, putCode);
assertNotNull(response);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
}
use of org.orcid.jaxb.model.record_v2.Keyword in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_KeywordsTest method testUpdateKeywordLeavingVisibilityNullTest.
@Test
public void testUpdateKeywordLeavingVisibilityNullTest() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4441", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
Response response = serviceDelegator.viewKeyword("4444-4444-4444-4441", 6L);
assertNotNull(response);
Keyword keyword = (Keyword) response.getEntity();
assertNotNull(keyword);
assertEquals(Visibility.PUBLIC, keyword.getVisibility());
keyword.setVisibility(null);
response = serviceDelegator.updateKeyword("4444-4444-4444-4441", 6L, keyword);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
keyword = (Keyword) response.getEntity();
assertNotNull(keyword);
assertEquals(Visibility.PUBLIC, keyword.getVisibility());
}
use of org.orcid.jaxb.model.record_v2.Keyword in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_KeywordsTest method testReadPublicScope_Keywords.
@Test
public void testReadPublicScope_Keywords() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
// Public works
Response r = serviceDelegator.viewKeywords(ORCID);
assertNotNull(r);
assertEquals(Keywords.class.getName(), r.getEntity().getClass().getName());
Keywords k = (Keywords) r.getEntity();
assertNotNull(k);
Utils.verifyLastModified(k.getLastModifiedDate());
assertEquals(3, k.getKeywords().size());
boolean found1 = false, found2 = false, found3 = false;
for (Keyword element : k.getKeywords()) {
Utils.verifyLastModified(element.getLastModifiedDate());
if (element.getPutCode() == 9) {
found1 = true;
} else if (element.getPutCode() == 10) {
found2 = true;
} else if (element.getPutCode() == 11) {
found3 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
r = serviceDelegator.viewKeyword(ORCID, 9L);
assertNotNull(r);
assertEquals(Keyword.class.getName(), r.getEntity().getClass().getName());
// Limited where am the source of should work
serviceDelegator.viewKeyword(ORCID, 10L);
// Limited where am not the source of should fail
try {
serviceDelegator.viewKeyword(ORCID, 12L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
// Private where am the source of should work
serviceDelegator.viewKeyword(ORCID, 11L);
// Private where am not the source of should fail
try {
serviceDelegator.viewKeyword(ORCID, 13L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
}
Aggregations