protected User createAuthenticatedUser() { if (authenticatedUser == null) { User user = new User(4); user.setUsername("thies"); user.setPassword("secret"); Set<UserRole> userRoles = new HashSet<UserRole>(); userRoles.addAll(UserRole.ROLES.values()); user.setUserRoles(userRoles); authenticatedUser = user; } return authenticatedUser; }
@Test public void use_edit_when_manager_views_non_admins() throws ObjectNotFoundException { getConfig().setSplitAdminRole(true); user.setUserRoles(Sets.newHashSet(UserRole.USER)); when(userService.getUserAndCheckDeletability(1)).thenReturn(user); webApp.setAuthorizedRoles(new Roles(UserRole.ROLE_MANAGER)); super.startTester(); tester.startPage(ManageUserPage.class); tester.executeAjaxEvent( "userSelection:border:border_body:entrySelectorFrame:entrySelectorFrame:blueBorder:blueBorder_body:itemListHolder:itemList:0", "click"); tester.assertComponent("tabs:panel", ManageUserFormPanel.class); }
@Before public void setup_userservice() throws Exception { super.setUp(); getMockContext().putBean("userService", userService); List<User> users = new ArrayList<User>(); user = new User(); user.setFirstName("thies"); user.setUserId(1); user.setLastName("Edeling"); user.setUserRoles(Sets.newHashSet(UserRole.ADMIN)); users.add(user); when(userService.getActiveUsers()).thenReturn(users); when(userService.getUserRoles()).thenReturn(new ArrayList<UserRole>()); when(userService.getUserDepartments()).thenReturn(new ArrayList<UserDepartment>()); }