use of org.pentaho.platform.web.http.api.resources.UserListWrapper in project pentaho-platform by pentaho.
the class UserRoleListService method getUsers.
public UserListWrapper getUsers() {
IUserRoleListService service = getUserRoleListService();
List<String> allUsers = service.getAllUsers();
if (null != userComparator) {
Collections.sort(allUsers, userComparator);
}
return new UserListWrapper(allUsers);
}
use of org.pentaho.platform.web.http.api.resources.UserListWrapper in project pentaho-platform by pentaho.
the class UserRoleDaoServiceTest method testGetRoleMembersSecurityException.
@Test(expected = SecurityException.class)
public void testGetRoleMembersSecurityException() {
setupMockSessionUser(SESSION_USER_NAME, false);
List<IPentahoUser> userList = new ArrayList<>();
IUserRoleDao roleDao = mock(IUserRoleDao.class);
when(roleDao.getRoleMembers(any(ITenant.class), anyString())).thenReturn(userList);
PentahoSystem.registerObject(roleDao);
IPentahoUser user = mock(IPentahoUser.class);
when(user.getUsername()).thenReturn("admin");
userList.add(user);
UserListWrapper wrapUserList = new UserListWrapper(userList);
IPentahoSession session = mock(IPentahoSession.class);
String tenantPath = "testPath";
when(session.getAttribute(IPentahoSession.TENANT_ID_KEY)).thenReturn(tenantPath);
PentahoSessionHolder.setSession(session);
userRoleService.getRoleMembers("Report Author");
}
use of org.pentaho.platform.web.http.api.resources.UserListWrapper in project pentaho-platform by pentaho.
the class UserRoleDaoServiceTest method testGetUsers.
@Test
public void testGetUsers() throws Exception {
List<IPentahoUser> userList = new ArrayList<>();
IUserRoleDao roleDao = mock(IUserRoleDao.class);
when(roleDao.getUsers()).thenReturn(userList);
PentahoSystem.registerObject(roleDao);
UserListWrapper wrapUserList = new UserListWrapper(userList);
assertEquals(wrapUserList.getUsers(), userRoleService.getUsers().getUsers());
}
use of org.pentaho.platform.web.http.api.resources.UserListWrapper in project pentaho-platform by pentaho.
the class UserRoleDaoServiceTest method testGetRoleMembers.
@Test
public void testGetRoleMembers() {
setupMockSessionUser(SESSION_USER_NAME, true);
List<IPentahoUser> userList = new ArrayList<>();
IUserRoleDao roleDao = mock(IUserRoleDao.class);
when(roleDao.getRoleMembers(any(ITenant.class), anyString())).thenReturn(userList);
PentahoSystem.registerObject(roleDao);
IPentahoUser user = mock(IPentahoUser.class);
when(user.getUsername()).thenReturn("admin");
userList.add(user);
UserListWrapper wrapUserList = new UserListWrapper(userList);
IPentahoSession session = mock(IPentahoSession.class);
String tenantPath = "testPath";
when(session.getAttribute(IPentahoSession.TENANT_ID_KEY)).thenReturn(tenantPath);
PentahoSessionHolder.setSession(session);
assertEquals(wrapUserList.getUsers(), userRoleService.getRoleMembers("Report Author").getUsers());
}
use of org.pentaho.platform.web.http.api.resources.UserListWrapper in project pentaho-platform by pentaho.
the class UserRoleListServiceTest method testGetUsers.
@Test
public void testGetUsers() {
IUserRoleListService service = mock(IUserRoleListService.class);
doReturn(service).when(userRoleListService).getUserRoleListService();
List<String> users = new ArrayList<String>();
users.add("admin");
users.add("joe");
users.add("suzy");
doReturn(users).when(service).getAllUsers();
UserListWrapper usersWrapper = userRoleListService.getUsers();
assertTrue(usersWrapper.getUsers().size() == 3);
}
Aggregations