use of org.orcid.jaxb.model.record_v2.Keywords in project ORCID-Source by ORCID.
the class ValidateV2RC2SamplesTest method testUnmarshallKeyword.
@Test
public void testUnmarshallKeyword() throws SAXException, URISyntaxException {
Keywords keywords = (Keywords) unmarshallFromPath("/record_2.0_rc2/samples/keywords-2.0_rc2.xml", Keywords.class, "/record_2.0_rc2/keyword-2.0_rc2.xsd");
assertNotNull(keywords);
assertNotNull(keywords.getKeywords());
assertEquals(2, keywords.getKeywords().size());
for (Keyword keyword : keywords.getKeywords()) {
assertThat(keyword.getContent(), anyOf(is("keyword1"), is("keyword2")));
assertThat(keyword.getPutCode(), anyOf(is(Long.valueOf(1)), is(Long.valueOf(2))));
assertEquals(Visibility.PUBLIC.value(), keyword.getVisibility().value());
assertNotNull(keyword.getCreatedDate());
assertNotNull(keyword.getLastModifiedDate());
assertNotNull(keyword.getSource());
assertEquals("8888-8888-8888-8880", keyword.getSource().retrieveSourcePath());
}
Keyword keyword = (Keyword) unmarshallFromPath("/record_2.0_rc2/samples/keyword-2.0_rc2.xml", Keyword.class);
assertNotNull(keyword);
assertEquals("keyword1", keyword.getContent());
assertEquals(Long.valueOf(1), keyword.getPutCode());
assertEquals(Visibility.PUBLIC.value(), keyword.getVisibility().value());
assertNotNull(keyword.getCreatedDate());
assertNotNull(keyword.getLastModifiedDate());
assertNotNull(keyword.getSource());
assertEquals("8888-8888-8888-8880", keyword.getSource().retrieveSourcePath());
}
use of org.orcid.jaxb.model.record_v2.Keywords in project ORCID-Source by ORCID.
the class ValidateV2RC2SamplesTest method testMarshallKeyword.
@Test
public void testMarshallKeyword() throws JAXBException, SAXException, URISyntaxException {
Keywords object = (Keywords) unmarshallFromPath("/record_2.0_rc2/samples/keywords-2.0_rc2.xml", Keywords.class);
marshall(object, "/record_2.0_rc2/keyword-2.0_rc2.xsd");
}
use of org.orcid.jaxb.model.record_v2.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_v2.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_v2.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());
}
Aggregations