Search in sources :

Example 1 with VXGroupPermissionList

use of org.apache.ranger.view.VXGroupPermissionList in project ranger by apache.

the class XGroupPermissionServiceBase method searchXGroupPermission.

/**
 * @param searchCriteria
 * @return
 */
public VXGroupPermissionList searchXGroupPermission(SearchCriteria searchCriteria) {
    VXGroupPermissionList returnList = new VXGroupPermissionList();
    List<VXGroupPermission> vXGroupPermissions = new ArrayList<VXGroupPermission>();
    List<T> resultList = searchResources(searchCriteria, searchFields, sortFields, returnList);
    // Iterate over the result list and create the return list
    for (T gjXUser : resultList) {
        VXGroupPermission vXGroupPermission = populateViewBean(gjXUser);
        vXGroupPermissions.add(vXGroupPermission);
    }
    returnList.setvXGroupPermission(vXGroupPermissions);
    return returnList;
}
Also used : VXGroupPermission(org.apache.ranger.view.VXGroupPermission) ArrayList(java.util.ArrayList) VXGroupPermissionList(org.apache.ranger.view.VXGroupPermissionList)

Example 2 with VXGroupPermissionList

use of org.apache.ranger.view.VXGroupPermissionList in project ranger by apache.

the class TestXUserREST method test92searchXGroupPermission.

@SuppressWarnings("unchecked")
@Test
public void test92searchXGroupPermission() {
    VXGroupPermissionList testVXGroupPermissionList = new VXGroupPermissionList();
    testVXGroupPermissionList.setTotalCount(1);
    VXGroupPermission testVXGroupPermission = createVXGroupPermission();
    List<VXGroupPermission> testVXGroupPermissions = new ArrayList<VXGroupPermission>();
    testVXGroupPermissions.add(testVXGroupPermission);
    testVXGroupPermissionList.setvXGroupPermission(testVXGroupPermissions);
    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, "groupPermissionList", "groupId", StringUtil.VALIDATION_NAME)).thenReturn("");
    Mockito.when(xUserMgr.searchXGroupPermission(testSearchCriteria)).thenReturn(testVXGroupPermissionList);
    VXGroupPermissionList outputVXGroupPermissionList = xUserRest.searchXGroupPermission(request);
    assertNotNull(outputVXGroupPermissionList);
    assertEquals(outputVXGroupPermissionList.getClass(), testVXGroupPermissionList.getClass());
    assertEquals(outputVXGroupPermissionList.getTotalCount(), testVXGroupPermissionList.getTotalCount());
    Mockito.verify(xUserMgr).searchXGroupPermission(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, "groupPermissionList", "groupId", StringUtil.VALIDATION_NAME);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) VXGroupPermission(org.apache.ranger.view.VXGroupPermission) ArrayList(java.util.ArrayList) SortField(org.apache.ranger.common.SortField) VXGroupPermissionList(org.apache.ranger.view.VXGroupPermissionList) SearchCriteria(org.apache.ranger.common.SearchCriteria) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)2 VXGroupPermission (org.apache.ranger.view.VXGroupPermission)2 VXGroupPermissionList (org.apache.ranger.view.VXGroupPermissionList)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