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());
}
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());
}
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());
}
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;
}
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());
}
Aggregations