Search in sources :

Example 26 with Name

use of org.orcid.jaxb.model.v3.dev1.record.Name in project ORCID-Source by ORCID.

the class PublicV3ApiServiceDelegatorTest method testViewOtherNames.

@Test
public void testViewOtherNames() {
    Response response = serviceDelegator.viewOtherNames(ORCID);
    assertNotNull(response);
    OtherNames otherNames = (OtherNames) response.getEntity();
    assertNotNull(otherNames);
    assertNotNull(otherNames.getLastModifiedDate());
    assertNotNull(otherNames.getLastModifiedDate().getValue());
    assertEquals("/0000-0000-0000-0003/other-names", otherNames.getPath());
    assertEquals(1, otherNames.getOtherNames().size());
    OtherName otherName = otherNames.getOtherNames().get(0);
    assertNotNull(otherName);
    assertNotNull(otherName.getLastModifiedDate());
    assertNotNull(otherName.getLastModifiedDate().getValue());
    assertEquals(Long.valueOf(13), otherName.getPutCode());
    assertEquals("Other Name PUBLIC", otherName.getContent());
    assertEquals(Visibility.PUBLIC.value(), otherName.getVisibility().value());
    assertEquals("/0000-0000-0000-0003/other-names/13", otherName.getPath());
    assertEquals("APP-5555555555555555", otherName.getSource().retrieveSourcePath());
}
Also used : Response(javax.ws.rs.core.Response) OtherNames(org.orcid.jaxb.model.v3.dev1.record.OtherNames) OtherName(org.orcid.jaxb.model.v3.dev1.record.OtherName) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 27 with Name

use of org.orcid.jaxb.model.v3.dev1.record.Name in project ORCID-Source by ORCID.

the class PublicV3ApiServiceDelegatorTest method testViewOtherName.

@Test
public void testViewOtherName() {
    Response response = serviceDelegator.viewOtherName(ORCID, 13L);
    assertNotNull(response);
    OtherName otherName = (OtherName) response.getEntity();
    assertNotNull(otherName);
    assertNotNull(otherName.getLastModifiedDate());
    assertNotNull(otherName.getLastModifiedDate().getValue());
    assertEquals(Long.valueOf(13), otherName.getPutCode());
    assertEquals("Other Name PUBLIC", otherName.getContent());
    assertEquals(Visibility.PUBLIC.value(), otherName.getVisibility().value());
    assertEquals("/0000-0000-0000-0003/other-names/13", otherName.getPath());
    assertEquals("APP-5555555555555555", otherName.getSource().retrieveSourcePath());
}
Also used : Response(javax.ws.rs.core.Response) OtherName(org.orcid.jaxb.model.v3.dev1.record.OtherName) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 28 with Name

use of org.orcid.jaxb.model.v3.dev1.record.Name in project ORCID-Source by ORCID.

the class PublicAPISecurityManagerV3Test method checkIsPublicPersonTest.

