use of org.orcid.jaxb.model.record_rc3.Email in project ORCID-Source by ORCID.
the class OrcidSecurityManager_EmailTest method testEmail_ReadPrivate_onePrivate.
@Test
public void testEmail_ReadPrivate_onePrivate() {
SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.EMAIL_READ_PRIVATE);
Email e1 = createEmail(Visibility.PUBLIC, CLIENT_2);
Email e2 = createEmail(Visibility.LIMITED, CLIENT_2);
Email e3 = createEmail(Visibility.PRIVATE, CLIENT_2);
List<Email> emails = new ArrayList<Email>(Arrays.asList(e1, e2, e3));
orcidSecurityManager.checkAndFilter(ORCID_1, emails, ScopePathType.ORCID_BIO_READ_LIMITED);
assertEquals(3, emails.size());
assertTrue(emails.contains(e1));
assertTrue(emails.contains(e2));
assertTrue(emails.contains(e3));
}
use of org.orcid.jaxb.model.record_rc3.Email in project ORCID-Source by ORCID.
the class RecordTest method testViewRecordFromPublicAPI.
@Test
public void testViewRecordFromPublicAPI() {
ClientResponse response = publicV2ApiClient.viewRecordXML(getUser1OrcidId());
assertNotNull(response);
assertEquals("invalid " + response, 200, response.getStatus());
Record record = response.getEntity(Record.class);
assertNotNull(record);
assertNotNull(record.getOrcidIdentifier());
assertEquals(getUser1OrcidId(), record.getOrcidIdentifier().getPath());
//Check the visibility of every activity that exists
if (record.getActivitiesSummary() != null) {
if (record.getActivitiesSummary() != null) {
//Educations
if (record.getActivitiesSummary().getEducations() != null) {
Educations e = record.getActivitiesSummary().getEducations();
if (e.getSummaries() != null) {
for (EducationSummary s : e.getSummaries()) {
assertNotNull(s.getSource());
assertEquals(Visibility.PUBLIC, s.getVisibility());
}
}
}
//Employments
if (record.getActivitiesSummary().getEmployments() != null) {
Employments e = record.getActivitiesSummary().getEmployments();
if (e.getSummaries() != null) {
for (EmploymentSummary s : e.getSummaries()) {
assertNotNull(s.getSource());
assertEquals(Visibility.PUBLIC, s.getVisibility());
}
}
}
//Fundings
if (record.getActivitiesSummary().getFundings() != null) {
Fundings f = record.getActivitiesSummary().getFundings();
List<FundingGroup> groups = f.getFundingGroup();
if (groups != null) {
for (FundingGroup fGroup : groups) {
List<FundingSummary> summaries = fGroup.getFundingSummary();
if (summaries != null) {
for (FundingSummary s : summaries) {
assertNotNull(s.getSource());
assertEquals(Visibility.PUBLIC, s.getVisibility());
}
}
}
}
}
//PeerReviews
if (record.getActivitiesSummary().getPeerReviews() != null) {
PeerReviews p = record.getActivitiesSummary().getPeerReviews();
List<PeerReviewGroup> groups = p.getPeerReviewGroup();
if (groups != null) {
for (PeerReviewGroup pGroup : groups) {
List<PeerReviewSummary> summaries = pGroup.getPeerReviewSummary();
if (summaries != null) {
for (PeerReviewSummary s : summaries) {
assertNotNull(s.getSource());
assertEquals(Visibility.PUBLIC, s.getVisibility());
}
}
}
}
}
//Works
if (record.getActivitiesSummary().getWorks() != null) {
Works w = record.getActivitiesSummary().getWorks();
List<WorkGroup> groups = w.getWorkGroup();
if (groups != null) {
for (WorkGroup wGroup : groups) {
List<WorkSummary> summaries = wGroup.getWorkSummary();
if (summaries != null) {
for (WorkSummary s : summaries) {
assertNotNull(s.getSource());
assertEquals(Visibility.PUBLIC, s.getVisibility());
}
}
}
}
}
}
}
//Check the visibility of every biography elements that exists
if (record.getPerson() != null) {
//Address
if (record.getPerson().getAddresses() != null) {
Addresses addresses = record.getPerson().getAddresses();
List<Address> list = addresses.getAddress();
if (list != null) {
for (Address o : list) {
assertNotNull(o.getSource());
assertEquals(Visibility.PUBLIC, o.getVisibility());
}
}
}
//Biography
if (record.getPerson().getBiography() != null) {
Biography b = record.getPerson().getBiography();
if (b != null) {
assertNotNull(b.getVisibility());
assertEquals(Visibility.PUBLIC, b.getVisibility());
}
}
//Emails
if (record.getPerson().getEmails() != null) {
Emails emails = record.getPerson().getEmails();
List<Email> list = emails.getEmails();
if (list != null) {
for (Email e : list) {
assertNotNull(e.getVisibility());
assertEquals(Visibility.PUBLIC, e.getVisibility());
}
}
}
//External identifiers
if (record.getPerson().getExternalIdentifiers() != null) {
PersonExternalIdentifiers extIds = record.getPerson().getExternalIdentifiers();
List<PersonExternalIdentifier> list = extIds.getExternalIdentifiers();
if (list != null) {
for (PersonExternalIdentifier e : list) {
assertEquals(Visibility.PUBLIC, e.getVisibility());
}
}
}
//Keywords
if (record.getPerson().getKeywords() != null) {
Keywords keywords = record.getPerson().getKeywords();
List<Keyword> list = keywords.getKeywords();
if (list != null) {
for (Keyword e : list) {
assertEquals(Visibility.PUBLIC, e.getVisibility());
}
}
}
//Name
if (record.getPerson().getName() != null) {
Name name = record.getPerson().getName();
assertEquals(Visibility.PUBLIC, name.getVisibility());
}
//Other names
if (record.getPerson().getOtherNames() != null) {
OtherNames otherNames = record.getPerson().getOtherNames();
List<OtherName> list = otherNames.getOtherNames();
if (list != null) {
for (OtherName e : list) {
assertEquals(Visibility.PUBLIC, e.getVisibility());
}
}
}
//Researcher urls
if (record.getPerson().getResearcherUrls() != null) {
ResearcherUrls rUrls = record.getPerson().getResearcherUrls();
List<ResearcherUrl> list = rUrls.getResearcherUrls();
if (list != null) {
for (ResearcherUrl e : list) {
assertEquals(Visibility.PUBLIC, e.getVisibility());
}
}
}
}
}
use of org.orcid.jaxb.model.record_rc3.Email in project ORCID-Source by ORCID.
the class RecordTest method testViewRecordFromPublicAPI.
@Test
public void testViewRecordFromPublicAPI() {
ClientResponse response = publicV2ApiClient.viewRecordXML(getUser1OrcidId());
assertNotNull(response);
assertEquals("invalid " + response, 200, response.getStatus());
Record record = response.getEntity(Record.class);
assertNotNull(record);
assertNotNull(record.getOrcidIdentifier());
assertEquals(getUser1OrcidId(), record.getOrcidIdentifier().getPath());
//Check the visibility of every activity that exists
if (record.getActivitiesSummary() != null) {
if (record.getActivitiesSummary() != null) {
//Educations
if (record.getActivitiesSummary().getEducations() != null) {
Educations e = record.getActivitiesSummary().getEducations();
if (e.getSummaries() != null) {
for (EducationSummary s : e.getSummaries()) {
assertNotNull(s.getSource());
assertEquals(Visibility.PUBLIC, s.getVisibility());
}
}
}
//Employments
if (record.getActivitiesSummary().getEmployments() != null) {
Employments e = record.getActivitiesSummary().getEmployments();
if (e.getSummaries() != null) {
for (EmploymentSummary s : e.getSummaries()) {
assertNotNull(s.getSource());
assertEquals(Visibility.PUBLIC, s.getVisibility());
}
}
}
//Fundings
if (record.getActivitiesSummary().getFundings() != null) {
Fundings f = record.getActivitiesSummary().getFundings();
List<FundingGroup> groups = f.getFundingGroup();
if (groups != null) {
for (FundingGroup fGroup : groups) {
List<FundingSummary> summaries = fGroup.getFundingSummary();
if (summaries != null) {
for (FundingSummary s : summaries) {
assertNotNull(s.getSource());
assertEquals(Visibility.PUBLIC, s.getVisibility());
}
}
}
}
}
//PeerReviews
if (record.getActivitiesSummary().getPeerReviews() != null) {
PeerReviews p = record.getActivitiesSummary().getPeerReviews();
List<PeerReviewGroup> groups = p.getPeerReviewGroup();
if (groups != null) {
for (PeerReviewGroup pGroup : groups) {
List<PeerReviewSummary> summaries = pGroup.getPeerReviewSummary();
if (summaries != null) {
for (PeerReviewSummary s : summaries) {
assertNotNull(s.getSource());
assertEquals(Visibility.PUBLIC, s.getVisibility());
}
}
}
}
}
//Works
if (record.getActivitiesSummary().getWorks() != null) {
Works w = record.getActivitiesSummary().getWorks();
List<WorkGroup> groups = w.getWorkGroup();
if (groups != null) {
for (WorkGroup wGroup : groups) {
List<WorkSummary> summaries = wGroup.getWorkSummary();
if (summaries != null) {
for (WorkSummary s : summaries) {
assertNotNull(s.getSource());
assertEquals(Visibility.PUBLIC, s.getVisibility());
}
}
}
}
}
}
}
//Check the visibility of every biography elements that exists
if (record.getPerson() != null) {
//Address
if (record.getPerson().getAddresses() != null) {
Addresses addresses = record.getPerson().getAddresses();
List<Address> list = addresses.getAddress();
if (list != null) {
for (Address o : list) {
assertNotNull(o.getSource());
assertEquals(Visibility.PUBLIC, o.getVisibility());
}
}
}
//Biography
if (record.getPerson().getBiography() != null) {
Biography b = record.getPerson().getBiography();
if (b != null) {
assertNotNull(b.getVisibility());
assertEquals(Visibility.PUBLIC, b.getVisibility());
}
}
//Emails
if (record.getPerson().getEmails() != null) {
Emails emails = record.getPerson().getEmails();
List<Email> list = emails.getEmails();
if (list != null) {
for (Email e : list) {
assertNotNull(e.getVisibility());
assertEquals(Visibility.PUBLIC, e.getVisibility());
}
}
}
//External identifiers
if (record.getPerson().getExternalIdentifiers() != null) {
PersonExternalIdentifiers extIds = record.getPerson().getExternalIdentifiers();
List<PersonExternalIdentifier> list = extIds.getExternalIdentifiers();
if (list != null) {
for (PersonExternalIdentifier e : list) {
assertEquals(Visibility.PUBLIC, e.getVisibility());
}
}
}
//Keywords
if (record.getPerson().getKeywords() != null) {
Keywords keywords = record.getPerson().getKeywords();
List<Keyword> list = keywords.getKeywords();
if (list != null) {
for (Keyword e : list) {
assertEquals(Visibility.PUBLIC, e.getVisibility());
}
}
}
//Name
if (record.getPerson().getName() != null) {
Name name = record.getPerson().getName();
assertEquals(Visibility.PUBLIC, name.getVisibility());
}
//Other names
if (record.getPerson().getOtherNames() != null) {
OtherNames otherNames = record.getPerson().getOtherNames();
List<OtherName> list = otherNames.getOtherNames();
if (list != null) {
for (OtherName e : list) {
assertEquals(Visibility.PUBLIC, e.getVisibility());
}
}
}
//Researcher urls
if (record.getPerson().getResearcherUrls() != null) {
ResearcherUrls rUrls = record.getPerson().getResearcherUrls();
List<ResearcherUrl> list = rUrls.getResearcherUrls();
if (list != null) {
for (ResearcherUrl e : list) {
assertEquals(Visibility.PUBLIC, e.getVisibility());
}
}
}
}
}
use of org.orcid.jaxb.model.record_rc3.Email in project ORCID-Source by ORCID.
the class ValidateV2SamplesTest method testUnmarshallPerson.
@Test
public void testUnmarshallPerson() throws SAXException, URISyntaxException {
Person person = (Person) unmarshallFromPath("/record_2.0/samples/read_samples/person-2.0.xml", Person.class, "/record_2.0/person-2.0.xsd");
assertNotNull(person);
assertNotNull(person.getName());
assertEquals("give-names", person.getName().getGivenNames().getContent());
assertEquals("family-name", person.getName().getFamilyName().getContent());
assertEquals("credit-name", person.getName().getCreditName().getContent());
assertEquals(Visibility.PUBLIC, person.getName().getVisibility());
assertNotNull(person.getOtherNames());
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());
assertNotNull(otherName.getCreatedDate().getValue());
assertEquals(2001, otherName.getCreatedDate().getValue().getYear());
assertEquals(12, otherName.getCreatedDate().getValue().getMonth());
assertEquals(31, otherName.getCreatedDate().getValue().getDay());
assertNotNull(otherName.getLastModifiedDate().getValue());
assertEquals(2001, otherName.getLastModifiedDate().getValue().getYear());
assertEquals(12, otherName.getLastModifiedDate().getValue().getMonth());
assertEquals(31, otherName.getLastModifiedDate().getValue().getDay());
assertNotNull(otherName.getSource());
assertEquals("8888-8888-8888-8880", otherName.getSource().retrieveSourcePath());
assertNotNull(person.getBiography());
assertEquals(Visibility.PUBLIC, person.getBiography().getVisibility());
assertEquals("biography", person.getBiography().getContent());
assertNotNull(person.getResearcherUrls());
assertNotNull(person.getResearcherUrls().getResearcherUrls());
assertEquals(1, person.getResearcherUrls().getResearcherUrls().size());
ResearcherUrl rUrl = person.getResearcherUrls().getResearcherUrls().get(0);
assertEquals(Visibility.PUBLIC, rUrl.getVisibility());
assertEquals(Long.valueOf(1248), rUrl.getPutCode());
assertEquals("url-name-1", rUrl.getUrlName());
assertNotNull(rUrl.getUrl());
assertEquals("http://url.com/", rUrl.getUrl().getValue());
assertNotNull(rUrl.getCreatedDate());
assertEquals(2001, rUrl.getCreatedDate().getValue().getYear());
assertEquals(12, rUrl.getCreatedDate().getValue().getMonth());
assertEquals(31, rUrl.getCreatedDate().getValue().getDay());
assertNotNull(rUrl.getLastModifiedDate());
assertEquals(2001, rUrl.getLastModifiedDate().getValue().getYear());
assertEquals(12, rUrl.getLastModifiedDate().getValue().getMonth());
assertEquals(31, rUrl.getLastModifiedDate().getValue().getDay());
assertNotNull(rUrl.getSource());
assertEquals("8888-8888-8888-8880", rUrl.getSource().retrieveSourcePath());
assertNotNull(person.getEmails());
assertNotNull(person.getEmails().getEmails());
assertEquals(1, person.getEmails().getEmails().size());
Email email = person.getEmails().getEmails().get(0);
assertEquals(Visibility.PUBLIC, email.getVisibility());
assertEquals("user1@email.com", email.getEmail());
assertNotNull(email.getCreatedDate());
assertNotNull(email.getCreatedDate().getValue());
assertEquals(2001, email.getCreatedDate().getValue().getYear());
assertEquals(12, email.getCreatedDate().getValue().getMonth());
assertEquals(31, email.getCreatedDate().getValue().getDay());
assertNotNull(email.getLastModifiedDate());
assertNotNull(email.getLastModifiedDate().getValue());
assertEquals(2001, email.getLastModifiedDate().getValue().getYear());
assertEquals(12, email.getLastModifiedDate().getValue().getMonth());
assertEquals(31, email.getLastModifiedDate().getValue().getDay());
assertNotNull(email.getSource());
assertEquals("8888-8888-8888-8880", email.retrieveSourcePath());
assertNotNull(person.getAddresses());
assertNotNull(person.getAddresses().getAddress());
assertEquals(1, person.getAddresses().getAddress().size());
Address address = person.getAddresses().getAddress().get(0);
assertEquals(Visibility.PUBLIC, address.getVisibility());
assertEquals(Long.valueOf(1), address.getPutCode());
assertNotNull(address.getCountry());
assertEquals(Iso3166Country.US, address.getCountry().getValue());
assertNotNull(address.getCreatedDate());
assertNotNull(address.getCreatedDate().getValue());
assertEquals(2001, address.getCreatedDate().getValue().getYear());
assertEquals(12, address.getCreatedDate().getValue().getMonth());
assertEquals(31, address.getCreatedDate().getValue().getDay());
assertNotNull(address.getLastModifiedDate());
assertNotNull(address.getLastModifiedDate().getValue());
assertEquals(2001, address.getLastModifiedDate().getValue().getYear());
assertEquals(12, address.getLastModifiedDate().getValue().getMonth());
assertEquals(31, address.getLastModifiedDate().getValue().getDay());
assertNotNull(address.getSource());
assertEquals("8888-8888-8888-8880", address.getSource().retrieveSourcePath());
assertNotNull(person.getKeywords());
assertNotNull(person.getKeywords().getKeywords());
assertEquals(1, person.getKeywords().getKeywords().size());
Keyword keyword = person.getKeywords().getKeywords().get(0);
assertEquals(Visibility.PUBLIC, keyword.getVisibility());
assertEquals(Long.valueOf(1), keyword.getPutCode());
assertEquals("keyword1", keyword.getContent());
assertNotNull(keyword.getCreatedDate());
assertNotNull(keyword.getCreatedDate().getValue());
assertEquals(2001, keyword.getCreatedDate().getValue().getYear());
assertEquals(12, keyword.getCreatedDate().getValue().getMonth());
assertEquals(31, keyword.getCreatedDate().getValue().getDay());
assertNotNull(keyword.getLastModifiedDate());
assertNotNull(keyword.getLastModifiedDate().getValue());
assertEquals(2001, keyword.getLastModifiedDate().getValue().getYear());
assertEquals(12, keyword.getLastModifiedDate().getValue().getMonth());
assertEquals(31, keyword.getLastModifiedDate().getValue().getDay());
assertNotNull(keyword.getSource());
assertEquals("8888-8888-8888-8880", keyword.getSource().retrieveSourcePath());
assertNotNull(person.getExternalIdentifiers());
assertNotNull(person.getExternalIdentifiers().getExternalIdentifiers());
assertEquals(1, person.getExternalIdentifiers().getExternalIdentifiers().size());
PersonExternalIdentifier extId = person.getExternalIdentifiers().getExternalIdentifiers().get(0);
assertEquals(Visibility.PUBLIC, extId.getVisibility());
assertEquals(Long.valueOf(1), extId.getPutCode());
assertEquals("type-1", extId.getType());
assertEquals("value-1", extId.getValue());
assertNotNull(extId.getUrl());
assertEquals("http://url.com/1", extId.getUrl().getValue());
assertNotNull(extId.getCreatedDate());
assertNotNull(extId.getCreatedDate().getValue());
assertEquals(2001, extId.getCreatedDate().getValue().getYear());
assertEquals(12, extId.getCreatedDate().getValue().getMonth());
assertEquals(31, extId.getCreatedDate().getValue().getDay());
assertNotNull(extId.getLastModifiedDate());
assertNotNull(extId.getLastModifiedDate().getValue());
assertEquals(2001, extId.getLastModifiedDate().getValue().getYear());
assertEquals(12, extId.getLastModifiedDate().getValue().getMonth());
assertEquals(31, extId.getLastModifiedDate().getValue().getDay());
assertNotNull(extId.getSource());
assertEquals("8888-8888-8888-8880", extId.getSource().retrieveSourcePath());
}
use of org.orcid.jaxb.model.record_rc3.Email in project ORCID-Source by ORCID.
the class ValidateV2SamplesTest method unmarshallFromPath.
private Object unmarshallFromPath(String path, Class<?> type, String schemaPath) throws SAXException, URISyntaxException {
try (Reader reader = new InputStreamReader(getClass().getResourceAsStream(path))) {
Object obj = unmarshall(reader, type, schemaPath);
Object result = null;
if (ResearcherUrls.class.equals(type)) {
result = (ResearcherUrls) obj;
} else if (ResearcherUrl.class.equals(type)) {
result = (ResearcherUrl) obj;
} else if (PersonalDetails.class.equals(type)) {
result = (PersonalDetails) obj;
} else if (PersonExternalIdentifier.class.equals(type)) {
result = (PersonExternalIdentifier) obj;
} else if (PersonExternalIdentifiers.class.equals(type)) {
result = (PersonExternalIdentifiers) obj;
} else if (Biography.class.equals(type)) {
result = (Biography) obj;
} else if (Name.class.equals(type)) {
result = (Name) obj;
} else if (CreditName.class.equals(type)) {
result = (CreditName) obj;
} else if (OtherName.class.equals(type)) {
result = (OtherName) obj;
} else if (OtherNames.class.equals(type)) {
result = (OtherNames) obj;
} else if (Keywords.class.equals(type)) {
result = (Keywords) obj;
} else if (Keyword.class.equals(type)) {
result = (Keyword) obj;
} else if (Addresses.class.equals(type)) {
result = (Addresses) obj;
} else if (Address.class.equals(type)) {
result = (Address) obj;
} else if (Emails.class.equals(type)) {
result = (Emails) obj;
} else if (Email.class.equals(type)) {
result = (Email) obj;
} else if (Person.class.equals(type)) {
result = (Person) obj;
} else if (Deprecated.class.equals(type)) {
result = (Deprecated) obj;
} else if (Preferences.class.equals(type)) {
result = (Preferences) obj;
} else if (History.class.equals(type)) {
result = (History) obj;
} else if (Record.class.equals(type)) {
result = (Record) obj;
} else if (ActivitiesSummary.class.equals(type)) {
result = (ActivitiesSummary) obj;
} else if (Works.class.equals(type)) {
result = (Works) obj;
}
return result;
} catch (IOException e) {
throw new RuntimeException("Error reading notification from classpath", e);
}
}
Aggregations