use of org.apache.ranger.view.VXUserList in project ranger by apache.
the class TestXUserREST method test24searchXUsers.
@SuppressWarnings("unchecked")
@Test
public void test24searchXUsers() {
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
SearchCriteria testSearchCriteria = createsearchCriteria();
Mockito.when(searchUtil.extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any())).thenReturn(testSearchCriteria);
Mockito.when(searchUtil.extractString(request, testSearchCriteria, "name", "User name", null)).thenReturn("");
Mockito.when(searchUtil.extractString(request, testSearchCriteria, "emailAddress", "Email Address", null)).thenReturn("");
Mockito.when(searchUtil.extractInt(request, testSearchCriteria, "userSource", "User Source")).thenReturn(1);
Mockito.when(searchUtil.extractInt(request, testSearchCriteria, "isVisible", "User Visibility")).thenReturn(1);
Mockito.when(searchUtil.extractInt(request, testSearchCriteria, "status", "User Status")).thenReturn(1);
Mockito.when(searchUtil.extractStringList(request, testSearchCriteria, "userRoleList", "User Role List", "userRoleList", null, null)).thenReturn(new ArrayList<String>());
Mockito.when(searchUtil.extractString(request, testSearchCriteria, "userRole", "UserRole", null)).thenReturn("");
List<VXUser> vXUsersList = new ArrayList<VXUser>();
vXUsersList.add(vxUser);
VXUserList testVXUserList = new VXUserList();
testVXUserList.setVXUsers(vXUsersList);
Mockito.when(xUserMgr.searchXUsers(testSearchCriteria)).thenReturn(testVXUserList);
VXUserList gotVXUserList = xUserRest.searchXUsers(request);
Mockito.verify(xUserMgr).searchXUsers(testSearchCriteria);
Mockito.verify(searchUtil).extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any());
Mockito.verify(searchUtil).extractString(request, testSearchCriteria, "name", "User name", null);
Mockito.verify(searchUtil).extractString(request, testSearchCriteria, "emailAddress", "Email Address", null);
Mockito.verify(searchUtil).extractInt(request, testSearchCriteria, "userSource", "User Source");
Mockito.verify(searchUtil).extractInt(request, testSearchCriteria, "isVisible", "User Visibility");
Mockito.verify(searchUtil).extractInt(request, testSearchCriteria, "status", "User Status");
Mockito.verify(searchUtil).extractStringList(request, testSearchCriteria, "userRoleList", "User Role List", "userRoleList", null, null);
Mockito.verify(searchUtil).extractString(request, testSearchCriteria, "userRole", "UserRole", null);
assertNotNull(gotVXUserList);
assertEquals(testVXUserList.getTotalCount(), gotVXUserList.getTotalCount());
assertEquals(testVXUserList.getClass(), gotVXUserList.getClass());
}
use of org.apache.ranger.view.VXUserList in project ranger by apache.
the class MetricUtil method getUserCountBasedOnUserRole.
private Long getUserCountBasedOnUserRole(@SuppressWarnings("rawtypes") List userRoleList) {
SearchCriteria searchCriteria = new SearchCriteria();
searchCriteria.setStartIndex(0);
searchCriteria.setMaxRows(100);
searchCriteria.setGetCount(true);
searchCriteria.setSortType("asc");
searchCriteria.addParam("userRoleList", userRoleList);
VXUserList VXUserListKeyAdmin = xUserMgr.searchXUsers(searchCriteria);
long userCount = VXUserListKeyAdmin.getTotalCount();
return userCount;
}
use of org.apache.ranger.view.VXUserList in project ranger by apache.
the class XUserServiceBase method searchXUsers.
/**
* @param searchCriteria
* @return
*/
public VXUserList searchXUsers(SearchCriteria searchCriteria) {
VXUserList returnList = new VXUserList();
List<VXUser> xUserList = new ArrayList<VXUser>();
@SuppressWarnings("unchecked") List<XXUser> resultList = (List<XXUser>) searchResources(searchCriteria, searchFields, sortFields, returnList);
// Iterate over the result list and create the return list
for (XXUser gjXUser : resultList) {
@SuppressWarnings("unchecked") VXUser vXUser = populateViewBean((T) gjXUser);
xUserList.add(vXUser);
}
returnList.setVXUsers(xUserList);
return returnList;
}
use of org.apache.ranger.view.VXUserList in project ranger by apache.
the class TestXUserREST method test73getXGroupUsers.
@SuppressWarnings("unchecked")
@Test
public void test73getXGroupUsers() {
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
SearchCriteria testSearchCriteria = createsearchCriteria();
testSearchCriteria.addParam("xGroupId", id);
Mockito.when(searchUtil.extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any())).thenReturn(testSearchCriteria);
VXUser testVXUser = createVXUser();
VXUserList testVXUserList = new VXUserList();
List<VXUser> testVXUsers = new ArrayList<VXUser>();
testVXUsers.add(testVXUser);
testVXUserList.setVXUsers(testVXUsers);
testVXUserList.setStartIndex(1);
testVXUserList.setTotalCount(1);
Mockito.when(xUserMgr.getXGroupUsers(testSearchCriteria)).thenReturn(testVXUserList);
VXUserList retVxGroupList = xUserRest.getXGroupUsers(request, id);
assertNotNull(retVxGroupList);
assertEquals(testVXUserList.getTotalCount(), retVxGroupList.getTotalCount());
assertEquals(testVXUserList.getStartIndex(), retVxGroupList.getStartIndex());
Mockito.verify(xUserMgr).getXGroupUsers(testSearchCriteria);
}
use of org.apache.ranger.view.VXUserList in project ranger by apache.
the class TestXUserMgr method test23GetXGroupUsers.
@Test
public void test23GetXGroupUsers() {
SearchCriteria testSearchCriteria = createsearchCriteria();
testSearchCriteria.addParam("xGroupId", userId);
VXUserList dbVXUserList = xUserMgr.getXGroupUsers(testSearchCriteria);
VXGroup vXGroup = new VXGroup();
vXGroup.setId(userId);
vXGroup.setDescription("group test");
vXGroup.setName("grouptest");
Assert.assertNotNull(dbVXUserList);
}
Aggregations