/** {@inheritDoc} */ public List<LabelValue> getAllRoles() { List<Role> roles = dao.getRoles(); List<LabelValue> list = new ArrayList<LabelValue>(); for (Role role1 : roles) { list.add(new LabelValue(role1.getName(), role1.getName())); } return list; }
@Test public void testUpdateRole() throws Exception { Role role = dao.getRoleByName("ROLE_USER"); log.debug(role); role.setDescription("test descr"); dao.save(role); role = dao.getRoleByName("ROLE_USER"); assertEquals(role.getDescription(), "test descr"); }
@Test public void testAddAndRemoveRole() throws Exception { Role role = new Role("testrole"); role.setDescription("new role descr"); dao.save(role); // setComplete(); // change behavior from rollback to commit // endTransaction(); // startNewTransaction(); role = dao.getRoleByName("testrole"); assertNotNull(role.getDescription()); dao.removeRole("testrole"); // setComplete(); // endTransaction(); // deletes role from database role = dao.getRoleByName("testrole"); assertNull(role); }