use of org.orcid.jaxb.model.record_rc2.PersonExternalIdentifier in project ORCID-Source by ORCID.
the class PublicV2ApiServiceDelegatorTest method validatePerson.
private void validatePerson(Person person) {
assertNotNull(person);
assertNotNull(person.getLastModifiedDate());
assertNotNull(person.getLastModifiedDate().getValue());
assertNotNull(person.getAddresses());
assertEquals("/0000-0000-0000-0003/address", person.getAddresses().getPath());
assertNotNull(person.getAddresses().getLastModifiedDate());
assertNotNull(person.getAddresses().getLastModifiedDate().getValue());
assertEquals(1, person.getAddresses().getAddress().size());
Address address = person.getAddresses().getAddress().get(0);
assertEquals(Iso3166Country.US, address.getCountry().getValue());
assertEquals(Visibility.PUBLIC.value(), address.getVisibility().value());
assertEquals(Long.valueOf(9), address.getPutCode());
assertEquals("/0000-0000-0000-0003/address/9", address.getPath());
assertEquals("APP-5555555555555555", address.getSource().retrieveSourcePath());
assertNotNull(person.getBiography());
assertEquals(Visibility.PUBLIC.value(), person.getBiography().getVisibility().value());
assertEquals("Biography for 0000-0000-0000-0003", person.getBiography().getContent());
assertNotNull(person.getBiography().getLastModifiedDate());
assertNotNull(person.getBiography().getLastModifiedDate().getValue());
assertEquals("/0000-0000-0000-0003/biography", person.getBiography().getPath());
assertNotNull(person.getEmails());
assertNotNull(person.getEmails().getLastModifiedDate());
assertNotNull(person.getEmails().getLastModifiedDate().getValue());
assertEquals(1, person.getEmails().getEmails().size());
Email email = person.getEmails().getEmails().get(0);
assertEquals("public_0000-0000-0000-0003@test.orcid.org", email.getEmail());
assertNotNull(email.getLastModifiedDate());
assertNotNull(email.getLastModifiedDate().getValue());
assertEquals("APP-5555555555555555", email.getSource().retrieveSourcePath());
assertEquals(Visibility.PUBLIC.value(), email.getVisibility().value());
assertNotNull(person.getExternalIdentifiers());
assertNotNull(person.getExternalIdentifiers().getLastModifiedDate());
assertNotNull(person.getExternalIdentifiers().getLastModifiedDate().getValue());
assertEquals("/0000-0000-0000-0003/external-identifiers", person.getExternalIdentifiers().getPath());
assertEquals(1, person.getExternalIdentifiers().getExternalIdentifiers().size());
PersonExternalIdentifier extId = person.getExternalIdentifiers().getExternalIdentifiers().get(0);
assertNotNull(extId);
assertNotNull(extId.getLastModifiedDate());
assertNotNull(extId.getLastModifiedDate().getValue());
assertEquals(Long.valueOf(13), extId.getPutCode());
assertEquals("public_type", extId.getType());
assertNotNull(extId.getUrl());
assertEquals("http://ext-id/public_ref", extId.getUrl().getValue());
assertEquals(Visibility.PUBLIC.value(), extId.getVisibility().value());
assertEquals("/0000-0000-0000-0003/external-identifiers/13", extId.getPath());
assertEquals("APP-5555555555555555", extId.getSource().retrieveSourcePath());
assertNotNull(person.getKeywords());
assertNotNull(person.getKeywords().getLastModifiedDate());
assertNotNull(person.getKeywords().getLastModifiedDate().getValue());
assertEquals(1, person.getKeywords().getKeywords().size());
assertNotNull(person.getKeywords().getLastModifiedDate());
assertEquals("/0000-0000-0000-0003/keywords", person.getKeywords().getPath());
Keyword keyword = person.getKeywords().getKeywords().get(0);
assertNotNull(keyword);
assertNotNull(keyword.getLastModifiedDate());
assertNotNull(keyword.getLastModifiedDate().getValue());
assertEquals(Long.valueOf(9), keyword.getPutCode());
assertEquals("PUBLIC", keyword.getContent());
assertEquals(Visibility.PUBLIC.value(), keyword.getVisibility().value());
assertEquals("/0000-0000-0000-0003/keywords/9", keyword.getPath());
assertEquals("APP-5555555555555555", keyword.getSource().retrieveSourcePath());
assertNotNull(person.getName());
assertNotNull(person.getName().getLastModifiedDate());
assertNotNull(person.getName().getLastModifiedDate().getValue());
assertEquals("Credit Name", person.getName().getCreditName().getContent());
assertEquals("Family Name", person.getName().getFamilyName().getContent());
assertEquals("Given Names", person.getName().getGivenNames().getContent());
assertEquals(Visibility.PUBLIC.value(), person.getName().getVisibility().value());
assertNotNull(person.getOtherNames());
assertEquals("/0000-0000-0000-0003/other-names", person.getOtherNames().getPath());
assertNotNull(person.getOtherNames().getLastModifiedDate());
assertNotNull(person.getOtherNames().getLastModifiedDate().getValue());
assertEquals(1, person.getOtherNames().getOtherNames().size());
OtherName otherName = person.getOtherNames().getOtherNames().get(0);
assertEquals("Other Name PUBLIC", otherName.getContent());
assertNotNull(otherName.getLastModifiedDate());
assertNotNull(otherName.getLastModifiedDate().getValue());
assertEquals("/0000-0000-0000-0003/other-names/13", otherName.getPath());
assertEquals(Long.valueOf(13), otherName.getPutCode());
assertEquals("APP-5555555555555555", otherName.getSource().retrieveSourcePath());
assertEquals(Visibility.PUBLIC.value(), otherName.getVisibility().value());
assertNotNull(person.getResearcherUrls());
assertEquals(1, person.getResearcherUrls().getResearcherUrls().size());
assertNotNull(person.getResearcherUrls().getLastModifiedDate());
assertNotNull(person.getResearcherUrls().getLastModifiedDate().getValue());
assertEquals("/0000-0000-0000-0003/researcher-urls", person.getResearcherUrls().getPath());
ResearcherUrl rUrl = person.getResearcherUrls().getResearcherUrls().get(0);
assertNotNull(rUrl);
assertNotNull(rUrl.getLastModifiedDate());
assertNotNull(rUrl.getLastModifiedDate().getValue());
assertNotNull(rUrl.getUrl());
assertEquals("http://www.researcherurl.com?id=13", rUrl.getUrl().getValue());
assertEquals("public_rurl", rUrl.getUrlName());
assertEquals(Visibility.PUBLIC.value(), rUrl.getVisibility().value());
assertEquals("/0000-0000-0000-0003/researcher-urls/13", rUrl.getPath());
assertEquals("APP-5555555555555555", rUrl.getSource().retrieveSourcePath());
assertEquals("/0000-0000-0000-0003/person", person.getPath());
}
use of org.orcid.jaxb.model.record_rc2.PersonExternalIdentifier in project ORCID-Source by ORCID.
the class PublicV2ApiServiceDelegatorTest method testViewExternalIdentifier.
@Test
public void testViewExternalIdentifier() {
Response response = serviceDelegator.viewExternalIdentifier(ORCID, 13L);
assertNotNull(response);
PersonExternalIdentifier extId = (PersonExternalIdentifier) response.getEntity();
assertNotNull(extId);
assertNotNull(extId.getLastModifiedDate());
assertNotNull(extId.getLastModifiedDate().getValue());
assertEquals(Long.valueOf(13), extId.getPutCode());
assertEquals("public_type", extId.getType());
assertNotNull(extId.getUrl());
assertEquals("http://ext-id/public_ref", extId.getUrl().getValue());
assertEquals(Visibility.PUBLIC.value(), extId.getVisibility().value());
assertEquals("/0000-0000-0000-0003/external-identifiers/13", extId.getPath());
assertEquals("APP-5555555555555555", extId.getSource().retrieveSourcePath());
}
use of org.orcid.jaxb.model.record_rc2.PersonExternalIdentifier in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_ExternalIdentifiersTest method testDeleteExternalIdentifierYouAreNotTheSourceOf.
@Test(expected = WrongSourceException.class)
public void testDeleteExternalIdentifierYouAreNotTheSourceOf() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4442", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
Response response = serviceDelegator.viewExternalIdentifier("4444-4444-4444-4442", 3L);
assertNotNull(response);
PersonExternalIdentifier extId = (PersonExternalIdentifier) response.getEntity();
assertNotNull(extId);
assertEquals("Facebook", extId.getType());
assertEquals("abc456", extId.getValue());
assertNotNull(extId.getUrl());
assertEquals("http://www.facebook.com/abc456", extId.getUrl().getValue());
serviceDelegator.deleteExternalIdentifier("4444-4444-4444-4442", 3L);
fail();
}
use of org.orcid.jaxb.model.record_rc2.PersonExternalIdentifier in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_ExternalIdentifiersTest method testViewPrivateExternalIdentifier.
@Test
public void testViewPrivateExternalIdentifier() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4442", ScopePathType.PERSON_READ_LIMITED);
Response response = serviceDelegator.viewExternalIdentifier("4444-4444-4444-4442", 5L);
assertNotNull(response);
PersonExternalIdentifier extId = (PersonExternalIdentifier) response.getEntity();
assertNotNull(extId);
assertEquals("/4444-4444-4444-4442/external-identifiers/5", extId.getPath());
Utils.verifyLastModified(extId.getLastModifiedDate());
assertEquals("Facebook", extId.getType());
assertEquals(Long.valueOf(5), extId.getPutCode());
assertEquals("abc012", extId.getValue());
assertNotNull(extId.getUrl());
assertEquals("http://www.facebook.com/abc012", extId.getUrl().getValue());
assertEquals(Visibility.PRIVATE, extId.getVisibility());
assertNotNull(extId.getSource());
assertEquals("APP-5555555555555555", extId.getSource().retrieveSourcePath());
assertNotNull(extId.getCreatedDate());
Utils.verifyLastModified(extId.getLastModifiedDate());
}
use of org.orcid.jaxb.model.record_rc2.PersonExternalIdentifier in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_ExternalIdentifiersTest method testReadPublicScope_ExternalIdentifiers.
@Test
public void testReadPublicScope_ExternalIdentifiers() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
// Public works
Response r = serviceDelegator.viewExternalIdentifiers(ORCID);
assertNotNull(r);
assertEquals(PersonExternalIdentifiers.class.getName(), r.getEntity().getClass().getName());
PersonExternalIdentifiers p = (PersonExternalIdentifiers) r.getEntity();
assertNotNull(p);
assertEquals("/0000-0000-0000-0003/external-identifiers", p.getPath());
Utils.verifyLastModified(p.getLastModifiedDate());
assertEquals(3, p.getExternalIdentifiers().size());
boolean found13 = false, found14 = false, found15 = false;
for (PersonExternalIdentifier element : p.getExternalIdentifiers()) {
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.viewExternalIdentifier(ORCID, 13L);
assertNotNull(r);
assertEquals(PersonExternalIdentifier.class.getName(), r.getEntity().getClass().getName());
// Limited am the source of should work
serviceDelegator.viewExternalIdentifier(ORCID, 14L);
// Limited fail
try {
serviceDelegator.viewExternalIdentifier(ORCID, 16L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
// Private am the source of should work
serviceDelegator.viewExternalIdentifier(ORCID, 15L);
// Private fail
try {
serviceDelegator.viewExternalIdentifier(ORCID, 17L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
}
Aggregations