Search in sources :

Example 1 with Claim

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());
    }
}
Also used : ProfileKeywordEntity(org.orcid.persistence.jpa.entities.ProfileKeywordEntity) Checkbox(org.orcid.pojo.ajaxForm.Checkbox) ResearcherUrlEntity(org.orcid.persistence.jpa.entities.ResearcherUrlEntity) ExternalIdentifierEntity(org.orcid.persistence.jpa.entities.ExternalIdentifierEntity) OtherNameEntity(org.orcid.persistence.jpa.entities.OtherNameEntity) Claim(org.orcid.pojo.ajaxForm.Claim) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) AddressEntity(org.orcid.persistence.jpa.entities.AddressEntity) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with Claim

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;
}
Also used : Claim(org.orcid.pojo.ajaxForm.Claim) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with Claim

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();
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Locale(org.orcid.jaxb.model.common_v2.Locale) NoSuchRequestHandlingMethodException(org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException) Checkbox(org.orcid.pojo.ajaxForm.Checkbox) HttpServletResponse(javax.servlet.http.HttpServletResponse) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Claim(org.orcid.pojo.ajaxForm.Claim) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Claim (org.orcid.pojo.ajaxForm.Claim)3 Test (org.junit.Test)2 Checkbox (org.orcid.pojo.ajaxForm.Checkbox)2 Transactional (org.springframework.transaction.annotation.Transactional)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 Locale (org.orcid.jaxb.model.common_v2.Locale)1 AddressEntity (org.orcid.persistence.jpa.entities.AddressEntity)1 ExternalIdentifierEntity (org.orcid.persistence.jpa.entities.ExternalIdentifierEntity)1 OtherNameEntity (org.orcid.persistence.jpa.entities.OtherNameEntity)1 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)1 ProfileKeywordEntity (org.orcid.persistence.jpa.entities.ProfileKeywordEntity)1 ResearcherUrlEntity (org.orcid.persistence.jpa.entities.ResearcherUrlEntity)1 DBUnitTest (org.orcid.test.DBUnitTest)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1 NoSuchRequestHandlingMethodException (org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException)1