@Test
public void checkIsPublicPersonTest() {
    Person p = getPersonElement();
    publicAPISecurityManagerV3.filter(p);
    // Nothing is filtered yet
    assertEquals(3, p.getAddresses().getAddress().size());
    p.getAddresses().getAddress().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getBiography().getVisibility());
    assertEquals(3, p.getEmails().getEmails().size());
    p.getEmails().getEmails().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    p.getExternalIdentifiers().getExternalIdentifiers().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getKeywords().getKeywords().size());
    p.getKeywords().getKeywords().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getName().getVisibility());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    p.getOtherNames().getOtherNames().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    p.getResearcherUrls().getResearcherUrls().forEach(e -> assertIsPublic(e));
    // Addresses filtered
    p = getPersonElement();
    setVisibility(p.getAddresses().getAddress(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV3.filter(p);
    // --- filtered ---
    assertNotNull(p.getAddresses());
    assertTrue(p.getAddresses().getAddress().isEmpty());
    assertEquals(Visibility.PUBLIC, p.getBiography().getVisibility());
    assertEquals(3, p.getEmails().getEmails().size());
    p.getEmails().getEmails().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    p.getExternalIdentifiers().getExternalIdentifiers().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getKeywords().getKeywords().size());
    p.getKeywords().getKeywords().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getName().getVisibility());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    p.getOtherNames().getOtherNames().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    p.getResearcherUrls().getResearcherUrls().forEach(e -> assertIsPublic(e));
    // Bio filtered
    p = getPersonElement();
    p.getBiography().setVisibility(Visibility.LIMITED);
    publicAPISecurityManagerV3.filter(p);
    assertEquals(3, p.getAddresses().getAddress().size());
    p.getAddresses().getAddress().forEach(e -> assertIsPublic(e));
    // --- filtered ---
    assertNull(p.getBiography());
    assertEquals(3, p.getEmails().getEmails().size());
    p.getEmails().getEmails().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    p.getExternalIdentifiers().getExternalIdentifiers().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getKeywords().getKeywords().size());
    p.getKeywords().getKeywords().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getName().getVisibility());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    p.getOtherNames().getOtherNames().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    p.getResearcherUrls().getResearcherUrls().forEach(e -> assertIsPublic(e));
    // Emails filtered
    p = getPersonElement();
    setVisibility(p.getEmails().getEmails(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV3.filter(p);
    assertEquals(3, p.getAddresses().getAddress().size());
    p.getAddresses().getAddress().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getBiography().getVisibility());
    // --- filtered ---
    assertNotNull(p.getEmails());
    assertTrue(p.getEmails().getEmails().isEmpty());
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    p.getExternalIdentifiers().getExternalIdentifiers().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getKeywords().getKeywords().size());
    p.getKeywords().getKeywords().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getName().getVisibility());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    p.getOtherNames().getOtherNames().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    p.getResearcherUrls().getResearcherUrls().forEach(e -> assertIsPublic(e));
    // External ids filtered
    p = getPersonElement();
    setVisibility(p.getExternalIdentifiers().getExternalIdentifiers(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV3.filter(p);
    assertEquals(3, p.getAddresses().getAddress().size());
    p.getAddresses().getAddress().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getBiography().getVisibility());
    assertEquals(3, p.getEmails().getEmails().size());
    p.getEmails().getEmails().forEach(e -> assertIsPublic(e));
    // --- filtered ---
    assertNotNull(p.getExternalIdentifiers());
    assertTrue(p.getExternalIdentifiers().getExternalIdentifiers().isEmpty());
    assertEquals(3, p.getKeywords().getKeywords().size());
    p.getKeywords().getKeywords().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getName().getVisibility());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    p.getOtherNames().getOtherNames().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    p.getResearcherUrls().getResearcherUrls().forEach(e -> assertIsPublic(e));
    // Keywords filtered
    p = getPersonElement();
    setVisibility(p.getKeywords().getKeywords(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV3.filter(p);
    assertEquals(3, p.getAddresses().getAddress().size());
    p.getAddresses().getAddress().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getBiography().getVisibility());
    assertEquals(3, p.getEmails().getEmails().size());
    p.getEmails().getEmails().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    p.getExternalIdentifiers().getExternalIdentifiers().forEach(e -> assertIsPublic(e));
    // --- filtered ---
    assertNotNull(p.getKeywords());
    assertTrue(p.getKeywords().getKeywords().isEmpty());
    assertEquals(Visibility.PUBLIC, p.getName().getVisibility());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    p.getOtherNames().getOtherNames().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    p.getResearcherUrls().getResearcherUrls().forEach(e -> assertIsPublic(e));
    // Name filtered
    p = getPersonElement();
    p.getName().setVisibility(Visibility.LIMITED);
    publicAPISecurityManagerV3.filter(p);
    assertEquals(3, p.getAddresses().getAddress().size());
    p.getAddresses().getAddress().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getBiography().getVisibility());
    assertEquals(3, p.getEmails().getEmails().size());
    p.getEmails().getEmails().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    p.getExternalIdentifiers().getExternalIdentifiers().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getKeywords().getKeywords().size());
    p.getKeywords().getKeywords().forEach(e -> assertIsPublic(e));
    // --- filtered ---
    assertNull(p.getName());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    p.getOtherNames().getOtherNames().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    p.getResearcherUrls().getResearcherUrls().forEach(e -> assertIsPublic(e));
    // Other names filtered
    p = getPersonElement();
    setVisibility(p.getOtherNames().getOtherNames(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV3.filter(p);
    assertEquals(3, p.getAddresses().getAddress().size());
    p.getAddresses().getAddress().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getBiography().getVisibility());
    assertEquals(3, p.getEmails().getEmails().size());
    p.getEmails().getEmails().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    p.getExternalIdentifiers().getExternalIdentifiers().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getKeywords().getKeywords().size());
    p.getKeywords().getKeywords().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getName().getVisibility());
    // --- filtered ---
    assertNotNull(p.getOtherNames());
    assertTrue(p.getOtherNames().getOtherNames().isEmpty());
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    p.getResearcherUrls().getResearcherUrls().forEach(e -> assertIsPublic(e));
    // Researcher urls filtered
    p = getPersonElement();
    setVisibility(p.getResearcherUrls().getResearcherUrls(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV3.filter(p);
    assertEquals(3, p.getAddresses().getAddress().size());
    p.getAddresses().getAddress().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getBiography().getVisibility());
    assertEquals(3, p.getEmails().getEmails().size());
    p.getEmails().getEmails().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    p.getExternalIdentifiers().getExternalIdentifiers().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getKeywords().getKeywords().size());
    p.getKeywords().getKeywords().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getName().getVisibility());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    p.getOtherNames().getOtherNames().forEach(e -> assertIsPublic(e));
    // --- filtered ---
    assertNotNull(p.getResearcherUrls());
    assertTrue(p.getResearcherUrls().getResearcherUrls().isEmpty());
}
Also used : Person(org.orcid.jaxb.model.v3.dev1.record.Person) Test(org.junit.Test)

