use of org.orcid.jaxb.model.v3.dev1.record.Biography in project ORCID-Source by ORCID.
the class ManageProfileControllerTest method testValidateBiography.
@Test
public void testValidateBiography() {
BiographyManager mockBiographyManager = Mockito.mock(BiographyManager.class);
SecurityContextHolder.getContext().setAuthentication(getAuthentication(USER_ORCID));
TargetProxyHelper.injectIntoProxy(controller, "biographyManager", mockBiographyManager);
when(mockBiographyManager.exists(Mockito.anyString())).thenReturn(true);
BiographyForm bf = new BiographyForm();
bf.setVisibility(org.orcid.pojo.ajaxForm.Visibility.valueOf(Visibility.PUBLIC));
// No NPE exception on empty bio
controller.setBiographyFormJson(bf);
assertNotNull(bf.getErrors());
assertTrue(bf.getErrors().isEmpty());
String bio = StringUtils.repeat('a', 5001);
bf.setBiography(Text.valueOf(bio));
controller.setBiographyFormJson(bf);
assertEquals(1, bf.getErrors().size());
assertEquals("Length.changePersonalInfoForm.biography", bf.getErrors().get(0));
bio = StringUtils.repeat('a', 5000);
bf.setBiography(Text.valueOf(bio));
bf.setVisibility(null);
controller.setBiographyFormJson(bf);
assertEquals(1, bf.getErrors().size());
assertEquals("common.visibility.not_blank", bf.getErrors().get(0));
bf.setBiography(Text.valueOf(bio));
bf.setVisibility(org.orcid.pojo.ajaxForm.Visibility.valueOf(Visibility.PUBLIC));
controller.setBiographyFormJson(bf);
assertTrue(bf.getErrors().isEmpty());
Biography bioElement = new Biography();
bioElement.setContent(bio);
bioElement.setVisibility(Visibility.PUBLIC);
verify(mockBiographyManager, times(1)).updateBiography(Mockito.eq(USER_ORCID), Mockito.eq(bioElement));
}
use of org.orcid.jaxb.model.v3.dev1.record.Biography 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.Biography 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.Biography in project ORCID-Source by ORCID.
the class PublicV3ApiServiceDelegatorTest method validatePerson.
private void validatePerson(Person person) {
assertNotNull(person);
assertNotNull(person.getLastModifiedDate());
assertNotNull(person.getLastModifiedDate().getValue());
assertNotNull(person.getAddresses());
assertEquals("/0000-0000-0000-0003/address", person.getAddresses().getPath());
assertNotNull(person.getAddresses().getLastModifiedDate());
assertNotNull(person.getAddresses().getLastModifiedDate().getValue());
assertEquals(1, person.getAddresses().getAddress().size());
Address address = person.getAddresses().getAddress().get(0);
assertEquals(Iso3166Country.US, address.getCountry().getValue());
assertEquals(Visibility.PUBLIC.value(), address.getVisibility().value());
assertEquals(Long.valueOf(9), address.getPutCode());
assertEquals("/0000-0000-0000-0003/address/9", address.getPath());
assertEquals("APP-5555555555555555", address.getSource().retrieveSourcePath());
assertNotNull(person.getBiography());
assertEquals(Visibility.PUBLIC.value(), person.getBiography().getVisibility().value());
assertEquals("Biography for 0000-0000-0000-0003", person.getBiography().getContent());
assertNotNull(person.getBiography().getLastModifiedDate());
assertNotNull(person.getBiography().getLastModifiedDate().getValue());
assertEquals("/0000-0000-0000-0003/biography", person.getBiography().getPath());
assertNotNull(person.getEmails());
assertNotNull(person.getEmails().getLastModifiedDate());
assertNotNull(person.getEmails().getLastModifiedDate().getValue());
assertEquals(1, person.getEmails().getEmails().size());
Email email = person.getEmails().getEmails().get(0);
assertEquals("public_0000-0000-0000-0003@test.orcid.org", email.getEmail());
assertNotNull(email.getLastModifiedDate());
assertNotNull(email.getLastModifiedDate().getValue());
assertEquals("APP-5555555555555555", email.getSource().retrieveSourcePath());
assertEquals(Visibility.PUBLIC.value(), email.getVisibility().value());
assertNotNull(person.getExternalIdentifiers());
assertNotNull(person.getExternalIdentifiers().getLastModifiedDate());
assertNotNull(person.getExternalIdentifiers().getLastModifiedDate().getValue());
assertEquals("/0000-0000-0000-0003/external-identifiers", person.getExternalIdentifiers().getPath());
assertEquals(1, person.getExternalIdentifiers().getExternalIdentifiers().size());
PersonExternalIdentifier extId = person.getExternalIdentifiers().getExternalIdentifiers().get(0);
assertNotNull(extId);
assertNotNull(extId.getLastModifiedDate());
assertNotNull(extId.getLastModifiedDate().getValue());
assertEquals(Long.valueOf(13), extId.getPutCode());
assertEquals("public_type", extId.getType());
assertNotNull(extId.getUrl());
assertEquals("http://ext-id/public_ref", extId.getUrl().getValue());
assertEquals(Visibility.PUBLIC.value(), extId.getVisibility().value());
assertEquals("/0000-0000-0000-0003/external-identifiers/13", extId.getPath());
assertEquals("APP-5555555555555555", extId.getSource().retrieveSourcePath());
assertNotNull(person.getKeywords());
assertNotNull(person.getKeywords().getLastModifiedDate());
assertNotNull(person.getKeywords().getLastModifiedDate().getValue());
assertEquals(1, person.getKeywords().getKeywords().size());
assertNotNull(person.getKeywords().getLastModifiedDate());
assertEquals("/0000-0000-0000-0003/keywords", person.getKeywords().getPath());
Keyword keyword = person.getKeywords().getKeywords().get(0);
assertNotNull(keyword);
assertNotNull(keyword.getLastModifiedDate());
assertNotNull(keyword.getLastModifiedDate().getValue());
assertEquals(Long.valueOf(9), keyword.getPutCode());
assertEquals("PUBLIC", keyword.getContent());
assertEquals(Visibility.PUBLIC.value(), keyword.getVisibility().value());
assertEquals("/0000-0000-0000-0003/keywords/9", keyword.getPath());
assertEquals("APP-5555555555555555", keyword.getSource().retrieveSourcePath());
assertNotNull(person.getName());
assertNotNull(person.getName().getLastModifiedDate());
assertNotNull(person.getName().getLastModifiedDate().getValue());
assertEquals("Credit Name", person.getName().getCreditName().getContent());
assertEquals("Family Name", person.getName().getFamilyName().getContent());
assertEquals("Given Names", person.getName().getGivenNames().getContent());
assertEquals(Visibility.PUBLIC.value(), person.getName().getVisibility().value());
assertNotNull(person.getOtherNames());
assertEquals("/0000-0000-0000-0003/other-names", person.getOtherNames().getPath());
assertNotNull(person.getOtherNames().getLastModifiedDate());
assertNotNull(person.getOtherNames().getLastModifiedDate().getValue());
assertEquals(1, person.getOtherNames().getOtherNames().size());
OtherName otherName = person.getOtherNames().getOtherNames().get(0);
assertEquals("Other Name PUBLIC", otherName.getContent());
assertNotNull(otherName.getLastModifiedDate());
assertNotNull(otherName.getLastModifiedDate().getValue());
assertEquals("/0000-0000-0000-0003/other-names/13", otherName.getPath());
assertEquals(Long.valueOf(13), otherName.getPutCode());
assertEquals("APP-5555555555555555", otherName.getSource().retrieveSourcePath());
assertEquals(Visibility.PUBLIC.value(), otherName.getVisibility().value());
assertNotNull(person.getResearcherUrls());
assertEquals(1, person.getResearcherUrls().getResearcherUrls().size());
assertNotNull(person.getResearcherUrls().getLastModifiedDate());
assertNotNull(person.getResearcherUrls().getLastModifiedDate().getValue());
assertEquals("/0000-0000-0000-0003/researcher-urls", person.getResearcherUrls().getPath());
ResearcherUrl rUrl = person.getResearcherUrls().getResearcherUrls().get(0);
assertNotNull(rUrl);
assertNotNull(rUrl.getLastModifiedDate());
assertNotNull(rUrl.getLastModifiedDate().getValue());
assertNotNull(rUrl.getUrl());
assertEquals("http://www.researcherurl.com?id=13", rUrl.getUrl().getValue());
assertEquals("public_rurl", rUrl.getUrlName());
assertEquals(Visibility.PUBLIC.value(), rUrl.getVisibility().value());
assertEquals("/0000-0000-0000-0003/researcher-urls/13", rUrl.getPath());
assertEquals("APP-5555555555555555", rUrl.getSource().retrieveSourcePath());
assertEquals("/0000-0000-0000-0003/person", person.getPath());
}
use of org.orcid.jaxb.model.v3.dev1.record.Biography in project ORCID-Source by ORCID.
the class PublicV3ApiServiceDelegatorTest method testFindPersonalDetails.
@Test
public void testFindPersonalDetails() {
Response response = serviceDelegator.viewPersonalDetails(ORCID);
assertNotNull(response);
PersonalDetails personalDetails = (PersonalDetails) response.getEntity();
assertNotNull(personalDetails);
assertNotNull(personalDetails.getLastModifiedDate());
assertNotNull(personalDetails.getLastModifiedDate().getValue());
assertNotNull(personalDetails.getBiography());
assertNotNull(personalDetails.getBiography().getLastModifiedDate());
assertNotNull(personalDetails.getBiography().getLastModifiedDate().getValue());
assertEquals("Biography for 0000-0000-0000-0003", personalDetails.getBiography().getContent());
assertEquals(Visibility.PUBLIC.value(), personalDetails.getBiography().getVisibility().value());
assertEquals("/0000-0000-0000-0003/biography", personalDetails.getBiography().getPath());
assertNotNull(personalDetails.getLastModifiedDate());
assertNotNull(personalDetails.getLastModifiedDate().getValue());
assertNotNull(personalDetails.getName());
assertNotNull(personalDetails.getName().getCreatedDate().getValue());
assertEquals("Credit Name", personalDetails.getName().getCreditName().getContent());
assertEquals("Family Name", personalDetails.getName().getFamilyName().getContent());
assertEquals("Given Names", personalDetails.getName().getGivenNames().getContent());
assertEquals(Visibility.PUBLIC.value(), personalDetails.getName().getVisibility().value());
assertNotNull(personalDetails.getName().getLastModifiedDate());
assertNotNull(personalDetails.getName().getLastModifiedDate().getValue());
assertNotNull(personalDetails.getOtherNames());
assertNotNull(personalDetails.getOtherNames().getLastModifiedDate());
assertNotNull(personalDetails.getOtherNames().getLastModifiedDate().getValue());
assertEquals(1, personalDetails.getOtherNames().getOtherNames().size());
assertEquals("Other Name PUBLIC", personalDetails.getOtherNames().getOtherNames().get(0).getContent());
assertEquals(Visibility.PUBLIC.value(), personalDetails.getOtherNames().getOtherNames().get(0).getVisibility().value());
assertEquals("/0000-0000-0000-0003/other-names", personalDetails.getOtherNames().getPath());
assertEquals("/0000-0000-0000-0003/personal-details", personalDetails.getPath());
}
Aggregations