Search in sources :

Example 26 with SortField

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

the class TestXUserREST method test25countXUsers.

@SuppressWarnings("unchecked")
@Test
public void test25countXUsers() {
    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.getXUserSearchCount(testSearchCriteria)).thenReturn(vXLong);
    VXLong testvxLong = xUserRest.countXUsers(request);
    Mockito.verify(xUserMgr).getXUserSearchCount(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 27 with SortField

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

the class TestXUserREST method test60searchXAuditMaps.

@SuppressWarnings("unchecked")
@Test
public void test60searchXAuditMaps() {
    VXAuditMap testvXAuditMap = createVXAuditMapObj();
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    SearchCriteria testSearchCriteria = createsearchCriteria();
    Mockito.when(searchUtil.extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any())).thenReturn(testSearchCriteria);
    List<VXAuditMap> testvXAuditMaps = new ArrayList<VXAuditMap>();
    testvXAuditMaps.add(testvXAuditMap);
    VXAuditMapList testVXAuditMapList = new VXAuditMapList();
    testVXAuditMapList.setVXAuditMaps(testvXAuditMaps);
    Mockito.when(xUserMgr.searchXAuditMaps(testSearchCriteria)).thenReturn(testVXAuditMapList);
    VXAuditMapList outputVXAuditMapList = xUserRest.searchXAuditMaps(request);
    Mockito.verify(xUserMgr).searchXAuditMaps(testSearchCriteria);
    Mockito.verify(searchUtil).extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any());
    assertNotNull(outputVXAuditMapList);
    assertEquals(outputVXAuditMapList.getClass(), testVXAuditMapList.getClass());
    assertEquals(outputVXAuditMapList.getResultSize(), testVXAuditMapList.getResultSize());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ArrayList(java.util.ArrayList) VXAuditMap(org.apache.ranger.view.VXAuditMap) SortField(org.apache.ranger.common.SortField) VXAuditMapList(org.apache.ranger.view.VXAuditMapList) SearchCriteria(org.apache.ranger.common.SearchCriteria) Test(org.junit.Test)

Example 28 with SortField

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

the class TestXUserREST method test11searchXGroups.

@SuppressWarnings("unchecked")
@Test
public void test11searchXGroups() {
    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", "group name", null)).thenReturn("");
    Mockito.when(searchUtil.extractInt(request, testSearchCriteria, "isVisible", "Group Visibility")).thenReturn(1);
    Mockito.when(searchUtil.extractString(request, testSearchCriteria, "groupSource", "group source", null)).thenReturn("");
    VXGroupList testvXGroupList = createxGroupList();
    Mockito.when(xUserMgr.searchXGroups(testSearchCriteria)).thenReturn(testvXGroupList);
    VXGroupList outputvXGroupList = xUserRest.searchXGroups(request);
    Mockito.verify(xUserMgr).searchXGroups(testSearchCriteria);
    Mockito.verify(searchUtil).extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any());
    Mockito.verify(searchUtil).extractString(request, testSearchCriteria, "name", "group name", null);
    Mockito.verify(searchUtil).extractInt(request, testSearchCriteria, "isVisible", "Group Visibility");
    Mockito.verify(searchUtil).extractString(request, testSearchCriteria, "groupSource", "group source", null);
    assertNotNull(outputvXGroupList);
    assertEquals(outputvXGroupList.getTotalCount(), testvXGroupList.getTotalCount());
    assertEquals(outputvXGroupList.getClass(), testvXGroupList.getClass());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) VXGroupList(org.apache.ranger.view.VXGroupList) SortField(org.apache.ranger.common.SortField) SearchCriteria(org.apache.ranger.common.SearchCriteria) Test(org.junit.Test)

Example 29 with SortField

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

the class TestXUserREST method test37countXGroupGroups.

@SuppressWarnings("unchecked")
@Test
public void test37countXGroupGroups() {
    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.getXGroupGroupSearchCount(testSearchCriteria)).thenReturn(vXLong);
    VXLong testvxLong = xUserRest.countXGroupGroups(request);
    Mockito.verify(xUserMgr).getXGroupGroupSearchCount(testSearchCriteria);
    Mockito.verify(searchUtil).extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any());
    assertNotNull(testvxLong);
    assertEquals(testvxLong.getClass(), vXLong.getClass());
    assertEquals(testvxLong.getValue(), vXLong.getValue());
}
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 30 with SortField

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

the class TestXUserREST method test48searchXPermMaps.

@SuppressWarnings("unchecked")
@Test
public void test48searchXPermMaps() {
    VXPermMap permMap = testcreateXPermMap();
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    SearchCriteria testSearchCriteria = createsearchCriteria();
    Mockito.when(searchUtil.extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any())).thenReturn(testSearchCriteria);
    List<VXPermMap> vXPermMaps = new ArrayList<VXPermMap>();
    vXPermMaps.add(permMap);
    VXPermMapList testvXGroupList = new VXPermMapList();
    testvXGroupList.setTotalCount(1);
    testvXGroupList.setVXPermMaps(vXPermMaps);
    Mockito.when(xUserMgr.searchXPermMaps(testSearchCriteria)).thenReturn(testvXGroupList);
    VXPermMapList outputvXGroupList = xUserRest.searchXPermMaps(request);
    Mockito.verify(xUserMgr).searchXPermMaps(testSearchCriteria);
    Mockito.verify(searchUtil).extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any());
    assertNotNull(outputvXGroupList);
    assertEquals(outputvXGroupList.getClass(), testvXGroupList.getClass());
    assertEquals(outputvXGroupList.getTotalCount(), testvXGroupList.getTotalCount());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) VXPermMap(org.apache.ranger.view.VXPermMap) ArrayList(java.util.ArrayList) SortField(org.apache.ranger.common.SortField) VXPermMapList(org.apache.ranger.view.VXPermMapList) 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