use of org.orcid.pojo.ajaxForm.Claim in project ORCID-Source by ORCID.
the class ProfileEntityManagerImplTest method testClaimChangingVisibility.
@Test
@Transactional
public void testClaimChangingVisibility() {
Claim claim = new Claim();
claim.setActivitiesVisibilityDefault(org.orcid.pojo.ajaxForm.Visibility.valueOf(Visibility.PRIVATE));
claim.setPassword(Text.valueOf("passwordTest1"));
claim.setPasswordConfirm(Text.valueOf("passwordTest1"));
Checkbox checked = new Checkbox();
checked.setValue(true);
claim.setSendChangeNotifications(checked);
claim.setSendOrcidNews(checked);
claim.setTermsOfUse(checked);
assertTrue(profileEntityManager.claimProfileAndUpdatePreferences("0000-0000-0000-0001", "public_0000-0000-0000-0001@test.orcid.org", Locale.EN, claim));
ProfileEntity profile = profileEntityManager.findByOrcid("0000-0000-0000-0001");
assertNotNull(profile);
assertNotNull(profile.getBiographyEntity());
assertEquals(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE, profile.getBiographyEntity().getVisibility());
assertNotNull(profile.getAddresses());
assertEquals(3, profile.getAddresses().size());
for (AddressEntity a : profile.getAddresses()) {
assertEquals(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE, a.getVisibility());
}
assertNotNull(profile.getExternalIdentifiers());
assertEquals(3, profile.getExternalIdentifiers().size());
for (ExternalIdentifierEntity e : profile.getExternalIdentifiers()) {
assertEquals(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE, e.getVisibility());
}
assertNotNull(profile.getKeywords());
assertEquals(3, profile.getKeywords().size());
for (ProfileKeywordEntity k : profile.getKeywords()) {
assertEquals(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE, k.getVisibility());
}
assertNotNull(profile.getOtherNames());
assertEquals(3, profile.getOtherNames().size());
for (OtherNameEntity o : profile.getOtherNames()) {
assertEquals(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE, o.getVisibility());
}
assertNotNull(profile.getResearcherUrls());
assertEquals(3, profile.getResearcherUrls().size());
for (ResearcherUrlEntity r : profile.getResearcherUrls()) {
assertEquals(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE, r.getVisibility());
}
}
use of org.orcid.pojo.ajaxForm.Claim in project ORCID-Source by ORCID.
the class ClaimController method verifyClaimJson.
@RequestMapping(value = "/claim/{encryptedEmail}.json", method = RequestMethod.GET)
@ResponseBody
public Claim verifyClaimJson(HttpServletRequest request, @PathVariable("encryptedEmail") String encryptedEmail, RedirectAttributes redirectAttributes) throws NoSuchRequestHandlingMethodException, UnsupportedEncodingException {
Claim c = new Claim();
c.getSendChangeNotifications().setValue(true);
c.getSendOrcidNews().setValue(true);
c.getTermsOfUse().setValue(false);
claimTermsOfUseValidate(c);
return c;
}
use of org.orcid.pojo.ajaxForm.Claim in project ORCID-Source by ORCID.
the class ClaimControllerTest method testClaim.
@Test
@Transactional
public void testClaim() {
String email = "public_0000-0000-0000-0001@test.orcid.org";
SecurityContextHolder.getContext().setAuthentication(null);
when(profileEntityCacheManager.retrieve(Mockito.anyString())).thenReturn(getProfileEntityToTestClam(false));
when(encryptionManager.decryptForExternalUse(any(String.class))).thenReturn(email);
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
when(request.getAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE)).thenReturn(null);
when(request.getLocale()).thenReturn(java.util.Locale.US);
String orcid = "0000-0000-0000-0001";
when(emailManager.findOrcidIdByEmail(email)).thenReturn(orcid);
when(profileEntityManager.claimProfileAndUpdatePreferences(any(String.class), any(String.class), any(Locale.class), any(Claim.class))).thenReturn(true);
Claim claim = new Claim();
claim.setActivitiesVisibilityDefault(org.orcid.pojo.ajaxForm.Visibility.valueOf(Visibility.PRIVATE));
claim.setPassword(Text.valueOf("passwordTest1"));
claim.setPasswordConfirm(Text.valueOf("passwordTest1"));
Checkbox checked = new Checkbox();
checked.setValue(true);
claim.setSendChangeNotifications(checked);
claim.setSendOrcidNews(checked);
claim.setTermsOfUse(checked);
try {
claim = claimController.submitClaimJson(request, response, email, claim);
assertNotNull(claim);
assertTrue(claim.getErrors().isEmpty());
assertTrue("Value was: " + claim.getUrl(), claim.getUrl().endsWith("/my-orcid?recordClaimed"));
} catch (NoSuchRequestHandlingMethodException e) {
fail();
} catch (UnsupportedEncodingException e) {
fail();
}
}
Aggregations