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());
}
Aggregations