Example 29 with Name

use of org.orcid.jaxb.model.v3.dev1.record.Name in project ORCID-Source by ORCID.

the class PublicAPISecurityManagerV3Test method getPersonalDetailsElement.

private PersonalDetails getPersonalDetailsElement(Visibility nameVisibility, Visibility bioVisiblity, Visibility otherNamesVisibility) {
    PersonalDetails p = new PersonalDetails();
    Name name = new Name();
    name.setVisibility(nameVisibility);
    p.setName(name);
    Biography bio = new Biography();
    bio.setVisibility(bioVisiblity);
    bio.setContent("Bio test");
    p.setBiography(bio);
    p.setOtherNames(getOtherNamesElement(otherNamesVisibility));
    return p;
}
Also used : Biography(org.orcid.jaxb.model.v3.dev1.record.Biography) PersonalDetails(org.orcid.jaxb.model.v3.dev1.record.PersonalDetails) OtherName(org.orcid.jaxb.model.v3.dev1.record.OtherName) Name(org.orcid.jaxb.model.v3.dev1.record.Name)

Example 30 with Name

use of org.orcid.jaxb.model.v3.dev1.record.Name in project ORCID-Source by ORCID.

the class PublicAPISecurityManagerV3Test method checkIsPublicPersonalDetailsTest.

@Test
public void checkIsPublicPersonalDetailsTest() {
    PersonalDetails p = getPersonalDetailsElement(Visibility.PUBLIC, Visibility.PUBLIC, Visibility.PUBLIC);
    publicAPISecurityManagerV3.filter(p);
    assertEquals(Visibility.PUBLIC, p.getName().getVisibility());
    assertEquals(Visibility.PUBLIC, p.getBiography().getVisibility());
    assertNotNull(p.getOtherNames().getOtherNames());
    p.getOtherNames().getOtherNames().forEach(e -> {
        assertIsPublic(e);
    });
    // Should not fail, but name should be empty
    p = getPersonalDetailsElement(Visibility.LIMITED, Visibility.PUBLIC, Visibility.PUBLIC);
    publicAPISecurityManagerV3.filter(p);
    assertNull(p.getName());
    assertNotNull(p.getBiography());
    assertNotNull(p.getOtherNames().getOtherNames());
    p.getOtherNames().getOtherNames().forEach(e -> {
        assertIsPublic(e);
    });
    // Should not fail, but bio should be null
    p = getPersonalDetailsElement(Visibility.PUBLIC, Visibility.LIMITED, Visibility.PUBLIC);
    publicAPISecurityManagerV3.filter(p);
    assertNotNull(p.getName());
    assertNull(p.getBiography());
    assertNotNull(p.getOtherNames().getOtherNames());
    p.getOtherNames().getOtherNames().forEach(e -> {
        assertIsPublic(e);
    });
    p = getPersonalDetailsElement(Visibility.PUBLIC, Visibility.PUBLIC, Visibility.LIMITED);
    publicAPISecurityManagerV3.filter(p);
    assertNotNull(p.getName());
    assertNotNull(p.getBiography());
    assertNotNull(p.getOtherNames());
    assertTrue(p.getOtherNames().getOtherNames().isEmpty());
    p = getPersonalDetailsElement(Visibility.PUBLIC, Visibility.PUBLIC, Visibility.PRIVATE);
    publicAPISecurityManagerV3.filter(p);
    assertNotNull(p.getName());
    assertNotNull(p.getBiography());
    assertNotNull(p.getOtherNames());
    assertTrue(p.getOtherNames().getOtherNames().isEmpty());
}
Also used : PersonalDetails(org.orcid.jaxb.model.v3.dev1.record.PersonalDetails) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)175 OtherName (org.orcid.jaxb.model.v3.dev1.record.OtherName)84 Name (org.orcid.jaxb.model.v3.dev1.record.Name)70 DBUnitTest (org.orcid.test.DBUnitTest)53 Biography (org.orcid.jaxb.model.v3.dev1.record.Biography)51 OtherNames (org.orcid.jaxb.model.v3.dev1.record.OtherNames)48 Response (javax.ws.rs.core.Response)43 PersonExternalIdentifier (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)43 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)40 Email (org.orcid.jaxb.model.v3.dev1.record.Email)39 Address (org.orcid.jaxb.model.v3.dev1.record.Address)37 Keyword (org.orcid.jaxb.model.v3.dev1.record.Keyword)36 Person (org.orcid.jaxb.model.v3.dev1.record.Person)35 Addresses (org.orcid.jaxb.model.v3.dev1.record.Addresses)33 PersonExternalIdentifiers (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers)33 ResearcherUrls (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls)33 Keywords (org.orcid.jaxb.model.v3.dev1.record.Keywords)31 Emails (org.orcid.jaxb.model.v3.dev1.record.Emails)30 ClientResponse (com.sun.jersey.api.client.ClientResponse)25 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)25