Search in sources :

Example 11 with UserconnectionEntity

use of org.orcid.persistence.jpa.entities.UserconnectionEntity in project ORCID-Source by ORCID.

the class ProfileEntityManagerImplTest method testDeprecateProfile.

@Test
public void testDeprecateProfile() throws Exception {
    UserconnectionPK pk = new UserconnectionPK();
    pk.setProviderid("providerId");
    pk.setProvideruserid("provideruserid");
    pk.setUserid("4444-4444-4444-4441");
    UserconnectionEntity userConnection = new UserconnectionEntity();
    userConnection.setAccesstoken("blah");
    userConnection.setConnectionSatus(UserConnectionStatus.STARTED);
    userConnection.setDisplayname("blah");
    userConnection.setDateCreated(new Date());
    userConnection.setLastModified(new Date());
    userConnection.setEmail("blah@blah.com");
    userConnection.setOrcid("4444-4444-4444-4441");
    userConnection.setId(pk);
    userConnection.setRank(1);
    userConnectionDao.persist(userConnection);
    ProfileEntity profileEntityToDeprecate = profileEntityCacheManager.retrieve("4444-4444-4444-4441");
    assertNull(profileEntityToDeprecate.getPrimaryRecord());
    boolean result = profileEntityManager.deprecateProfile("4444-4444-4444-4441", "4444-4444-4444-4442", ProfileEntity.USER_DRIVEN_DEPRECATION, null);
    assertTrue(result);
    profileEntityToDeprecate = profileEntityCacheManager.retrieve("4444-4444-4444-4441");
    assertNotNull(profileEntityToDeprecate.getPrimaryRecord());
    assertNotNull(profileEntityToDeprecate.getDeprecatedMethod());
    assertEquals(ProfileEntity.USER_DRIVEN_DEPRECATION, profileEntityToDeprecate.getDeprecatedMethod());
    assertEquals("4444-4444-4444-4442", profileEntityToDeprecate.getPrimaryRecord().getId());
    assertEquals(0, userConnectionDao.findByOrcid("4444-4444-4444-4441").size());
}
Also used : UserconnectionPK(org.orcid.persistence.jpa.entities.UserconnectionPK) UserconnectionEntity(org.orcid.persistence.jpa.entities.UserconnectionEntity) Date(java.util.Date) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

UserconnectionEntity (org.orcid.persistence.jpa.entities.UserconnectionEntity)11 UserconnectionPK (org.orcid.persistence.jpa.entities.UserconnectionPK)5 Date (java.util.Date)4 Test (org.junit.Test)4 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 SocialType (org.orcid.frontend.spring.web.social.config.SocialType)3 UsernameNotFoundException (org.springframework.security.core.userdetails.UsernameNotFoundException)3 HeaderCheckResult (org.orcid.pojo.HeaderCheckResult)2 RemoteUser (org.orcid.pojo.RemoteUser)2 DBUnitTest (org.orcid.test.DBUnitTest)2 Authentication (org.springframework.security.core.Authentication)2 AuthenticationException (org.springframework.security.core.AuthenticationException)2 PreAuthenticatedAuthenticationToken (org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken)2 Transactional (org.springframework.transaction.annotation.Transactional)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 ModelAndView (org.springframework.web.servlet.ModelAndView)2 Timestamp (java.sql.Timestamp)1 Random (java.util.Random)1 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)1