@Test public void checkUserPassword() { assertTrue( EncryptorManager.checkPassword( "acp", "F7qgI9zK3PdRKkktS2bFe75xnaRaI4aHxQI0oKVJj4eOZ9YTc7EZltPOVrU5ITEt")); assertTrue( EncryptorManager.checkPassword( "acc", "ieDSTg7j70jPbpfvFQAfvNZDwDPDXiYES5TpIAXKmZpQu05Yuu0soDW/Xo4yIx8R")); }
@Before public void setUp() { List<User> testUsers = new ArrayList<User>(); for (int i = 0; i < 10; i++) { User user = new User(); user.setEmail("alex_clavijo" + i + "@gmail.com"); user.setUsername("alex" + i); user.setPassword(EncryptorManager.encryptPassword("acp")); user.setName("Alejandro" + i); user.setLastName("Clavijo" + i); user.setCreated(DateTime.now()); Set<UserRole> roles = new HashSet<UserRole>(); roles.add(UserRole.USER); user.setRoles(roles); testUsers.add(user); } userRepository.saveAll(testUsers); }
@Test @Transactional public void saveUser() { User user = new User(); user.setEmail("*****@*****.**"); user.setUsername("alber"); user.setPassword(EncryptorManager.encryptPassword("acc")); user.setName("Alberto"); user.setLastName("Clavijo"); Set<UserRole> roles = new HashSet<UserRole>(); roles.add(UserRole.ADMIN); user.setRoles(roles); // userRepository.save(user); sessionFactory.getCurrentSession().save(user); sessionFactory.getCurrentSession().flush(); assertNotNull(user.getUserId()); }