use of org.orcid.jaxb.model.record_v2.ResearcherUrls in project ORCID-Source by ORCID.
the class ValidateV2SamplesTest method testUnmarshallResearcherUrl.
@Test
public void testUnmarshallResearcherUrl() throws SAXException, URISyntaxException {
ResearcherUrls rUrls = (ResearcherUrls) unmarshallFromPath("/record_2.0/samples/read_samples/researcher-urls-2.0.xml", ResearcherUrls.class, "/record_2.0/researcher-url-2.0.xsd");
assertNotNull(rUrls);
assertNotNull(rUrls.getResearcherUrls());
assertEquals(1, rUrls.getResearcherUrls().size());
assertNotNull(rUrls.getResearcherUrls().get(0).getCreatedDate());
assertNotNull(rUrls.getResearcherUrls().get(0).getLastModifiedDate());
assertEquals("Site # 1", rUrls.getResearcherUrls().get(0).getUrlName());
assertEquals("http://site1.com/", rUrls.getResearcherUrls().get(0).getUrl().getValue());
assertEquals(Long.valueOf(1248), rUrls.getResearcherUrls().get(0).getPutCode());
assertEquals(Visibility.PUBLIC.value(), rUrls.getResearcherUrls().get(0).getVisibility().value());
assertNotNull(rUrls.getResearcherUrls().get(0).getSource());
assertEquals("http://www.orcid.org/8888-8888-8888-8880", rUrls.getResearcherUrls().get(0).getSource().retriveSourceUri());
assertEquals("8888-8888-8888-8880", rUrls.getResearcherUrls().get(0).getSource().retrieveSourcePath());
ResearcherUrl rUrl = (ResearcherUrl) unmarshallFromPath("/record_2.0/samples/read_samples/researcher-url-2.0.xml", ResearcherUrl.class);
assertNotNull(rUrl);
assertEquals("Site # 1", rUrl.getUrlName());
assertNotNull(rUrl.getUrl());
assertEquals("http://site1.com/", rUrl.getUrl().getValue());
assertNotNull(rUrl.getCreatedDate());
assertNotNull(rUrl.getLastModifiedDate());
assertNotNull(rUrl.getSource());
assertEquals("8888-8888-8888-8880", rUrl.getSource().retrieveSourcePath());
}
use of org.orcid.jaxb.model.record_v2.ResearcherUrls in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV2Test method filterResearcherUrlsTest.
@Test
public void filterResearcherUrlsTest() {
ResearcherUrls x = getResearcherUrlsElement(Visibility.PUBLIC, Visibility.PUBLIC, Visibility.PUBLIC);
assertEquals(3, x.getResearcherUrls().size());
publicAPISecurityManagerV2.filter(x);
assertEquals(3, x.getResearcherUrls().size());
assertAllArePublic(x.getResearcherUrls());
x = getResearcherUrlsElement(Visibility.PUBLIC, Visibility.PUBLIC, Visibility.LIMITED);
assertEquals(3, x.getResearcherUrls().size());
publicAPISecurityManagerV2.filter(x);
assertEquals(2, x.getResearcherUrls().size());
assertAllArePublic(x.getResearcherUrls());
x = getResearcherUrlsElement(Visibility.PUBLIC, Visibility.LIMITED, Visibility.PRIVATE);
assertEquals(3, x.getResearcherUrls().size());
publicAPISecurityManagerV2.filter(x);
assertEquals(1, x.getResearcherUrls().size());
assertAllArePublic(x.getResearcherUrls());
x = getResearcherUrlsElement(Visibility.PRIVATE, Visibility.LIMITED, Visibility.PRIVATE);
assertEquals(3, x.getResearcherUrls().size());
publicAPISecurityManagerV2.filter(x);
assertTrue(x.getResearcherUrls().isEmpty());
}
use of org.orcid.jaxb.model.record_v2.ResearcherUrls in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_ReadPersonTest method testPerson.
private void testPerson(Person p, String orcid) {
// This is more an utility that will work only for 0000-0000-0000-0003
assertEquals("0000-0000-0000-0003", orcid);
assertNotNull(p);
assertEquals("/0000-0000-0000-0003/person", p.getPath());
Utils.verifyLastModified(p.getLastModifiedDate());
// Address
assertNotNull(p.getAddresses());
Addresses a = p.getAddresses();
assertNotNull(a);
Utils.verifyLastModified(a.getLastModifiedDate());
assertEquals(3, a.getAddress().size());
boolean found1 = false, found2 = false, found3 = false;
for (Address element : a.getAddress()) {
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);
// Biography
assertNotNull(p.getBiography());
Biography b = p.getBiography();
assertNotNull(b);
Utils.verifyLastModified(b.getLastModifiedDate());
assertEquals("Biography for 0000-0000-0000-0003", b.getContent());
// Email
assertNotNull(p.getEmails());
Emails email = p.getEmails();
assertNotNull(email);
Utils.verifyLastModified(email.getLastModifiedDate());
assertEquals(3, email.getEmails().size());
assertEquals("public_0000-0000-0000-0003@test.orcid.org", email.getEmails().get(0).getEmail());
found1 = false;
found2 = false;
found3 = false;
for (Email element : email.getEmails()) {
if (element.getEmail().equals("public_0000-0000-0000-0003@test.orcid.org")) {
found1 = true;
} else if (element.getEmail().equals("limited_0000-0000-0000-0003@test.orcid.org")) {
found2 = true;
} else if (element.getEmail().equals("private_0000-0000-0000-0003@test.orcid.org")) {
found3 = true;
} else {
fail("Invalid email " + element.getEmail());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
// External identifiers
assertNotNull(p.getExternalIdentifiers());
PersonExternalIdentifiers extIds = p.getExternalIdentifiers();
assertNotNull(extIds);
Utils.verifyLastModified(extIds.getLastModifiedDate());
assertEquals(3, extIds.getExternalIdentifiers().size());
found1 = false;
found2 = false;
found3 = false;
for (PersonExternalIdentifier element : extIds.getExternalIdentifiers()) {
Utils.verifyLastModified(element.getLastModifiedDate());
if (element.getPutCode() == 13) {
found1 = true;
} else if (element.getPutCode() == 14) {
found2 = true;
} else if (element.getPutCode() == 15) {
found3 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
// Keywords
assertNotNull(p.getKeywords());
Keywords k = p.getKeywords();
assertNotNull(k);
Utils.verifyLastModified(k.getLastModifiedDate());
assertEquals(3, k.getKeywords().size());
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);
// Name
assertNotNull(p.getName());
assertEquals("Credit Name", p.getName().getCreditName().getContent());
assertEquals("Given Names", p.getName().getGivenNames().getContent());
assertEquals("Family Name", p.getName().getFamilyName().getContent());
// Other names
assertNotNull(p.getOtherNames());
OtherNames o = p.getOtherNames();
assertNotNull(o);
Utils.verifyLastModified(o.getLastModifiedDate());
assertEquals(3, o.getOtherNames().size());
found1 = false;
found2 = false;
found3 = false;
for (OtherName element : o.getOtherNames()) {
Utils.verifyLastModified(element.getLastModifiedDate());
if (element.getPutCode() == 13) {
found1 = true;
} else if (element.getPutCode() == 14) {
found2 = true;
} else if (element.getPutCode() == 15) {
found3 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
// Researcher urls
assertNotNull(p.getResearcherUrls());
ResearcherUrls ru = p.getResearcherUrls();
assertNotNull(ru);
Utils.verifyLastModified(ru.getLastModifiedDate());
assertEquals(3, ru.getResearcherUrls().size());
found1 = false;
found2 = false;
found3 = false;
for (ResearcherUrl element : ru.getResearcherUrls()) {
Utils.verifyLastModified(element.getLastModifiedDate());
if (element.getPutCode() == 13) {
found1 = true;
} else if (element.getPutCode() == 14) {
found2 = true;
} else if (element.getPutCode() == 15) {
found3 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
assertNotNull(p.getPath());
}
use of org.orcid.jaxb.model.record_v2.ResearcherUrls in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_ResearcherUrlsTest method testReadPublicScope_ResearcherUrls.
@Test
public void testReadPublicScope_ResearcherUrls() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
// Public works
Response r = serviceDelegator.viewResearcherUrls(ORCID);
assertNotNull(r);
ResearcherUrls ru = (ResearcherUrls) r.getEntity();
assertNotNull(ru);
assertEquals("/0000-0000-0000-0003/researcher-urls", ru.getPath());
Utils.verifyLastModified(ru.getLastModifiedDate());
assertEquals(3, ru.getResearcherUrls().size());
boolean found13 = false, found14 = false, found15 = false;
for (ResearcherUrl element : ru.getResearcherUrls()) {
if (element.getPutCode() == 13) {
found13 = true;
} else if (element.getPutCode() == 14) {
found14 = true;
} else if (element.getPutCode() == 15) {
found15 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found13);
assertTrue(found14);
assertTrue(found15);
r = serviceDelegator.viewResearcherUrl(ORCID, 13L);
assertNotNull(r);
assertEquals(ResearcherUrl.class.getName(), r.getEntity().getClass().getName());
// Limited am the source of should work
serviceDelegator.viewResearcherUrl(ORCID, 14L);
// Limited am not the source of should fail
try {
serviceDelegator.viewResearcherUrl(ORCID, 16L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
// Private am the source of should work
serviceDelegator.viewResearcherUrl(ORCID, 15L);
// Private am not the source of should fail
try {
serviceDelegator.viewResearcherUrl(ORCID, 17L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
}
use of org.orcid.jaxb.model.record_v2.ResearcherUrls in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_ResearcherUrlsTest method testViewResearcherUrlsReadPublic.
@Test
public void testViewResearcherUrlsReadPublic() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
Response r = serviceDelegator.viewResearcherUrls(ORCID);
ResearcherUrls elements = (ResearcherUrls) r.getEntity();
assertNotNull(elements);
assertEquals("/0000-0000-0000-0003/researcher-urls", elements.getPath());
for (ResearcherUrl element : elements.getResearcherUrls()) {
if (!element.retrieveSourcePath().equals("APP-5555555555555555") && !Visibility.PUBLIC.equals(element.getVisibility())) {
fail("Element " + element.getPutCode() + " is not source of APP-5555555555555555 and is not public");
}
}
}
Aggregations