Search in sources :

Example 26 with PersonExternalIdentifiers

use of org.orcid.jaxb.model.record_rc2.PersonExternalIdentifiers in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_ReadPersonTest method assertAllPublicButEmails.

private void assertAllPublicButEmails(Person p) {
    assertNotNull(p);
    Utils.verifyLastModified(p.getLastModifiedDate());
    // Address
    assertNotNull(p.getAddresses());
    Addresses a = p.getAddresses();
    assertNotNull(a);
    Utils.verifyLastModified(a.getLastModifiedDate());
    assertEquals(1, a.getAddress().size());
    assertEquals(Long.valueOf(9), a.getAddress().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC, a.getAddress().get(0).getVisibility());
    // Biography
    assertNotNull(p.getBiography());
    Biography b = p.getBiography();
    assertNotNull(b);
    Utils.verifyLastModified(b.getLastModifiedDate());
    assertEquals("Biography for 0000-0000-0000-0003", b.getContent());
    // External identifiers
    assertNotNull(p.getExternalIdentifiers());
    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(Visibility.PUBLIC, extIds.getExternalIdentifiers().get(0).getVisibility());
    // Keywords
    assertNotNull(p.getKeywords());
    Keywords k = p.getKeywords();
    assertNotNull(k);
    Utils.verifyLastModified(k.getLastModifiedDate());
    assertEquals(1, k.getKeywords().size());
    assertEquals(Long.valueOf(9), k.getKeywords().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC, k.getKeywords().get(0).getVisibility());
    // 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(1, o.getOtherNames().size());
    assertEquals(Long.valueOf(13), o.getOtherNames().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC, o.getOtherNames().get(0).getVisibility());
    // Researcher urls
    assertNotNull(p.getResearcherUrls());
    ResearcherUrls ru = p.getResearcherUrls();
    assertNotNull(ru);
    Utils.verifyLastModified(ru.getLastModifiedDate());
    assertEquals(1, ru.getResearcherUrls().size());
    assertEquals(Long.valueOf(13), ru.getResearcherUrls().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC, ru.getResearcherUrls().get(0).getVisibility());
}
Also used : Addresses(org.orcid.jaxb.model.record_v2.Addresses) Keywords(org.orcid.jaxb.model.record_v2.Keywords) PersonExternalIdentifiers(org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers) OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) Biography(org.orcid.jaxb.model.record_v2.Biography) ResearcherUrls(org.orcid.jaxb.model.record_v2.ResearcherUrls)

Example 27 with PersonExternalIdentifiers

use of org.orcid.jaxb.model.record_rc2.PersonExternalIdentifiers in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_ReadRecordTest method assertAllPublicButEmails.

private void assertAllPublicButEmails(Person p) {
    assertNotNull(p);
    Utils.verifyLastModified(p.getLastModifiedDate());
    // Address
    assertNotNull(p.getAddresses());
    Addresses a = p.getAddresses();
    assertNotNull(a);
    Utils.verifyLastModified(a.getLastModifiedDate());
    assertEquals(1, a.getAddress().size());
    assertEquals(Long.valueOf(9), a.getAddress().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC, a.getAddress().get(0).getVisibility());
    // Biography
    assertNotNull(p.getBiography());
    Biography b = p.getBiography();
    assertNotNull(b);
    Utils.verifyLastModified(b.getLastModifiedDate());
    assertEquals("Biography for 0000-0000-0000-0003", b.getContent());
    // External identifiers
    assertNotNull(p.getExternalIdentifiers());
    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(Visibility.PUBLIC, extIds.getExternalIdentifiers().get(0).getVisibility());
    // Keywords
    assertNotNull(p.getKeywords());
    Keywords k = p.getKeywords();
    assertNotNull(k);
    Utils.verifyLastModified(k.getLastModifiedDate());
    assertEquals(1, k.getKeywords().size());
    assertEquals(Long.valueOf(9), k.getKeywords().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC, k.getKeywords().get(0).getVisibility());
    // 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(1, o.getOtherNames().size());
    assertEquals(Long.valueOf(13), o.getOtherNames().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC, o.getOtherNames().get(0).getVisibility());
    // Researcher urls
    assertNotNull(p.getResearcherUrls());
    ResearcherUrls ru = p.getResearcherUrls();
    assertNotNull(ru);
    Utils.verifyLastModified(ru.getLastModifiedDate());
    assertEquals(1, ru.getResearcherUrls().size());
    assertEquals(Long.valueOf(13), ru.getResearcherUrls().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC, ru.getResearcherUrls().get(0).getVisibility());
}
Also used : Addresses(org.orcid.jaxb.model.record_v2.Addresses) Keywords(org.orcid.jaxb.model.record_v2.Keywords) PersonExternalIdentifiers(org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers) OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) Biography(org.orcid.jaxb.model.record_v2.Biography) ResearcherUrls(org.orcid.jaxb.model.record_v2.ResearcherUrls)

