Search in sources :

Example 6 with SortField

use of org.apache.ranger.common.SortField 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 7 with SortField

use of org.apache.ranger.common.SortField in project ranger by apache.

the class TestXUserREST method test81countXModuleDef.

@SuppressWarnings("unchecked")
@Test
public void test81countXModuleDef() {
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    SearchCriteria testSearchCriteria = createsearchCriteria();
    Mockito.when(searchUtil.extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any())).thenReturn(testSearchCriteria);
    vXLong.setValue(1);
    Mockito.when(xUserMgr.getXModuleDefSearchCount(testSearchCriteria)).thenReturn(vXLong);
    VXLong testvxLong = xUserRest.countXModuleDef(request);
    Mockito.verify(xUserMgr).getXModuleDefSearchCount(testSearchCriteria);
    Mockito.verify(searchUtil).extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any());
    assertNotNull(testvxLong);
    assertEquals(testvxLong.getValue(), vXLong.getValue());
    assertEquals(testvxLong.getClass(), vXLong.getClass());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) VXLong(org.apache.ranger.view.VXLong) SortField(org.apache.ranger.common.SortField) SearchCriteria(org.apache.ranger.common.SearchCriteria) Test(org.junit.Test)

Example 8 with SortField

use of org.apache.ranger.common.SortField in project ranger by apache.

the class TestXUserREST method test36searchXGroupGroups.

@SuppressWarnings("unchecked")
@Test
public void test36searchXGroupGroups() {
    VXGroupGroupList testvXGroupGroupList = new VXGroupGroupList();
    VXGroupGroup testVXGroup = createVXGroupGroup();
    List<VXGroupGroup> testVXGroupGroups = new ArrayList<VXGroupGroup>();
    testVXGroupGroups.add(testVXGroup);
    testvXGroupGroupList.setVXGroupGroups(testVXGroupGroups);
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    SearchCriteria testSearchCriteria = createsearchCriteria();
    Mockito.when(searchUtil.extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any())).thenReturn(testSearchCriteria);
    Mockito.when(xUserMgr.searchXGroupGroups(testSearchCriteria)).thenReturn(testvXGroupGroupList);
    VXGroupGroupList outputvXGroupGroupList = xUserRest.searchXGroupGroups(request);
    Mockito.verify(xUserMgr).searchXGroupGroups(testSearchCriteria);
    Mockito.verify(searchUtil).extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any());
    assertNotNull(outputvXGroupGroupList);
    assertEquals(outputvXGroupGroupList.getClass(), testvXGroupGroupList.getClass());
    assertEquals(outputvXGroupGroupList.getResultSize(), testvXGroupGroupList.getResultSize());
}
Also used : VXGroupGroupList(org.apache.ranger.view.VXGroupGroupList) HttpServletRequest(javax.servlet.http.HttpServletRequest) ArrayList(java.util.ArrayList) VXGroupGroup(org.apache.ranger.view.VXGroupGroup) SortField(org.apache.ranger.common.SortField) SearchCriteria(org.apache.ranger.common.SearchCriteria) Test(org.junit.Test)

Example 9 with SortField

use of org.apache.ranger.common.SortField in project ranger by apache.

the class TestXUserREST method test93countXGroupPermission.

@SuppressWarnings("unchecked")
@Test
public void test93countXGroupPermission() {
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    SearchCriteria testSearchCriteria = createsearchCriteria();
    Mockito.when(searchUtil.extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any())).thenReturn(testSearchCriteria);
    vXLong.setValue(1);
    Mockito.when(xUserMgr.getXGroupPermissionSearchCount(testSearchCriteria)).thenReturn(vXLong);
    VXLong testvxLong = xUserRest.countXGroupPermission(request);
    Mockito.verify(xUserMgr).getXGroupPermissionSearchCount(testSearchCriteria);
    Mockito.verify(searchUtil).extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any());
    assertNotNull(testvxLong);
    assertEquals(testvxLong.getValue(), vXLong.getValue());
    assertEquals(testvxLong.getClass(), vXLong.getClass());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) VXLong(org.apache.ranger.view.VXLong) SortField(org.apache.ranger.common.SortField) SearchCriteria(org.apache.ranger.common.SearchCriteria) Test(org.junit.Test)

Example 10 with SortField

use of org.apache.ranger.common.SortField in project ranger by apache.

the class TestXUserREST method test31countXGroupUserst.

@SuppressWarnings("unchecked")
@Test
public void test31countXGroupUserst() {
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    SearchCriteria testSearchCriteria = createsearchCriteria();
    Mockito.when(searchUtil.extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any())).thenReturn(testSearchCriteria);
    vXLong.setValue(1);
    Mockito.when(xUserMgr.getXGroupUserSearchCount(testSearchCriteria)).thenReturn(vXLong);
    VXLong testvxLong = xUserRest.countXGroupUsers(request);
    Mockito.verify(xUserMgr).getXGroupUserSearchCount(testSearchCriteria);
    Mockito.verify(searchUtil).extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any());
    assertNotNull(testvxLong);
    assertEquals(testvxLong.getValue(), vXLong.getValue());
    assertEquals(testvxLong.getClass(), vXLong.getClass());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) VXLong(org.apache.ranger.view.VXLong) SortField(org.apache.ranger.common.SortField) SearchCriteria(org.apache.ranger.common.SearchCriteria) Test(org.junit.Test)

Aggregations

SortField (org.apache.ranger.common.SortField)34 Test (org.junit.Test)30 SearchCriteria (org.apache.ranger.common.SearchCriteria)26 HttpServletRequest (javax.servlet.http.HttpServletRequest)23 ArrayList (java.util.ArrayList)15 VXLong (org.apache.ranger.view.VXLong)12 Date (java.util.Date)3 VXAccessAuditList (org.apache.ranger.view.VXAccessAuditList)3 XXServiceDef (org.apache.ranger.entity.XXServiceDef)2 VXAccessAudit (org.apache.ranger.view.VXAccessAudit)2 VXTrxLogList (org.apache.ranger.view.VXTrxLogList)2 VXUser (org.apache.ranger.view.VXUser)2 VXUserList (org.apache.ranger.view.VXUserList)2 Predicate (org.apache.commons.collections.Predicate)1 KeySearchFilter (org.apache.ranger.plugin.util.KeySearchFilter)1 VXAuditMap (org.apache.ranger.view.VXAuditMap)1 VXAuditMapList (org.apache.ranger.view.VXAuditMapList)1 VXAuthSession (org.apache.ranger.view.VXAuthSession)1 VXAuthSessionList (org.apache.ranger.view.VXAuthSessionList)1 VXCredentialStore (org.apache.ranger.view.VXCredentialStore)1