use of org.nextprot.api.user.domain.User in project nextprot-api by calipho-sib.
the class UserDaoTest method testReadUserWithRoles.
@Test
public void testReadUserWithRoles() {
User user = userDao.getUserByUsername("spongebob");
Assert.assertEquals(23, user.getId());
Assert.assertEquals("spongebob", user.getUsername());
Assert.assertNull(user.getFirstName());
Assert.assertNull(user.getLastName());
Assert.assertTrue(!user.getAuthorities().isEmpty());
Assert.assertEquals(2, user.getAuthorities().size());
Assert.assertTrue(user.getAuthorities().contains(new SimpleGrantedAuthority("ROLE_USER")));
Assert.assertTrue(user.getAuthorities().contains(new SimpleGrantedAuthority("ROLE_ADMIN")));
}
use of org.nextprot.api.user.domain.User in project nextprot-api by calipho-sib.
the class UserDaoTest method testUpdateUserWithRoles.
@Test
public void testUpdateUserWithRoles() {
User updated = new User();
updated.setId(23);
updated.setUsername("spongebob");
updated.setFirstName("sponge");
updated.setLastName("bob");
Set<GrantedAuthority> hs = new HashSet<GrantedAuthority>();
hs.add(new SimpleGrantedAuthority("ROLE_USER"));
updated.setAuthorities(hs);
userDao.updateUser(updated);
User user = userDao.getUserByUsername("spongebob");
Assert.assertEquals(23, user.getId());
Assert.assertEquals("spongebob", user.getUsername());
Assert.assertEquals("sponge", user.getFirstName());
Assert.assertEquals("bob", user.getLastName());
Assert.assertTrue(!user.getAuthorities().isEmpty());
Assert.assertEquals(1, user.getAuthorities().size());
Assert.assertTrue(user.getAuthorities().contains(new SimpleGrantedAuthority("ROLE_USER")));
}
Aggregations