Example 28 with PersonExternalIdentifiers

use of org.orcid.jaxb.model.record_rc2.PersonExternalIdentifiers in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_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());
}
Also used : Email(org.orcid.jaxb.model.record_v2.Email) Keywords(org.orcid.jaxb.model.record_v2.Keywords) Address(org.orcid.jaxb.model.record_v2.Address) Keyword(org.orcid.jaxb.model.record_v2.Keyword) OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) OtherName(org.orcid.jaxb.model.record_v2.OtherName) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) Addresses(org.orcid.jaxb.model.record_v2.Addresses) PersonExternalIdentifiers(org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers) Biography(org.orcid.jaxb.model.record_v2.Biography) ResearcherUrls(org.orcid.jaxb.model.record_v2.ResearcherUrls) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) Emails(org.orcid.jaxb.model.record_v2.Emails)

Example 29 with PersonExternalIdentifiers

use of org.orcid.jaxb.model.record_rc2.PersonExternalIdentifiers in project ORCID-Source by ORCID.

the class ValidateV2RC2SamplesTest method unmarshallFromPath.

private Object unmarshallFromPath(String path, Class<?> type, String schemaPath) throws SAXException, URISyntaxException {
    try (Reader reader = new InputStreamReader(getClass().getResourceAsStream(path))) {
        Object obj = unmarshall(reader, type, schemaPath);
        Object result = null;
        if (ResearcherUrls.class.equals(type)) {
            result = (ResearcherUrls) obj;
        } else if (ResearcherUrl.class.equals(type)) {
            result = (ResearcherUrl) obj;
        } else if (PersonalDetails.class.equals(type)) {
            result = (PersonalDetails) obj;
        } else if (PersonExternalIdentifier.class.equals(type)) {
            result = (PersonExternalIdentifier) obj;
        } else if (PersonExternalIdentifiers.class.equals(type)) {
            result = (PersonExternalIdentifiers) obj;
        } else if (Biography.class.equals(type)) {
            result = (Biography) obj;
        } else if (Name.class.equals(type)) {
            result = (Name) obj;
        } else if (CreditName.class.equals(type)) {
            result = (CreditName) obj;
        } else if (OtherName.class.equals(type)) {
            result = (OtherName) obj;
        } else if (OtherNames.class.equals(type)) {
            result = (OtherNames) obj;
        } else if (Keywords.class.equals(type)) {
            result = (Keywords) obj;
        } else if (Keyword.class.equals(type)) {
            result = (Keyword) obj;
        } else if (Addresses.class.equals(type)) {
            result = (Addresses) obj;
        } else if (Address.class.equals(type)) {
            result = (Address) obj;
        } else if (Emails.class.equals(type)) {
            result = (Emails) obj;
        } else if (Email.class.equals(type)) {
            result = (Email) obj;
        } else if (Person.class.equals(type)) {
            result = (Person) obj;
        } else if (Deprecated.class.equals(type)) {
            result = (Deprecated) obj;
        } else if (Preferences.class.equals(type)) {
            result = (Preferences) obj;
        } else if (History.class.equals(type)) {
            result = (History) obj;
        } else if (Record.class.equals(type)) {
            result = (Record) obj;
        } else if (ActivitiesSummary.class.equals(type)) {
            result = (ActivitiesSummary) obj;
        }
        return result;
    } catch (IOException e) {
        throw new RuntimeException("Error reading notification from classpath", e);
    }
}
Also used : Email(org.orcid.jaxb.model.record_rc2.Email) InputStreamReader(java.io.InputStreamReader) Keyword(org.orcid.jaxb.model.record_rc2.Keyword) Address(org.orcid.jaxb.model.record_rc2.Address) OtherNames(org.orcid.jaxb.model.record_rc2.OtherNames) CreditName(org.orcid.jaxb.model.record_rc2.CreditName) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) IOException(java.io.IOException) PersonExternalIdentifier(org.orcid.jaxb.model.record_rc2.PersonExternalIdentifier) History(org.orcid.jaxb.model.record_rc2.History) ActivitiesSummary(org.orcid.jaxb.model.record.summary_rc2.ActivitiesSummary) Deprecated(org.orcid.jaxb.model.record_rc2.Deprecated) Biography(org.orcid.jaxb.model.record_rc2.Biography) ResearcherUrl(org.orcid.jaxb.model.record_rc2.ResearcherUrl)

