Skip to content

Commit

Permalink
Merge pull request #6848 from ORCID/FixNPEOnNameCheck
Browse files Browse the repository at this point in the history
Check the source of the element based on the source ids and not the name
  • Loading branch information
leomendoza123 authored Aug 4, 2023
2 parents ddcb438 + 4375c86 commit 0a882a5
Show file tree
Hide file tree
Showing 23 changed files with 397 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -403,15 +403,19 @@ public void testReadPublicScope_ExternalIdentifiers() {
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;
assertEquals(5, p.getExternalIdentifiers().size());
boolean found13 = false, found14 = false, found15 = false, found18 = false, found19 = 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 if (element.getPutCode() == 18) {
found18 = true;
} else if (element.getPutCode() == 19) {
found19 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
Expand All @@ -420,6 +424,8 @@ public void testReadPublicScope_ExternalIdentifiers() {
assertTrue(found13);
assertTrue(found14);
assertTrue(found15);
assertTrue(found18);
assertTrue(found19);

r = serviceDelegator.viewExternalIdentifier(ORCID, 13L);
assertNotNull(r);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void testViewPerson() {
Utils.verifyLastModified(a.getLastModifiedDate());
assertEquals(4, a.getAddress().size());

boolean found1 = false, found2 = false, found3 = false, found4 = false;
boolean found1 = false, found2 = false, found3 = false, found4 = false, found5 = false, found6 = false;
for (Address element : a.getAddress()) {
Utils.verifyLastModified(element.getLastModifiedDate());
if (element.getPutCode() == 9) {
Expand Down Expand Up @@ -180,11 +180,13 @@ public void testViewPerson() {
PersonExternalIdentifiers extIds = p.getExternalIdentifiers();
assertNotNull(extIds);
Utils.verifyLastModified(extIds.getLastModifiedDate());
assertEquals(4, extIds.getExternalIdentifiers().size());
assertEquals(6, extIds.getExternalIdentifiers().size());
found1 = false;
found2 = false;
found3 = false;
found4 = false;
found5 = false;
found6 = false;

for (PersonExternalIdentifier element : extIds.getExternalIdentifiers()) {
Utils.verifyLastModified(element.getLastModifiedDate());
Expand All @@ -196,6 +198,10 @@ public void testViewPerson() {
found3 = true;
} else if (element.getPutCode() == 16) {
found4 = true;
} else if (element.getPutCode() == 18) {
found5 = true;
} else if (element.getPutCode() == 19) {
found6 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
Expand All @@ -205,6 +211,8 @@ public void testViewPerson() {
assertTrue(found2);
assertTrue(found3);
assertTrue(found4);
assertTrue(found5);
assertTrue(found6);

// Keywords
assertNotNull(p.getKeywords());
Expand Down Expand Up @@ -318,7 +326,7 @@ private void testPerson(Person p, String orcid) {
Utils.verifyLastModified(a.getLastModifiedDate());
assertEquals(3, a.getAddress().size());

boolean found1 = false, found2 = false, found3 = false;
boolean found1 = false, found2 = false, found3 = false, found4 = false, found5 = false;
for (Address element : a.getAddress()) {
Utils.verifyLastModified(element.getLastModifiedDate());
if (element.getPutCode() == 9) {
Expand Down Expand Up @@ -377,10 +385,12 @@ private void testPerson(Person p, String orcid) {
PersonExternalIdentifiers extIds = p.getExternalIdentifiers();
assertNotNull(extIds);
Utils.verifyLastModified(extIds.getLastModifiedDate());
assertEquals(3, extIds.getExternalIdentifiers().size());
assertEquals(5, extIds.getExternalIdentifiers().size());
found1 = false;
found2 = false;
found3 = false;
found4 = false;
found5 = false;
for (PersonExternalIdentifier element : extIds.getExternalIdentifiers()) {
Utils.verifyLastModified(element.getLastModifiedDate());
if (element.getPutCode() == 13) {
Expand All @@ -389,6 +399,10 @@ private void testPerson(Person p, String orcid) {
found2 = true;
} else if (element.getPutCode() == 15) {
found3 = true;
} else if (element.getPutCode() == 18) {
found4 = true;
} else if (element.getPutCode() == 19) {
found5 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
Expand All @@ -397,6 +411,8 @@ private void testPerson(Person p, String orcid) {
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
assertTrue(found4);
assertTrue(found5);

// Keywords
assertNotNull(p.getKeywords());
Expand Down Expand Up @@ -580,9 +596,13 @@ private void assertAllPublicButEmails(Person p) {
PersonExternalIdentifiers extIds = p.getExternalIdentifiers();
assertNotNull(extIds);
Utils.verifyLastModified(extIds.getLastModifiedDate());
assertEquals(1, extIds.getExternalIdentifiers().size());
assertEquals(Long.valueOf(13), extIds.getExternalIdentifiers().get(0).getPutCode());
assertEquals(3, extIds.getExternalIdentifiers().size());
assertEquals(Long.valueOf(19), extIds.getExternalIdentifiers().get(0).getPutCode());
assertEquals(Visibility.PUBLIC, extIds.getExternalIdentifiers().get(0).getVisibility());
assertEquals(Long.valueOf(18), extIds.getExternalIdentifiers().get(1).getPutCode());
assertEquals(Visibility.PUBLIC, extIds.getExternalIdentifiers().get(1).getVisibility());
assertEquals(Long.valueOf(13), extIds.getExternalIdentifiers().get(2).getPutCode());
assertEquals(Visibility.PUBLIC, extIds.getExternalIdentifiers().get(2).getVisibility());

// Keywords
assertNotNull(p.getKeywords());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public void testViewRecord() {
assertNotNull(person.getExternalIdentifiers());
Utils.verifyLastModified(person.getExternalIdentifiers().getLastModifiedDate());
assertEquals("/0000-0000-0000-0003/external-identifiers", person.getExternalIdentifiers().getPath());
assertEquals(4, person.getExternalIdentifiers().getExternalIdentifiers().size());
assertEquals(6, person.getExternalIdentifiers().getExternalIdentifiers().size());
for (PersonExternalIdentifier extId : person.getExternalIdentifiers().getExternalIdentifiers()) {
Utils.verifyLastModified(extId.getLastModifiedDate());
if (extId.getPutCode().equals(Long.valueOf(13))) {
Expand Down Expand Up @@ -282,6 +282,22 @@ public void testViewRecord() {
assertEquals("http://ext-id/self/limited", extId.getUrl().getValue());
assertEquals("self_limited_ref", extId.getValue());
assertEquals(Visibility.LIMITED.value(), extId.getVisibility().value());
} else if (extId.getPutCode().equals(Long.valueOf(18))) {
assertEquals(Long.valueOf(5), extId.getDisplayIndex());
assertEquals("/0000-0000-0000-0003/external-identifiers/18", extId.getPath());
assertEquals("0000-0000-0000-0003", extId.getSource().retrieveSourcePath());
assertEquals("self_public_type", extId.getType());
assertEquals("http://ext-id/self/public", extId.getUrl().getValue());
assertEquals("self_public_ref", extId.getValue());
assertEquals(Visibility.PUBLIC.value(), extId.getVisibility().value());
} else if (extId.getPutCode().equals(Long.valueOf(19))) {
assertEquals(Long.valueOf(6), extId.getDisplayIndex());
assertEquals("/0000-0000-0000-0003/external-identifiers/19", extId.getPath());
assertEquals("APP-5555555555555558", extId.getSource().retrieveSourcePath());
assertEquals("self_public_user_obo_type", extId.getType());
assertEquals("http://ext-id/self/obo/public", extId.getUrl().getValue());
assertEquals("self_public_user_obo_ref", extId.getValue());
assertEquals(Visibility.PUBLIC.value(), extId.getVisibility().value());
} else {
fail("Invalid external identifier found: " + extId.getPutCode());
}
Expand Down Expand Up @@ -796,7 +812,7 @@ private void testPerson(Person p, String orcid) {
Utils.verifyLastModified(a.getLastModifiedDate());
assertEquals(3, a.getAddress().size());

boolean found1 = false, found2 = false, found3 = false;
boolean found1 = false, found2 = false, found3 = false, found4 = false, found5 = false;
for (Address element : a.getAddress()) {
Utils.verifyLastModified(element.getLastModifiedDate());
if (element.getPutCode() == 9) {
Expand Down Expand Up @@ -855,10 +871,12 @@ private void testPerson(Person p, String orcid) {
PersonExternalIdentifiers extIds = p.getExternalIdentifiers();
assertNotNull(extIds);
Utils.verifyLastModified(extIds.getLastModifiedDate());
assertEquals(3, extIds.getExternalIdentifiers().size());
assertEquals(5, extIds.getExternalIdentifiers().size());
found1 = false;
found2 = false;
found3 = false;
found4 = false;
found5 = false;
for (PersonExternalIdentifier element : extIds.getExternalIdentifiers()) {
Utils.verifyLastModified(element.getLastModifiedDate());
if (element.getPutCode() == 13) {
Expand All @@ -867,6 +885,10 @@ private void testPerson(Person p, String orcid) {
found2 = true;
} else if (element.getPutCode() == 15) {
found3 = true;
} else if (element.getPutCode() == 18) {
found4 = true;
} else if (element.getPutCode() == 19) {
found5 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
Expand All @@ -875,6 +897,8 @@ private void testPerson(Person p, String orcid) {
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
assertTrue(found4);
assertTrue(found5);

// Keywords
assertNotNull(p.getKeywords());
Expand Down Expand Up @@ -1062,9 +1086,13 @@ private void assertAllPublicButEmails(Person p) {
PersonExternalIdentifiers extIds = p.getExternalIdentifiers();
assertNotNull(extIds);
Utils.verifyLastModified(extIds.getLastModifiedDate());
assertEquals(1, extIds.getExternalIdentifiers().size());
assertEquals(Long.valueOf(13), extIds.getExternalIdentifiers().get(0).getPutCode());
assertEquals(3, extIds.getExternalIdentifiers().size());
assertEquals(Long.valueOf(19), extIds.getExternalIdentifiers().get(0).getPutCode());
assertEquals(Visibility.PUBLIC, extIds.getExternalIdentifiers().get(0).getVisibility());
assertEquals(Long.valueOf(18), extIds.getExternalIdentifiers().get(1).getPutCode());
assertEquals(Visibility.PUBLIC, extIds.getExternalIdentifiers().get(1).getVisibility());
assertEquals(Long.valueOf(13), extIds.getExternalIdentifiers().get(2).getPutCode());
assertEquals(Visibility.PUBLIC, extIds.getExternalIdentifiers().get(2).getVisibility());

// Keywords
assertNotNull(p.getKeywords());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,15 +409,19 @@ public void testReadPublicScope_ExternalIdentifiers() {
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;
assertEquals(5, p.getExternalIdentifiers().size());
boolean found13 = false, found14 = false, found15 = false, found18 = false, found19 = 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 if (element.getPutCode() == 18) {
found18 = true;
} else if (element.getPutCode() == 19) {
found19 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
Expand All @@ -426,6 +430,8 @@ public void testReadPublicScope_ExternalIdentifiers() {
assertTrue(found13);
assertTrue(found14);
assertTrue(found15);
assertTrue(found18);
assertTrue(found19);

r = serviceDelegator.viewExternalIdentifier(ORCID, 13L);
assertNotNull(r);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void testViewPerson() {
Utils.verifyLastModified(a.getLastModifiedDate());
assertEquals(4, a.getAddress().size());

boolean found1 = false, found2 = false, found3 = false, found4 = false;
boolean found1 = false, found2 = false, found3 = false, found4 = false, found5 = false, found6 = false;
for (Address element : a.getAddress()) {
Utils.verifyLastModified(element.getLastModifiedDate());
if (element.getPutCode() == 9) {
Expand Down Expand Up @@ -186,11 +186,13 @@ public void testViewPerson() {
PersonExternalIdentifiers extIds = p.getExternalIdentifiers();
assertNotNull(extIds);
Utils.verifyLastModified(extIds.getLastModifiedDate());
assertEquals(4, extIds.getExternalIdentifiers().size());
assertEquals(6, extIds.getExternalIdentifiers().size());
found1 = false;
found2 = false;
found3 = false;
found4 = false;
found5 = false;
found6 = false;

for (PersonExternalIdentifier element : extIds.getExternalIdentifiers()) {
Utils.verifyLastModified(element.getLastModifiedDate());
Expand All @@ -202,6 +204,10 @@ public void testViewPerson() {
found3 = true;
} else if (element.getPutCode() == 16) {
found4 = true;
} else if (element.getPutCode() == 18) {
found5 = true;
} else if (element.getPutCode() == 19) {
found6 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
Expand All @@ -211,6 +217,8 @@ public void testViewPerson() {
assertTrue(found2);
assertTrue(found3);
assertTrue(found4);
assertTrue(found5);
assertTrue(found6);

// Keywords
assertNotNull(p.getKeywords());
Expand Down Expand Up @@ -324,7 +332,7 @@ private void testPerson(Person p, String orcid) {
Utils.verifyLastModified(a.getLastModifiedDate());
assertEquals(3, a.getAddress().size());

boolean found1 = false, found2 = false, found3 = false;
boolean found1 = false, found2 = false, found3 = false, found4 = false, found5 = false;
for (Address element : a.getAddress()) {
Utils.verifyLastModified(element.getLastModifiedDate());
if (element.getPutCode() == 9) {
Expand Down Expand Up @@ -383,10 +391,12 @@ private void testPerson(Person p, String orcid) {
PersonExternalIdentifiers extIds = p.getExternalIdentifiers();
assertNotNull(extIds);
Utils.verifyLastModified(extIds.getLastModifiedDate());
assertEquals(3, extIds.getExternalIdentifiers().size());
assertEquals(5, extIds.getExternalIdentifiers().size());
found1 = false;
found2 = false;
found3 = false;
found4 = false;
found5 = false;
for (PersonExternalIdentifier element : extIds.getExternalIdentifiers()) {
Utils.verifyLastModified(element.getLastModifiedDate());
if (element.getPutCode() == 13) {
Expand All @@ -395,6 +405,10 @@ private void testPerson(Person p, String orcid) {
found2 = true;
} else if (element.getPutCode() == 15) {
found3 = true;
} else if (element.getPutCode() == 18) {
found4 = true;
} else if (element.getPutCode() == 19) {
found5 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
Expand All @@ -403,6 +417,8 @@ private void testPerson(Person p, String orcid) {
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
assertTrue(found4);
assertTrue(found5);

// Keywords
assertNotNull(p.getKeywords());
Expand Down Expand Up @@ -586,9 +602,13 @@ private void assertAllPublicButEmails(Person p) {
PersonExternalIdentifiers extIds = p.getExternalIdentifiers();
assertNotNull(extIds);
Utils.verifyLastModified(extIds.getLastModifiedDate());
assertEquals(1, extIds.getExternalIdentifiers().size());
assertEquals(Long.valueOf(13), extIds.getExternalIdentifiers().get(0).getPutCode());
assertEquals(3, extIds.getExternalIdentifiers().size());
assertEquals(Long.valueOf(19), extIds.getExternalIdentifiers().get(0).getPutCode());
assertEquals(Visibility.PUBLIC, extIds.getExternalIdentifiers().get(0).getVisibility());
assertEquals(Long.valueOf(18), extIds.getExternalIdentifiers().get(1).getPutCode());
assertEquals(Visibility.PUBLIC, extIds.getExternalIdentifiers().get(1).getVisibility());
assertEquals(Long.valueOf(13), extIds.getExternalIdentifiers().get(2).getPutCode());
assertEquals(Visibility.PUBLIC, extIds.getExternalIdentifiers().get(2).getVisibility());

// Keywords
assertNotNull(p.getKeywords());
Expand Down
Loading

0 comments on commit 0a882a5

Please sign in to comment.