use of org.orcid.jaxb.model.record_rc2.Keywords in project ORCID-Source by ORCID.
the class ValidateV2RC2SamplesTest 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;
}
return result;
} catch (IOException e) {
throw new RuntimeException("Error reading notification from classpath", e);
}
}
use of org.orcid.jaxb.model.record_rc2.Keywords in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV2Test method getKeywordsElement.
private Keywords getKeywordsElement(Visibility... vs) {
Keywords elements = new Keywords();
for (Visibility v : vs) {
Keyword element = new Keyword();
element.setVisibility(v);
if (elements.getKeywords() == null) {
elements.setKeywords(new ArrayList<Keyword>());
}
elements.getKeywords().add(element);
}
return elements;
}
use of org.orcid.jaxb.model.record_rc2.Keywords 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();
}
}
use of org.orcid.jaxb.model.record_rc2.Keywords in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_KeywordsTest method testDeleteKeyword.
@Test
public void testDeleteKeyword() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4499", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
Response response = serviceDelegator.viewKeywords("4444-4444-4444-4499");
assertNotNull(response);
Keywords keywords = (Keywords) response.getEntity();
assertNotNull(keywords);
assertNotNull(keywords.getKeywords());
assertEquals(1, keywords.getKeywords().size());
response = serviceDelegator.deleteKeyword("4444-4444-4444-4499", 8L);
assertNotNull(response);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
response = serviceDelegator.viewKeywords("4444-4444-4444-4499");
assertNotNull(response);
keywords = (Keywords) response.getEntity();
assertNotNull(keywords);
assertNotNull(keywords.getKeywords());
assertTrue(keywords.getKeywords().isEmpty());
}
use of org.orcid.jaxb.model.record_rc2.Keywords in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_KeywordsTest method testViewKeywords.
@Test
public void testViewKeywords() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.PERSON_READ_LIMITED);
Response response = serviceDelegator.viewKeywords("4444-4444-4444-4443");
assertNotNull(response);
Keywords keywords = (Keywords) response.getEntity();
assertNotNull(keywords);
assertEquals("/4444-4444-4444-4443/keywords", keywords.getPath());
Utils.verifyLastModified(keywords.getLastModifiedDate());
assertNotNull(keywords.getKeywords());
assertEquals(3, keywords.getKeywords().size());
for (Keyword keyword : keywords.getKeywords()) {
Utils.verifyLastModified(keyword.getLastModifiedDate());
assertThat(keyword.getPutCode(), anyOf(is(1L), is(2L), is(4L)));
assertThat(keyword.getContent(), anyOf(is("tea making"), is("coffee making"), is("what else can we make?")));
if (keyword.getPutCode() == 1L) {
assertEquals(Visibility.PUBLIC, keyword.getVisibility());
assertEquals("APP-5555555555555555", keyword.getSource().retrieveSourcePath());
} else if (keyword.getPutCode() == 2L) {
assertEquals(Visibility.LIMITED, keyword.getVisibility());
assertEquals("4444-4444-4444-4443", keyword.getSource().retrieveSourcePath());
} else {
assertEquals(Visibility.PRIVATE, keyword.getVisibility());
assertEquals("APP-5555555555555555", keyword.getSource().retrieveSourcePath());
}
}
}
Aggregations