use of org.orcid.jaxb.model.record_v2.Addresses in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV2Test method checkIsPublicPersonTest.
@Test
public void checkIsPublicPersonTest() {
Person p = getPersonElement();
publicAPISecurityManagerV2.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);
publicAPISecurityManagerV2.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);
publicAPISecurityManagerV2.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);
publicAPISecurityManagerV2.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);
publicAPISecurityManagerV2.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);
publicAPISecurityManagerV2.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);
publicAPISecurityManagerV2.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);
publicAPISecurityManagerV2.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);
publicAPISecurityManagerV2.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.record_v2.Addresses in project ORCID-Source by ORCID.
the class ConvertVrc2ToVrc3Test method upgradeAddressesToVrc3Test.
@Test
public void upgradeAddressesToVrc3Test() throws JAXBException {
JAXBContext jaxbContext1 = JAXBContext.newInstance(Addresses.class);
JAXBContext jaxbContext2 = JAXBContext.newInstance(org.orcid.jaxb.model.record_rc3.Addresses.class);
Unmarshaller jaxbUnmarshaller = jaxbContext1.createUnmarshaller();
InputStream rc2Stream = ConvertVrc2ToVrc3Test.class.getClassLoader().getResourceAsStream("test-addresses-2.0_rc2.xml");
InputStream rc3Stream = ConvertVrc2ToVrc3Test.class.getClassLoader().getResourceAsStream("test-addresses-2.0_rc3.xml");
Addresses rc2Element = (Addresses) jaxbUnmarshaller.unmarshal(rc2Stream);
jaxbUnmarshaller = jaxbContext2.createUnmarshaller();
org.orcid.jaxb.model.record_rc3.Addresses rc3Element1 = (org.orcid.jaxb.model.record_rc3.Addresses) jaxbUnmarshaller.unmarshal(rc3Stream);
V2Convertible result = versionConverterV2_0_rc2ToV2_0_rc3.upgrade(new V2Convertible(rc2Element, "v2_rc2"));
org.orcid.jaxb.model.record_rc3.Addresses rc3Element2 = (org.orcid.jaxb.model.record_rc3.Addresses) result.getObjectToConvert();
assertEquals(rc3Element1, rc3Element2);
}
use of org.orcid.jaxb.model.record_v2.Addresses in project ORCID-Source by ORCID.
the class ConvertV2ToV2_1Test method upgradeAddressesToV21Test.
@Test
public void upgradeAddressesToV21Test() throws JAXBException {
JAXBContext jaxbContext1 = JAXBContext.newInstance(Addresses.class);
JAXBContext jaxbContext2 = JAXBContext.newInstance(Addresses.class);
Unmarshaller jaxbUnmarshaller = jaxbContext1.createUnmarshaller();
InputStream v20Stream = ConvertV2ToV2_1Test.class.getClassLoader().getResourceAsStream("test-addresses-2.0.xml");
InputStream v21Stream = ConvertV2ToV2_1Test.class.getClassLoader().getResourceAsStream("test-addresses-2.1.xml");
Addresses v20Element = (Addresses) jaxbUnmarshaller.unmarshal(v20Stream);
jaxbUnmarshaller = jaxbContext2.createUnmarshaller();
Addresses v21Element1 = (Addresses) jaxbUnmarshaller.unmarshal(v21Stream);
V2Convertible result = versionConverterV2_0ToV2_1.upgrade(new V2Convertible(v20Element, "v2.1"));
Addresses v21Element2 = (Addresses) result.getObjectToConvert();
assertEquals(v21Element1, v21Element2);
}
use of org.orcid.jaxb.model.record_v2.Addresses in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_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.record_v2.Addresses in project ORCID-Source by ORCID.
the class OrcidSecurityManager_FullRecordTest method testRecord_When_SomePrivate_NoSource_ReadLimitedToken.
@Test
public void testRecord_When_SomePrivate_NoSource_ReadLimitedToken() {
SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.READ_LIMITED);
Name name = createName(Visibility.PRIVATE);
Biography bio = createBiography(Visibility.PUBLIC);
Address a1 = createAddress(Visibility.PRIVATE, CLIENT_2);
Address a2 = createAddress(Visibility.PUBLIC, CLIENT_2);
Address a3 = createAddress(Visibility.PRIVATE, CLIENT_2);
Addresses addresses = new Addresses();
addresses.setAddress(new ArrayList<Address>(Arrays.asList(a1, a2, a3)));
Email e1 = createEmail(Visibility.PRIVATE, CLIENT_2);
Email e2 = createEmail(Visibility.PUBLIC, CLIENT_2);
Email e3 = createEmail(Visibility.PRIVATE, CLIENT_2);
Emails emails = new Emails();
emails.setEmails(new ArrayList<Email>(Arrays.asList(e1, e2, e3)));
Keyword k1 = createKeyword(Visibility.PRIVATE, CLIENT_2);
Keyword k2 = createKeyword(Visibility.PUBLIC, CLIENT_2);
Keyword k3 = createKeyword(Visibility.PRIVATE, CLIENT_2);
Keywords keywords = new Keywords();
keywords.setKeywords(new ArrayList<Keyword>(Arrays.asList(k1, k2, k3)));
OtherName o1 = createOtherName(Visibility.PRIVATE, CLIENT_2);
OtherName o2 = createOtherName(Visibility.PUBLIC, CLIENT_2);
OtherName o3 = createOtherName(Visibility.PRIVATE, CLIENT_2);
OtherNames otherNames = new OtherNames();
otherNames.setOtherNames(new ArrayList<OtherName>(Arrays.asList(o1, o2, o3)));
PersonExternalIdentifier ext1 = createPersonExternalIdentifier(Visibility.PRIVATE, CLIENT_2);
PersonExternalIdentifier ext2 = createPersonExternalIdentifier(Visibility.PUBLIC, CLIENT_2);
PersonExternalIdentifier ext3 = createPersonExternalIdentifier(Visibility.PRIVATE, CLIENT_2);
PersonExternalIdentifiers extIds = new PersonExternalIdentifiers();
extIds.setExternalIdentifiers(new ArrayList<PersonExternalIdentifier>(Arrays.asList(ext1, ext2, ext3)));
ResearcherUrl r1 = createResearcherUrl(Visibility.PRIVATE, CLIENT_2);
ResearcherUrl r2 = createResearcherUrl(Visibility.PUBLIC, CLIENT_2);
ResearcherUrl r3 = createResearcherUrl(Visibility.PRIVATE, CLIENT_2);
ResearcherUrls researcherUrls = new ResearcherUrls();
researcherUrls.setResearcherUrls(new ArrayList<ResearcherUrl>(Arrays.asList(r1, r2, r3)));
EducationSummary edu1 = createEducationSummary(Visibility.PRIVATE, CLIENT_2);
EducationSummary edu2 = createEducationSummary(Visibility.PUBLIC, CLIENT_2);
EducationSummary edu3 = createEducationSummary(Visibility.PRIVATE, CLIENT_2);
EmploymentSummary em1 = createEmploymentSummary(Visibility.PRIVATE, CLIENT_2);
EmploymentSummary em2 = createEmploymentSummary(Visibility.PUBLIC, CLIENT_2);
EmploymentSummary em3 = createEmploymentSummary(Visibility.PRIVATE, CLIENT_2);
FundingSummary f1 = createFundingSummary(Visibility.PRIVATE, CLIENT_2, EXTID_1);
FundingSummary f2 = createFundingSummary(Visibility.PUBLIC, CLIENT_2, EXTID_2);
FundingSummary f3 = createFundingSummary(Visibility.PRIVATE, CLIENT_2, EXTID_3);
PeerReviewSummary p1 = createPeerReviewSummary(Visibility.PRIVATE, CLIENT_2, EXTID_1);
PeerReviewSummary p2 = createPeerReviewSummary(Visibility.PUBLIC, CLIENT_2, EXTID_2);
PeerReviewSummary p3 = createPeerReviewSummary(Visibility.PRIVATE, CLIENT_2, EXTID_3);
WorkSummary w1 = createWorkSummary(Visibility.PRIVATE, CLIENT_2, EXTID_1);
WorkSummary w2 = createWorkSummary(Visibility.PUBLIC, CLIENT_2, EXTID_2);
WorkSummary w3 = createWorkSummary(Visibility.PRIVATE, CLIENT_2, EXTID_3);
ActivitiesSummary as = new ActivitiesSummary();
as.setEducations(createEducations(edu1, edu2, edu3));
as.setEmployments(createEmployments(em1, em2, em3));
as.setFundings(createFundings(f1, f2, f3));
as.setPeerReviews(createPeerReviews(p1, p2, p3));
as.setWorks(createWorks(w1, w2, w3));
Person p = new Person();
p.setBiography(bio);
p.setName(name);
p.setAddresses(addresses);
p.setEmails(emails);
p.setExternalIdentifiers(extIds);
p.setKeywords(keywords);
p.setOtherNames(otherNames);
p.setResearcherUrls(researcherUrls);
Record record = new Record();
record.setActivitiesSummary(as);
record.setPerson(p);
orcidSecurityManager.checkAndFilter(ORCID_1, record);
assertNotNull(record);
// Check person
assertNull(p.getName());
assertEquals(bio, p.getBiography());
// Check addresses
assertEquals(1, p.getAddresses().getAddress().size());
assertFalse(p.getAddresses().getAddress().contains(a1));
assertTrue(p.getAddresses().getAddress().contains(a2));
assertFalse(p.getAddresses().getAddress().contains(a3));
// Check emails
assertEquals(1, p.getEmails().getEmails().size());
assertFalse(p.getEmails().getEmails().contains(e1));
assertTrue(p.getEmails().getEmails().contains(e2));
assertFalse(p.getEmails().getEmails().contains(e3));
// Check ext ids
assertEquals(1, p.getExternalIdentifiers().getExternalIdentifiers().size());
assertFalse(p.getExternalIdentifiers().getExternalIdentifiers().contains(ext1));
assertTrue(p.getExternalIdentifiers().getExternalIdentifiers().contains(ext2));
assertFalse(p.getExternalIdentifiers().getExternalIdentifiers().contains(ext3));
// Check keywords
assertEquals(1, p.getKeywords().getKeywords().size());
assertFalse(p.getKeywords().getKeywords().contains(k1));
assertTrue(p.getKeywords().getKeywords().contains(k2));
assertFalse(p.getKeywords().getKeywords().contains(k3));
// Check other names
assertEquals(1, p.getOtherNames().getOtherNames().size());
assertFalse(p.getOtherNames().getOtherNames().contains(o1));
assertTrue(p.getOtherNames().getOtherNames().contains(o2));
assertFalse(p.getOtherNames().getOtherNames().contains(o3));
// Check researcher urls
assertEquals(1, p.getResearcherUrls().getResearcherUrls().size());
assertFalse(p.getResearcherUrls().getResearcherUrls().contains(r1));
assertTrue(p.getResearcherUrls().getResearcherUrls().contains(r2));
assertFalse(p.getResearcherUrls().getResearcherUrls().contains(r3));
// Check activities
assertNotNull(as);
// Check educations
assertEquals(1, as.getEducations().getSummaries().size());
assertFalse(as.getEducations().getSummaries().contains(edu1));
assertTrue(as.getEducations().getSummaries().contains(edu2));
assertFalse(as.getEducations().getSummaries().contains(edu3));
// Check employments
assertEquals(1, as.getEmployments().getSummaries().size());
assertFalse(as.getEmployments().getSummaries().contains(em1));
assertTrue(as.getEmployments().getSummaries().contains(em2));
assertFalse(as.getEmployments().getSummaries().contains(em3));
// Check fundings
assertEquals(1, as.getFundings().getFundingGroup().size());
assertEquals(1, as.getFundings().getFundingGroup().get(0).getActivities().size());
assertFalse(as.getFundings().getFundingGroup().get(0).getActivities().contains(f1));
assertTrue(as.getFundings().getFundingGroup().get(0).getActivities().contains(f2));
assertFalse(as.getFundings().getFundingGroup().get(0).getActivities().contains(f3));
assertEquals(2, as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().size());
assertFalse(as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_1)));
assertTrue(as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_2)));
assertFalse(as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_3)));
assertTrue(as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_SHARED)));
// Check peer reviews
assertEquals(1, as.getPeerReviews().getPeerReviewGroup().size());
assertEquals(1, as.getPeerReviews().getPeerReviewGroup().get(0).getActivities().size());
assertFalse(as.getPeerReviews().getPeerReviewGroup().get(0).getActivities().contains(p1));
assertTrue(as.getPeerReviews().getPeerReviewGroup().get(0).getActivities().contains(p2));
assertFalse(as.getPeerReviews().getPeerReviewGroup().get(0).getActivities().contains(p3));
assertEquals(1, as.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().size());
assertTrue(as.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_SHARED, "peer-review")));
// Check works
assertEquals(1, as.getWorks().getWorkGroup().size());
assertEquals(1, as.getWorks().getWorkGroup().get(0).getActivities().size());
assertFalse(as.getWorks().getWorkGroup().get(0).getActivities().contains(w1));
assertTrue(as.getWorks().getWorkGroup().get(0).getActivities().contains(w2));
assertFalse(as.getWorks().getWorkGroup().get(0).getActivities().contains(w3));
assertEquals(2, as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().size());
assertFalse(as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_1)));
assertTrue(as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_2)));
assertFalse(as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_3)));
assertTrue(as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_SHARED)));
}
Aggregations