use of org.apache.ranger.view.VXUserPermissionList in project ranger by apache.
the class TestXUserREST method test86searchXUserPermission.
@SuppressWarnings("unchecked")
@Test
public void test86searchXUserPermission() {
VXUserPermissionList testVXUserPermissionList = new VXUserPermissionList();
testVXUserPermissionList.setTotalCount(1);
testVXUserPermissionList.setStartIndex(1);
VXUserPermission testVXUserPermission = createVXUserPermission();
List<VXUserPermission> testVXUserPermissions = new ArrayList<VXUserPermission>();
testVXUserPermissions.add(testVXUserPermission);
testVXUserPermissionList.setvXModuleDef(testVXUserPermissions);
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, "id", "id", StringUtil.VALIDATION_NAME)).thenReturn("");
Mockito.when(searchUtil.extractString(request, testSearchCriteria, "userPermissionList", "userId", StringUtil.VALIDATION_NAME)).thenReturn("");
Mockito.when(xUserMgr.searchXUserPermission(testSearchCriteria)).thenReturn(testVXUserPermissionList);
VXUserPermissionList outputVXUserPermissionList = xUserRest.searchXUserPermission(request);
assertNotNull(outputVXUserPermissionList);
assertEquals(outputVXUserPermissionList.getStartIndex(), testVXUserPermissionList.getStartIndex());
assertEquals(outputVXUserPermissionList.getTotalCount(), testVXUserPermissionList.getTotalCount());
Mockito.verify(xUserMgr).searchXUserPermission(testSearchCriteria);
Mockito.verify(searchUtil).extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any());
Mockito.verify(searchUtil).extractString(request, testSearchCriteria, "id", "id", StringUtil.VALIDATION_NAME);
Mockito.verify(searchUtil).extractString(request, testSearchCriteria, "userPermissionList", "userId", StringUtil.VALIDATION_NAME);
}
use of org.apache.ranger.view.VXUserPermissionList in project ranger by apache.
the class XUserPermissionServiceBase method searchXUserPermission.
/**
* @param searchCriteria
* @return
*/
public VXUserPermissionList searchXUserPermission(SearchCriteria searchCriteria) {
VXUserPermissionList returnList = new VXUserPermissionList();
List<VXUserPermission> vXUserPermissions = new ArrayList<VXUserPermission>();
List<T> resultList = searchResources(searchCriteria, searchFields, sortFields, returnList);
// Iterate over the result list and create the return list
for (T gjXUser : resultList) {
VXUserPermission vXUserPermission = populateViewBean(gjXUser);
vXUserPermissions.add(vXUserPermission);
}
returnList.setvXModuleDef(vXUserPermissions);
return returnList;
}
Aggregations