use of com.alibaba.json.bvt.bug.Bug_for_issue_729.Person in project ORCID-Source by ORCID.
the class ValidateV2SamplesTest method testUnmarshallRecord.
@Test
public void testUnmarshallRecord() throws SAXException, URISyntaxException {
Record record = (Record) unmarshallFromPath("/record_2.0/samples/read_samples/record-2.0.xml", Record.class, "/record_2.0/record-2.0.xsd");
assertNotNull(record);
//Check activities
assertNotNull(record.getActivitiesSummary());
ActivitiesSummary activities = record.getActivitiesSummary();
assertNotNull(activities.getLastModifiedDate());
assertNotNull(activities.getEducations());
Educations educations = activities.getEducations();
assertNotNull(educations.getLastModifiedDate());
assertEquals(1, educations.getSummaries().size());
EducationSummary education = educations.getSummaries().get(0);
assertEquals(Long.valueOf(0), education.getPutCode());
assertEquals(Visibility.PRIVATE, education.getVisibility());
assertEquals("education:department-name", education.getDepartmentName());
assertEquals("education:role-title", education.getRoleTitle());
assertNotNull(education.getEndDate());
assertEquals("02", education.getEndDate().getDay().getValue());
assertEquals("02", education.getEndDate().getMonth().getValue());
assertEquals("1848", education.getEndDate().getYear().getValue());
assertNotNull(education.getStartDate());
assertEquals("02", education.getStartDate().getDay().getValue());
assertEquals("02", education.getStartDate().getMonth().getValue());
assertEquals("1848", education.getStartDate().getYear().getValue());
assertNotNull(education.getOrganization());
assertEquals("common:name", education.getOrganization().getName());
assertEquals("common:city", education.getOrganization().getAddress().getCity());
assertEquals("common:region", education.getOrganization().getAddress().getRegion());
assertEquals(Iso3166Country.AF, education.getOrganization().getAddress().getCountry());
assertNotNull(activities.getEmployments());
Employments employments = activities.getEmployments();
assertNotNull(employments.getLastModifiedDate());
assertEquals(1, employments.getSummaries().size());
EmploymentSummary employment = employments.getSummaries().get(0);
assertEquals(Long.valueOf(0), employment.getPutCode());
assertEquals(Visibility.PRIVATE, employment.getVisibility());
assertEquals("employment:department-name", employment.getDepartmentName());
assertEquals("employment:role-title", employment.getRoleTitle());
assertNotNull(employment.getEndDate());
assertEquals("02", employment.getEndDate().getDay().getValue());
assertEquals("02", employment.getEndDate().getMonth().getValue());
assertEquals("1848", employment.getEndDate().getYear().getValue());
assertNotNull(employment.getStartDate());
assertEquals("02", employment.getStartDate().getDay().getValue());
assertEquals("02", employment.getStartDate().getMonth().getValue());
assertEquals("1848", employment.getStartDate().getYear().getValue());
assertNotNull(employment.getOrganization());
assertEquals("common:name", employment.getOrganization().getName());
assertEquals("common:city", employment.getOrganization().getAddress().getCity());
assertEquals("common:region", employment.getOrganization().getAddress().getRegion());
assertEquals(Iso3166Country.AF, employment.getOrganization().getAddress().getCountry());
assertNotNull(activities.getFundings());
Fundings fundings = activities.getFundings();
assertNotNull(fundings.getLastModifiedDate());
assertEquals(1, fundings.getFundingGroup().size());
assertNotNull(fundings.getFundingGroup().get(0).getLastModifiedDate());
assertEquals(1, fundings.getFundingGroup().get(0).getFundingSummary().size());
assertEquals(1, fundings.getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().size());
assertEquals("grant_number", fundings.getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getType());
assertEquals("external-id-value", fundings.getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getValue());
assertEquals(1, fundings.getFundingGroup().get(0).getFundingSummary().size());
FundingSummary funding = fundings.getFundingGroup().get(0).getFundingSummary().get(0);
assertEquals(Long.valueOf(0), funding.getPutCode());
assertEquals(Visibility.PRIVATE, funding.getVisibility());
assertNotNull(funding.getTitle());
assertEquals("common:title", funding.getTitle().getTitle().getContent());
assertEquals("common:translated-title", funding.getTitle().getTranslatedTitle().getContent());
assertEquals("en", funding.getTitle().getTranslatedTitle().getLanguageCode());
assertNotNull(funding.getExternalIdentifiers());
assertEquals(1, funding.getExternalIdentifiers().getExternalIdentifier().size());
assertEquals(Relationship.SELF, funding.getExternalIdentifiers().getExternalIdentifier().get(0).getRelationship());
assertEquals("grant_number", funding.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
assertEquals("http://tempuri.org", funding.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
assertEquals("external-id-value", funding.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
assertNotNull(funding.getEndDate());
assertEquals("02", funding.getEndDate().getDay().getValue());
assertEquals("02", funding.getEndDate().getMonth().getValue());
assertEquals("1848", funding.getEndDate().getYear().getValue());
assertNotNull(funding.getStartDate());
assertEquals("02", funding.getStartDate().getDay().getValue());
assertEquals("02", funding.getStartDate().getMonth().getValue());
assertEquals("1848", funding.getStartDate().getYear().getValue());
assertNotNull(funding.getOrganization());
assertEquals("common:name", funding.getOrganization().getName());
assertEquals("common:city", funding.getOrganization().getAddress().getCity());
assertEquals("common:region", funding.getOrganization().getAddress().getRegion());
assertEquals(Iso3166Country.AF, funding.getOrganization().getAddress().getCountry());
assertNotNull(activities.getPeerReviews());
assertNotNull(activities.getPeerReviews().getLastModifiedDate());
assertNotNull(activities.getPeerReviews().getPeerReviewGroup());
assertEquals(1, activities.getPeerReviews().getPeerReviewGroup().size());
assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers());
assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier());
assertEquals(1, activities.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().size());
assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getType());
assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getValue());
assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getUrl());
assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getRelationship());
assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary());
assertEquals(1, activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().size());
assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getCompletionDate());
assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getCompletionDate().getDay());
assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getCompletionDate().getMonth());
assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getCompletionDate().getYear());
assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getCreatedDate());
assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getCreatedDate().getValue());
assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getDisplayIndex());
assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getExternalIdentifiers());
assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getExternalIdentifiers().getExternalIdentifier());
assertEquals(1, activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getExternalIdentifiers().getExternalIdentifier().size());
assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getExternalIdentifiers().getExternalIdentifier().get(0).getType());
assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getExternalIdentifiers().getExternalIdentifier().get(0).getUrl());
assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getExternalIdentifiers().getExternalIdentifier().get(0).getRelationship());
assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getGroupId());
assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getLastModifiedDate());
assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getOrganization());
assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getOrganization().getAddress());
assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getOrganization().getAddress().getCity());
assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getOrganization().getAddress().getCountry());
assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getOrganization().getAddress().getRegion());
assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getOrganization().getName());
assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getPutCode());
assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getSource());
assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getSource().retrieveSourcePath());
assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getVisibility());
assertNotNull(activities.getWorks());
Works works = activities.getWorks();
assertNotNull(works.getLastModifiedDate());
assertEquals(1, works.getWorkGroup().size());
assertNotNull(works.getWorkGroup().get(0).getIdentifiers());
assertEquals(1, works.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().size());
assertEquals(Relationship.PART_OF, works.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getRelationship());
assertEquals("agr", works.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getType());
assertEquals("http://orcid.org", works.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
assertEquals("external-id-value", works.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getValue());
assertEquals(1, works.getWorkGroup().get(0).getWorkSummary().size());
WorkSummary work = works.getWorkGroup().get(0).getWorkSummary().get(0);
assertEquals(Long.valueOf(0), work.getPutCode());
assertEquals(Visibility.PRIVATE, work.getVisibility());
assertNotNull(work.getTitle());
assertEquals("common:title", work.getTitle().getTitle().getContent());
assertEquals("common:translated-title", work.getTitle().getTranslatedTitle().getContent());
assertEquals("en", work.getTitle().getTranslatedTitle().getLanguageCode());
assertNotNull(work.getExternalIdentifiers());
assertEquals(1, work.getExternalIdentifiers().getExternalIdentifier().size());
assertEquals(Relationship.SELF, work.getExternalIdentifiers().getExternalIdentifier().get(0).getRelationship());
assertEquals("agr", work.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
assertEquals("http://tempuri.org", work.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
assertEquals("external-id-value", work.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
assertEquals(WorkType.ARTISTIC_PERFORMANCE, work.getType());
assertNotNull(work.getPublicationDate());
assertEquals("02", work.getPublicationDate().getDay().getValue());
assertEquals("02", work.getPublicationDate().getMonth().getValue());
assertEquals("1848", work.getPublicationDate().getYear().getValue());
//Check biography
Person person = record.getPerson();
assertNotNull(person);
assertNotNull(person.getLastModifiedDate().getValue());
assertNotNull(person.getAddresses());
assertNotNull(person.getAddresses().getLastModifiedDate());
assertEquals(1, person.getAddresses().getAddress().size());
Address address = person.getAddresses().getAddress().get(0);
assertEquals(Long.valueOf(1), address.getPutCode());
assertEquals(Visibility.PUBLIC, address.getVisibility());
assertEquals(Iso3166Country.US, address.getCountry().getValue());
assertEquals(Long.valueOf(0), address.getDisplayIndex());
assertNotNull(address.getLastModifiedDate());
assertNotNull(person.getBiography());
assertEquals(Visibility.PUBLIC, person.getBiography().getVisibility());
assertEquals("biography", person.getBiography().getContent());
assertNotNull(person.getEmails());
assertTrue(StringUtils.isNotBlank(person.getEmails().getPath()));
assertNotNull(person.getEmails().getLastModifiedDate());
assertNotNull(person.getEmails().getEmails());
assertEquals(1, person.getEmails().getEmails().size());
Email email = person.getEmails().getEmails().get(0);
assertNotNull(email.getCreatedDate().getValue());
assertEquals("user1@email.com", email.getEmail());
assertNotNull(email.getLastModifiedDate().getValue());
assertEquals(Long.valueOf(0), email.getPutCode());
assertNotNull(email.getSource());
assertEquals(Visibility.PUBLIC, email.getVisibility());
assertNotNull(person.getExternalIdentifiers());
assertTrue(StringUtils.isNotBlank(person.getExternalIdentifiers().getPath()));
assertNotNull(person.getExternalIdentifiers().getLastModifiedDate().getValue());
assertNotNull(person.getExternalIdentifiers().getExternalIdentifiers());
assertEquals(1, person.getExternalIdentifiers().getExternalIdentifiers().size());
PersonExternalIdentifier extId = person.getExternalIdentifiers().getExternalIdentifiers().get(0);
assertNotNull(extId.getCreatedDate().getValue());
assertNotNull(extId.getLastModifiedDate());
assertEquals(Long.valueOf(0), extId.getDisplayIndex());
assertEquals(Long.valueOf(1), extId.getPutCode());
assertEquals(Relationship.PART_OF, extId.getRelationship());
assertNotNull(extId.getSource());
assertEquals("type-1", extId.getType());
assertEquals("http://url.com/1", extId.getUrl().getValue());
assertEquals("value-1", extId.getValue());
assertEquals(Visibility.PUBLIC, extId.getVisibility());
assertNotNull(person.getKeywords());
assertTrue(StringUtils.isNotBlank(person.getKeywords().getPath()));
assertNotNull(person.getKeywords().getLastModifiedDate().getValue());
assertNotNull(person.getKeywords().getKeywords());
assertEquals(1, person.getKeywords().getKeywords().size());
Keyword keyword = person.getKeywords().getKeywords().get(0);
assertEquals("keyword1", keyword.getContent());
assertNotNull(keyword.getCreatedDate().getValue());
assertNotNull(keyword.getLastModifiedDate().getValue());
assertEquals(Long.valueOf(0), keyword.getDisplayIndex());
assertEquals(Long.valueOf(1), keyword.getPutCode());
assertNotNull(keyword.getSource());
assertEquals(Visibility.PUBLIC, keyword.getVisibility());
assertNotNull(person.getOtherNames());
assertTrue(StringUtils.isNotBlank(person.getOtherNames().getPath()));
assertNotNull(person.getOtherNames().getLastModifiedDate().getValue());
assertNotNull(person.getOtherNames().getOtherNames());
assertEquals(1, person.getOtherNames().getOtherNames().size());
OtherName otherName = person.getOtherNames().getOtherNames().get(0);
assertEquals("other-name-1", otherName.getContent());
assertNotNull(otherName.getCreatedDate().getValue());
assertNotNull(otherName.getLastModifiedDate().getValue());
assertEquals(Long.valueOf(0), otherName.getDisplayIndex());
assertEquals(Long.valueOf(1), otherName.getPutCode());
assertNotNull(otherName.getSource());
assertEquals(Visibility.PUBLIC, otherName.getVisibility());
assertNotNull(person.getResearcherUrls());
assertTrue(StringUtils.isNotBlank(person.getResearcherUrls().getPath()));
assertNotNull(person.getResearcherUrls().getLastModifiedDate().getValue());
assertNotNull(person.getResearcherUrls().getResearcherUrls().size());
ResearcherUrl rUrl = person.getResearcherUrls().getResearcherUrls().get(0);
assertNotNull(rUrl.getCreatedDate().getValue());
assertEquals(Long.valueOf(0), rUrl.getDisplayIndex());
assertNotNull(rUrl.getLastModifiedDate().getValue());
assertEquals(Long.valueOf(1248), rUrl.getPutCode());
assertNotNull(rUrl.getSource());
assertEquals("http://url.com/", rUrl.getUrl().getValue());
assertEquals("url-name-1", rUrl.getUrlName());
assertEquals(Visibility.PUBLIC, rUrl.getVisibility());
assertNotNull(person.getName());
Name name = person.getName();
assertTrue(StringUtils.isNotBlank(name.getPath()));
assertEquals("credit-name", name.getCreditName().getContent());
assertEquals("family-name", name.getFamilyName().getContent());
assertEquals("give-names", name.getGivenNames().getContent());
assertNotNull(name.getLastModifiedDate().getValue());
assertEquals(Visibility.PUBLIC, name.getVisibility());
}
use of com.alibaba.json.bvt.bug.Bug_for_issue_729.Person in project ORCID-Source by ORCID.
the class ValidateV2_1IdentifiersTest method testPerson.
/**
* <external-identifier:external-identifiers>
<external-identifier:external-identifier visibility="public" put-code="1">
<common:external-id-type>type-1</common:external-id-type>
<common:external-id-value>value-1</common:external-id-value>
<common:external-id-url>http://url.com/1</common:external-id-url>
<common:created-date>2001-12-31T12:00:00</common:created-date>
<common:last-modified-date>2001-12-31T12:00:00</common:last-modified-date>
<common:source>
<common:source-orcid>
<common:uri>https://orcid.org/8888-8888-8888-8880</common:uri>
<common:path>8888-8888-8888-8880</common:path>
<common:host>orcid.org</common:host>
</common:source-orcid>
<common:source-name />
</common:source>
</external-identifier:external-identifier>
</external-identifier:external-identifiers>
* @throws SAXException
* @throws IOException
* @throws JAXBException
* @throws ParserConfigurationException
*/
@Test
public void testPerson() throws SAXException, IOException, JAXBException, ParserConfigurationException {
Person person = unmarshallFromPath("/record_2.1/samples/read_samples/person-2.1.xml", Person.class);
assertEquals("credit-name", person.getName().getCreditName().getContent());
assertEquals(1, person.getExternalIdentifiers().getExternalIdentifiers().size());
PersonExternalIdentifier id = person.getExternalIdentifiers().getExternalIdentifiers().get(0);
assertEquals("type-1", id.getType());
assertEquals("value-1", id.getValue());
assertEquals(new Url("http://url.com/1"), id.getUrl());
assertNull(id.getRelationship());
assertNotNull(id.getCreatedDate().getValue());
assertNotNull(id.getLastModifiedDate().getValue());
assertEquals(new Long(1), id.getPutCode());
assertEquals(Visibility.PUBLIC, id.getVisibility());
Validator validator = getValidator("person");
validator.validate(marshall(Person.class, person));
validator.validate(marshallToDOM(Person.class, person));
}
use of com.alibaba.json.bvt.bug.Bug_for_issue_729.Person in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV2Test method getPersonElement.
private Person getPersonElement() {
Visibility[] vs = { Visibility.PUBLIC, Visibility.PUBLIC, Visibility.PUBLIC };
Person p = new Person();
p.setAddresses(getAddressesElement(vs));
p.setEmails(getEmailsElement(vs));
p.setExternalIdentifiers(getPersonExternalIdentifiersElement(vs));
p.setKeywords(getKeywordsElement(vs));
p.setOtherNames(getOtherNamesElement(vs));
p.setResearcherUrls(getResearcherUrlsElement(vs));
Name name = new Name();
name.setVisibility(Visibility.PUBLIC);
p.setName(name);
Biography b = new Biography();
b.setVisibility(Visibility.PUBLIC);
b.setContent("Biography test");
p.setBiography(b);
return p;
}
use of com.alibaba.json.bvt.bug.Bug_for_issue_729.Person 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 com.alibaba.json.bvt.bug.Bug_for_issue_729.Person in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV2Test method checkIsPublicRecordTest.
@Test
public void checkIsPublicRecordTest() {
Record r = getRecordElement();
publicAPISecurityManagerV2.filter(r);
// Verify activities - nothing filtered
ActivitiesSummary as = r.getActivitiesSummary();
assertEquals(3, as.getEducations().getSummaries().size());
assertContainerContainsOnlyPublicElements(as.getEducations());
assertEquals(3, as.getEmployments().getSummaries().size());
assertContainerContainsOnlyPublicElements(as.getEmployments());
assertEquals(3, as.getFundings().getFundingGroup().size());
assertGroupContainsOnlyPublicElements(as.getFundings());
assertEquals(3, as.getPeerReviews().getPeerReviewGroup().size());
assertGroupContainsOnlyPublicElements(as.getPeerReviews());
assertEquals(3, as.getWorks().getWorkGroup().size());
assertGroupContainsOnlyPublicElements(as.getWorks());
// Verify bio sections - nothing filtered
Person p = r.getPerson();
assertEquals(3, p.getAddresses().getAddress().size());
assertAllArePublic(p.getAddresses().getAddress());
assertEquals(3, p.getEmails().getEmails().size());
assertAllArePublic(p.getEmails().getEmails());
assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
assertAllArePublic(p.getExternalIdentifiers().getExternalIdentifiers());
assertEquals(3, p.getKeywords().getKeywords().size());
assertAllArePublic(p.getKeywords().getKeywords());
assertEquals(3, p.getOtherNames().getOtherNames().size());
assertAllArePublic(p.getOtherNames().getOtherNames());
assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
assertAllArePublic(p.getResearcherUrls().getResearcherUrls());
assertNotNull(p.getBiography());
assertNotNull(p.getName());
// Filter biography, name, educations and funding
r = getRecordElement();
r.getPerson().getBiography().setVisibility(Visibility.LIMITED);
r.getPerson().getName().setVisibility(Visibility.LIMITED);
setVisibility(r.getActivitiesSummary().getEducations().getSummaries(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
setVisibility(r.getActivitiesSummary().getFundings(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
publicAPISecurityManagerV2.filter(r);
// Verify activities - educations and funding filtered
as = r.getActivitiesSummary();
assertNotNull(as.getEducations());
assertTrue(as.getEducations().getSummaries().isEmpty());
assertEquals(3, as.getEmployments().getSummaries().size());
assertTrue(as.getFundings().getFundingGroup().isEmpty());
assertEquals(3, as.getPeerReviews().getPeerReviewGroup().size());
assertEquals(3, as.getWorks().getWorkGroup().size());
// Verify bio sections - bio and name filtered
p = r.getPerson();
assertEquals(3, p.getAddresses().getAddress().size());
assertEquals(3, p.getEmails().getEmails().size());
assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
assertEquals(3, p.getKeywords().getKeywords().size());
assertEquals(3, p.getOtherNames().getOtherNames().size());
assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
assertNull(p.getBiography());
assertNull(p.getName());
// Filter emails, external identifiers, peer reviews and works
r = getRecordElement();
setVisibility(r.getPerson().getEmails().getEmails(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
setVisibility(r.getPerson().getExternalIdentifiers().getExternalIdentifiers(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
setVisibility(r.getActivitiesSummary().getPeerReviews(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
setVisibility(r.getActivitiesSummary().getWorks(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
publicAPISecurityManagerV2.filter(r);
// Verify activities - peer reviews and works filtered
as = r.getActivitiesSummary();
assertEquals(3, as.getEducations().getSummaries().size());
assertEquals(3, as.getEmployments().getSummaries().size());
assertEquals(3, as.getFundings().getFundingGroup().size());
assertTrue(as.getPeerReviews().getPeerReviewGroup().isEmpty());
assertTrue(as.getWorks().getWorkGroup().isEmpty());
// Verify bio sections - emails, external identifiers filtered
p = r.getPerson();
assertEquals(3, p.getAddresses().getAddress().size());
assertNotNull(p.getEmails());
assertTrue(p.getEmails().getEmails().isEmpty());
assertNotNull(p.getExternalIdentifiers());
assertTrue(p.getExternalIdentifiers().getExternalIdentifiers().isEmpty());
assertEquals(3, p.getKeywords().getKeywords().size());
assertEquals(3, p.getOtherNames().getOtherNames().size());
assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
assertNotNull(p.getBiography());
assertNotNull(p.getName());
// Filter keywords and other names
r = getRecordElement();
setVisibility(r.getPerson().getOtherNames().getOtherNames(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
setVisibility(r.getPerson().getKeywords().getKeywords(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
publicAPISecurityManagerV2.filter(r);
// Verify activities - nothing filtered
as = r.getActivitiesSummary();
assertEquals(3, as.getEducations().getSummaries().size());
assertEquals(3, as.getEmployments().getSummaries().size());
assertEquals(3, as.getFundings().getFundingGroup().size());
assertEquals(3, as.getPeerReviews().getPeerReviewGroup().size());
assertEquals(3, as.getWorks().getWorkGroup().size());
// Verify bio sections - keywords and other names filtered
p = r.getPerson();
assertEquals(3, p.getAddresses().getAddress().size());
assertEquals(3, p.getEmails().getEmails().size());
assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
assertNotNull(p.getKeywords());
assertTrue(p.getKeywords().getKeywords().isEmpty());
assertNotNull(p.getOtherNames());
assertTrue(p.getOtherNames().getOtherNames().isEmpty());
assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
assertNotNull(p.getBiography());
assertNotNull(p.getName());
}
Aggregations