use of org.orcid.jaxb.model.v3.dev1.record.Emails in project ORCID-Source by ORCID.
the class ValidateV3_dev1SamplesTest 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;
} else if (Education.class.equals(type)) {
result = (Education) obj;
} else if (Educations.class.equals(type)) {
result = (Educations) obj;
} else if (Employment.class.equals(type)) {
result = (Employment) obj;
} else if (Employments.class.equals(type)) {
result = (Employments) obj;
} else if (Distinction.class.equals(type)) {
result = (Distinction) obj;
} else if (Distinctions.class.equals(type)) {
result = (Distinctions) obj;
} else if (InvitedPosition.class.equals(type)) {
result = (InvitedPosition) obj;
} else if (InvitedPositions.class.equals(type)) {
result = (InvitedPositions) obj;
} else if (Membership.class.equals(type)) {
result = (Membership) obj;
} else if (Memberships.class.equals(type)) {
result = (Memberships) obj;
} else if (Qualification.class.equals(type)) {
result = (Qualification) obj;
} else if (Qualifications.class.equals(type)) {
result = (Qualifications) obj;
} else if (Service.class.equals(type)) {
result = (Service) obj;
} else if (Services.class.equals(type)) {
result = (Services) obj;
}
return result;
} catch (IOException e) {
throw new RuntimeException("Error reading notification from classpath", e);
}
}
use of org.orcid.jaxb.model.v3.dev1.record.Emails in project ORCID-Source by ORCID.
the class PublicProfileControllerTest method testViewValidUser.
@SuppressWarnings("unchecked")
@Test
public void testViewValidUser() {
ModelAndView mav = publicProfileController.publicPreview(request, response, 1, 0, 15, userOrcid);
assertEquals("public_profile_v3", mav.getViewName());
Map<String, Object> model = mav.getModel();
assertNotNull(model);
assertTrue(model.containsKey("isPublicProfile"));
assertTrue(model.containsKey("effectiveUserOrcid"));
assertEquals(userOrcid, model.get("effectiveUserOrcid"));
assertTrue(model.containsKey("biography"));
Biography biography = (Biography) model.get("biography");
assertEquals("Biography for 0000-0000-0000-0003", biography.getContent());
assertTrue(model.containsKey("displayName"));
String displayName = (String) model.get("displayName");
assertEquals("Credit Name", displayName);
assertTrue(model.containsKey("title"));
assertEquals(localeManager.resolveMessage("layout.public-layout.title", displayName, userOrcid), model.get("title"));
assertTrue(model.containsKey("publicGroupedOtherNames"));
Map<String, List<OtherName>> groupedOtherNames = (Map<String, List<OtherName>>) model.get("publicGroupedOtherNames");
assertNotNull(groupedOtherNames);
assertEquals(1, groupedOtherNames.keySet().size());
assertTrue(groupedOtherNames.containsKey("Other Name PUBLIC"));
List<OtherName> publicOtherNames = groupedOtherNames.get("Other Name PUBLIC");
assertEquals(1, publicOtherNames.size());
assertEquals(Long.valueOf(13), publicOtherNames.get(0).getPutCode());
assertEquals("Other Name PUBLIC", publicOtherNames.get(0).getContent());
assertEquals(Visibility.PUBLIC, publicOtherNames.get(0).getVisibility());
assertTrue(model.containsKey("publicGroupedAddresses"));
Map<String, List<Address>> groupedAddresses = (Map<String, List<Address>>) model.get("publicGroupedAddresses");
assertNotNull(groupedAddresses);
assertEquals(1, groupedAddresses.keySet().size());
assertTrue(groupedAddresses.containsKey("US"));
List<Address> publicAddresses = groupedAddresses.get("US");
assertEquals(1, publicAddresses.size());
assertEquals(Long.valueOf(9), publicAddresses.get(0).getPutCode());
assertEquals(Iso3166Country.US, publicAddresses.get(0).getCountry().getValue());
assertEquals(Visibility.PUBLIC, publicAddresses.get(0).getVisibility());
assertTrue(model.containsKey("countryNames"));
Map<String, String> countryNames = (Map<String, String>) model.get("countryNames");
Map<String, String> testCountry = new HashMap<String, String>();
testCountry.put("US", localeManager.resolveMessage("org.orcid.persistence.jpa.entities.CountryIsoEntity.US"));
assertEquals(testCountry, countryNames);
assertTrue(model.containsKey("publicGroupedKeywords"));
Map<String, List<Keyword>> groupedKeywords = (Map<String, List<Keyword>>) model.get("publicGroupedKeywords");
assertNotNull(groupedKeywords);
assertEquals(1, groupedKeywords.keySet().size());
assertTrue(groupedKeywords.containsKey("PUBLIC"));
List<Keyword> publicKeywords = groupedKeywords.get("PUBLIC");
assertEquals(1, publicKeywords.size());
assertEquals(Long.valueOf(9), publicKeywords.get(0).getPutCode());
assertEquals("PUBLIC", publicKeywords.get(0).getContent());
assertEquals(Visibility.PUBLIC, publicKeywords.get(0).getVisibility());
assertTrue(model.containsKey("publicGroupedResearcherUrls"));
Map<String, List<ResearcherUrl>> rUrls = (Map<String, List<ResearcherUrl>>) model.get("publicGroupedResearcherUrls");
assertNotNull(rUrls);
assertEquals(1, rUrls.keySet().size());
assertTrue(rUrls.containsKey("http://www.researcherurl.com?id=13"));
List<ResearcherUrl> publicResearchUrls = rUrls.get("http://www.researcherurl.com?id=13");
assertEquals(Long.valueOf(13), publicResearchUrls.get(0).getPutCode());
assertEquals("public_rurl", publicResearchUrls.get(0).getUrlName());
assertEquals(Visibility.PUBLIC, publicResearchUrls.get(0).getVisibility());
assertTrue(model.containsKey("publicGroupedEmails"));
Map<String, List<Email>> emails = (Map<String, List<Email>>) model.get("publicGroupedEmails");
assertNotNull(emails);
assertEquals(1, emails.keySet().size());
assertTrue(emails.containsKey("public_0000-0000-0000-0003@test.orcid.org"));
List<Email> publicEmails = emails.get("public_0000-0000-0000-0003@test.orcid.org");
assertEquals("public_0000-0000-0000-0003@test.orcid.org", publicEmails.get(0).getEmail());
assertEquals(Visibility.PUBLIC, publicEmails.get(0).getVisibility());
assertTrue(model.containsKey("publicGroupedPersonExternalIdentifiers"));
Map<String, List<PersonExternalIdentifier>> extIds = (Map<String, List<PersonExternalIdentifier>>) model.get("publicGroupedPersonExternalIdentifiers");
assertNotNull(extIds);
assertEquals(1, extIds.keySet().size());
assertTrue(extIds.containsKey("public_type:public_ref"));
List<PersonExternalIdentifier> publicExternalIdentifiers = extIds.get("public_type:public_ref");
assertEquals(Long.valueOf(13), publicExternalIdentifiers.get(0).getPutCode());
assertEquals("http://ext-id/public_ref", publicExternalIdentifiers.get(0).getUrl().getValue());
assertEquals(Visibility.PUBLIC, publicExternalIdentifiers.get(0).getVisibility());
assertTrue(model.containsKey("affiliationIdsJson"));
assertEquals("[17,47,42,37,32,27,20]", model.get("affiliationIdsJson"));
assertTrue(model.containsKey("fundingIdsJson"));
assertEquals("[10]", model.get("fundingIdsJson"));
assertTrue(model.containsKey("peerReviewIdsJson"));
assertEquals("[9]", model.get("peerReviewIdsJson"));
assertTrue(model.containsKey("isProfileEmpty"));
Boolean isProfileEmpty = (Boolean) model.get("isProfileEmpty");
assertFalse(isProfileEmpty);
assertFalse(model.containsKey("noIndex"));
}
use of org.orcid.jaxb.model.v3.dev1.record.Emails in project ORCID-Source by ORCID.
the class PublicProfileControllerTest method testViewClaimedUserWhenIsLongEnough.
@Test
public void testViewClaimedUserWhenIsLongEnough() {
// Update the submission date so it is long enough
ProfileEntity profileEntity = profileDao.find(unclaimedUserOrcid);
profileEntity.setSubmissionDate(DateUtils.addDays(new Date(), -10));
profileDao.merge(profileEntity);
profileDao.flush();
ModelAndView mav = publicProfileController.publicPreview(request, response, 1, 0, 15, unclaimedUserOrcid);
assertEquals("public_profile_v3", mav.getViewName());
Map<String, Object> model = mav.getModel();
assertNotNull(model);
assertTrue(model.containsKey("isPublicProfile"));
assertTrue(model.containsKey("effectiveUserOrcid"));
assertEquals(unclaimedUserOrcid, model.get("effectiveUserOrcid"));
assertTrue(!model.containsKey("biography"));
assertFalse(model.containsKey("displayName"));
assertFalse(model.containsKey("title"));
assertTrue(model.containsKey("publicGroupedOtherNames"));
Map<String, List<OtherName>> groupedOtherNames = (Map<String, List<OtherName>>) model.get("publicGroupedOtherNames");
assertNotNull(groupedOtherNames);
assertEquals(1, groupedOtherNames.keySet().size());
List<OtherName> publicOtherNames = groupedOtherNames.get("PUBLIC");
assertEquals(1, publicOtherNames.size());
assertEquals(Long.valueOf(18), publicOtherNames.get(0).getPutCode());
assertEquals("PUBLIC", publicOtherNames.get(0).getContent());
assertEquals(Visibility.PUBLIC, publicOtherNames.get(0).getVisibility());
assertTrue(model.containsKey("publicGroupedAddresses"));
Map<String, List<Address>> groupedAddresses = (Map<String, List<Address>>) model.get("publicGroupedAddresses");
assertNotNull(groupedAddresses);
assertEquals(1, groupedAddresses.keySet().size());
assertTrue(groupedAddresses.containsKey("US"));
List<Address> publicAddresses = groupedAddresses.get("US");
assertEquals(1, publicAddresses.size());
assertEquals(Long.valueOf(14), publicAddresses.get(0).getPutCode());
assertEquals(Iso3166Country.US, publicAddresses.get(0).getCountry().getValue());
assertEquals(Visibility.PUBLIC, publicAddresses.get(0).getVisibility());
assertTrue(model.containsKey("publicGroupedKeywords"));
Map<String, List<Keyword>> groupedKeywords = (Map<String, List<Keyword>>) model.get("publicGroupedKeywords");
assertNotNull(groupedKeywords);
assertEquals(1, groupedKeywords.keySet().size());
List<Keyword> publicKeywords = groupedKeywords.get("PUBLIC");
assertEquals(Long.valueOf(14), publicKeywords.get(0).getPutCode());
assertEquals("PUBLIC", publicKeywords.get(0).getContent());
assertEquals(Visibility.PUBLIC, publicKeywords.get(0).getVisibility());
assertTrue(model.containsKey("publicGroupedResearcherUrls"));
Map<String, List<ResearcherUrl>> rUrls = (Map<String, List<ResearcherUrl>>) model.get("publicGroupedResearcherUrls");
assertNotNull(rUrls);
assertEquals(1, rUrls.keySet().size());
assertTrue(rUrls.containsKey("http://www.researcherurl.com?id=18"));
List<ResearcherUrl> publicResearchUrls = rUrls.get("http://www.researcherurl.com?id=18");
assertEquals(Long.valueOf(18), publicResearchUrls.get(0).getPutCode());
assertEquals("public", publicResearchUrls.get(0).getUrlName());
assertEquals(Visibility.PUBLIC, publicResearchUrls.get(0).getVisibility());
assertTrue(model.containsKey("publicGroupedEmails"));
Map<String, List<Email>> emails = (Map<String, List<Email>>) model.get("publicGroupedEmails");
assertNotNull(emails);
assertEquals(1, emails.keySet().size());
List<Email> groupedEmails = emails.get("public_0000-0000-0000-0001@test.orcid.org");
assertEquals("public_0000-0000-0000-0001@test.orcid.org", groupedEmails.get(0).getEmail());
assertEquals(Visibility.PUBLIC, groupedEmails.get(0).getVisibility());
assertTrue(model.containsKey("publicGroupedPersonExternalIdentifiers"));
Map<String, List<PersonExternalIdentifier>> extIds = (Map<String, List<PersonExternalIdentifier>>) model.get("publicGroupedPersonExternalIdentifiers");
assertNotNull(extIds);
assertEquals(1, extIds.keySet().size());
assertTrue(extIds.containsKey("public:public"));
List<PersonExternalIdentifier> publicExternalIdentifiers = extIds.get("public:public");
assertEquals(Long.valueOf(18), publicExternalIdentifiers.get(0).getPutCode());
assertEquals("http://ext-id/self/public", publicExternalIdentifiers.get(0).getUrl().getValue());
assertEquals(Visibility.PUBLIC, publicExternalIdentifiers.get(0).getVisibility());
assertTrue(model.containsKey("isProfileEmpty"));
Boolean isProfileEmpty = (Boolean) model.get("isProfileEmpty");
assertTrue(isProfileEmpty);
assertFalse(model.containsKey("noIndex"));
// Update the submission date so it is not long enough
profileEntity = profileDao.find(unclaimedUserOrcid);
profileEntity.setSubmissionDate(new Date());
profileDao.merge(profileEntity);
profileDao.flush();
}
use of org.orcid.jaxb.model.v3.dev1.record.Emails in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_EmailsTest method testReadPublicScope_Emails.
@Test
public void testReadPublicScope_Emails() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
Response r = serviceDelegator.viewEmails(ORCID);
assertNotNull(r);
assertEquals(Emails.class.getName(), r.getEntity().getClass().getName());
Emails email = (Emails) r.getEntity();
assertNotNull(email);
assertEquals("/0000-0000-0000-0003/email", email.getPath());
Utils.verifyLastModified(email.getLastModifiedDate());
assertEquals(3, email.getEmails().size());
boolean found1 = false;
boolean found2 = false;
boolean found3 = false;
for (Email element : email.getEmails()) {
Utils.verifyLastModified(element.getLastModifiedDate());
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 put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
}
use of org.orcid.jaxb.model.v3.dev1.record.Emails in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_EmailsTest method testViewEmailsReadPublic.
@Test
public void testViewEmailsReadPublic() {
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
Response r = serviceDelegator.viewEmails(ORCID);
Emails element = (Emails) r.getEntity();
assertNotNull(element);
assertEquals("/0000-0000-0000-0003/email", element.getPath());
Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
Aggregations