use of org.orcid.jaxb.model.v3.dev1.record.OtherName in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_OtherNamesTest method testUpdateOtherNameLeavingVisibilityNullTest.
@Test
public void testUpdateOtherNameLeavingVisibilityNullTest() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
Response response = serviceDelegator.viewOtherName("4444-4444-4444-4443", 1L);
assertNotNull(response);
OtherName otherName = (OtherName) response.getEntity();
assertNotNull(otherName);
assertEquals(Visibility.PUBLIC, otherName.getVisibility());
otherName.setVisibility(null);
response = serviceDelegator.updateOtherName("4444-4444-4444-4443", 1L, otherName);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
otherName = (OtherName) response.getEntity();
assertNotNull(otherName);
assertEquals(Visibility.PUBLIC, otherName.getVisibility());
}
use of org.orcid.jaxb.model.v3.dev1.record.OtherName in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_OtherNamesTest method testUpdateOtherName.
@Test
public void testUpdateOtherName() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
Response response = serviceDelegator.viewOtherName("4444-4444-4444-4443", 1L);
assertNotNull(response);
OtherName otherName = (OtherName) response.getEntity();
assertNotNull(otherName);
Utils.verifyLastModified(otherName.getLastModifiedDate());
LastModifiedDate before = otherName.getLastModifiedDate();
assertEquals("Slibberdy Slabinah", otherName.getContent());
assertEquals(Visibility.PUBLIC, otherName.getVisibility());
otherName.setContent("Updated Other Name");
response = serviceDelegator.updateOtherName("4444-4444-4444-4443", 1L, otherName);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.viewOtherName("4444-4444-4444-4443", 1L);
assertNotNull(response);
OtherName updatedOtherName = (OtherName) response.getEntity();
assertNotNull(updatedOtherName);
Utils.verifyLastModified(updatedOtherName.getLastModifiedDate());
assertTrue(updatedOtherName.getLastModifiedDate().after(before));
assertEquals("Updated Other Name", updatedOtherName.getContent());
assertEquals(Visibility.PUBLIC, updatedOtherName.getVisibility());
}
use of org.orcid.jaxb.model.v3.dev1.record.OtherName in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_PersonalDetailsTest method testViewPersonalDetails.
@Test
public void testViewPersonalDetails() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.PERSON_READ_LIMITED);
Response response = serviceDelegator.viewPersonalDetails(ORCID);
assertNotNull(response);
PersonalDetails personalDetails = (PersonalDetails) response.getEntity();
assertNotNull(personalDetails);
assertEquals("/0000-0000-0000-0003/personal-details", personalDetails.getPath());
Utils.verifyLastModified(personalDetails.getLastModifiedDate());
assertNotNull(personalDetails.getBiography());
Utils.verifyLastModified(personalDetails.getBiography().getLastModifiedDate());
assertEquals("Biography for 0000-0000-0000-0003", personalDetails.getBiography().getContent());
assertEquals(Visibility.PUBLIC.value(), personalDetails.getBiography().getVisibility().value());
assertEquals("/0000-0000-0000-0003/biography", personalDetails.getBiography().getPath());
assertNotNull(personalDetails.getName());
Utils.verifyLastModified(personalDetails.getName().getLastModifiedDate());
assertNotNull(personalDetails.getName().getCreatedDate().getValue());
assertEquals("Credit Name", personalDetails.getName().getCreditName().getContent());
assertEquals("Family Name", personalDetails.getName().getFamilyName().getContent());
assertEquals("Given Names", personalDetails.getName().getGivenNames().getContent());
assertEquals(Visibility.PUBLIC.value(), personalDetails.getName().getVisibility().value());
assertNotNull(personalDetails.getOtherNames());
Utils.verifyLastModified(personalDetails.getOtherNames().getLastModifiedDate());
assertEquals(4, personalDetails.getOtherNames().getOtherNames().size());
for (OtherName otherName : personalDetails.getOtherNames().getOtherNames()) {
Utils.verifyLastModified(otherName.getLastModifiedDate());
if (otherName.getPutCode().equals(Long.valueOf(13))) {
assertEquals("Other Name PUBLIC", otherName.getContent());
assertEquals(Long.valueOf(0), otherName.getDisplayIndex());
assertEquals("/0000-0000-0000-0003/other-names/13", otherName.getPath());
assertEquals("APP-5555555555555555", otherName.getSource().retrieveSourcePath());
assertEquals(Visibility.PUBLIC.value(), otherName.getVisibility().value());
} else if (otherName.getPutCode().equals(Long.valueOf(14))) {
assertEquals("Other Name LIMITED", otherName.getContent());
assertEquals(Long.valueOf(1), otherName.getDisplayIndex());
assertEquals("/0000-0000-0000-0003/other-names/14", otherName.getPath());
assertEquals("APP-5555555555555555", otherName.getSource().retrieveSourcePath());
assertEquals(Visibility.LIMITED.value(), otherName.getVisibility().value());
} else if (otherName.getPutCode().equals(Long.valueOf(15))) {
assertEquals("Other Name PRIVATE", otherName.getContent());
assertEquals(Long.valueOf(2), otherName.getDisplayIndex());
assertEquals("/0000-0000-0000-0003/other-names/15", otherName.getPath());
assertEquals("APP-5555555555555555", otherName.getSource().retrieveSourcePath());
assertEquals(Visibility.PRIVATE.value(), otherName.getVisibility().value());
} else if (otherName.getPutCode().equals(Long.valueOf(16))) {
assertEquals("Other Name SELF LIMITED", otherName.getContent());
assertEquals(Long.valueOf(3), otherName.getDisplayIndex());
assertEquals("/0000-0000-0000-0003/other-names/16", otherName.getPath());
assertEquals("0000-0000-0000-0003", otherName.getSource().retrieveSourcePath());
assertEquals(Visibility.LIMITED.value(), otherName.getVisibility().value());
} else {
fail("Invalid put code found: " + otherName.getPutCode());
}
}
assertEquals("/0000-0000-0000-0003/other-names", personalDetails.getOtherNames().getPath());
assertEquals("/0000-0000-0000-0003/personal-details", personalDetails.getPath());
}
use of org.orcid.jaxb.model.v3.dev1.record.OtherName in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_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.v3.dev1.record.OtherName in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_ReadRecordTest 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());
}
Aggregations