Example 30 with PersonExternalIdentifiers

use of org.orcid.jaxb.model.record_rc2.PersonExternalIdentifiers in project ORCID-Source by ORCID.

the class PublicAPISecurityManagerV2Test method filterExternalIdentifiersTest.

@Test
public void filterExternalIdentifiersTest() {
    PersonExternalIdentifiers x = getPersonExternalIdentifiersElement(Visibility.PUBLIC, Visibility.PUBLIC, Visibility.PUBLIC);
    assertEquals(3, x.getExternalIdentifiers().size());
    publicAPISecurityManagerV2.filter(x);
    assertEquals(3, x.getExternalIdentifiers().size());
    assertAllArePublic(x.getExternalIdentifiers());
    x = getPersonExternalIdentifiersElement(Visibility.PUBLIC, Visibility.PUBLIC, Visibility.LIMITED);
    assertEquals(3, x.getExternalIdentifiers().size());
    publicAPISecurityManagerV2.filter(x);
    assertEquals(2, x.getExternalIdentifiers().size());
    assertAllArePublic(x.getExternalIdentifiers());
    x = getPersonExternalIdentifiersElement(Visibility.PUBLIC, Visibility.LIMITED, Visibility.PRIVATE);
    assertEquals(3, x.getExternalIdentifiers().size());
    publicAPISecurityManagerV2.filter(x);
    assertEquals(1, x.getExternalIdentifiers().size());
    assertAllArePublic(x.getExternalIdentifiers());
    x = getPersonExternalIdentifiersElement(Visibility.PRIVATE, Visibility.LIMITED, Visibility.PRIVATE);
    assertEquals(3, x.getExternalIdentifiers().size());
    publicAPISecurityManagerV2.filter(x);
    assertTrue(x.getExternalIdentifiers().isEmpty());
}
Also used : PersonExternalIdentifiers(org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)52 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)52 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)41 Addresses (org.orcid.jaxb.model.record_v2.Addresses)35 Keywords (org.orcid.jaxb.model.record_v2.Keywords)35 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)35 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)35 Biography (org.orcid.jaxb.model.record_v2.Biography)33 Emails (org.orcid.jaxb.model.record_v2.Emails)33 Address (org.orcid.jaxb.model.record_v2.Address)32 OtherName (org.orcid.jaxb.model.record_v2.OtherName)32 Email (org.orcid.jaxb.model.record_v2.Email)31 Keyword (org.orcid.jaxb.model.record_v2.Keyword)31 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)31 Name (org.orcid.jaxb.model.record_v2.Name)28 Person (org.orcid.jaxb.model.record_v2.Person)25 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)15 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)15 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)15 PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)15