Search in sources :

Example 1 with VXUserPermissionList

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);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) VXUserPermissionList(org.apache.ranger.view.VXUserPermissionList) ArrayList(java.util.ArrayList) SortField(org.apache.ranger.common.SortField) VXUserPermission(org.apache.ranger.view.VXUserPermission) SearchCriteria(org.apache.ranger.common.SearchCriteria) Test(org.junit.Test)

Example 2 with VXUserPermissionList

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;
}
Also used : VXUserPermissionList(org.apache.ranger.view.VXUserPermissionList) ArrayList(java.util.ArrayList) VXUserPermission(org.apache.ranger.view.VXUserPermission)

Aggregations

ArrayList (java.util.ArrayList)2 VXUserPermission (org.apache.ranger.view.VXUserPermission)2 VXUserPermissionList (org.apache.ranger.view.VXUserPermissionList)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 SearchCriteria (org.apache.ranger.common.SearchCriteria)1 SortField (org.apache.ranger.common.SortField)1 Test (org.junit.Test)1