Search in sources :

Example 16 with SortField

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

the class TestXAuditREST method Test6countXTrxLogs.

@SuppressWarnings("unchecked")
@Test
public void Test6countXTrxLogs() {
    VXLong vxLongExp = new VXLong();
    vxLongExp.setValue(id);
    Mockito.when(searchUtil.extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any())).thenReturn(searchCriteria);
    Mockito.when(xAuditMgr.getXTrxLogSearchCount(searchCriteria)).thenReturn(vxLongExp);
    VXLong vxLongAct = auditREST.countXTrxLogs(request);
    Assert.assertNotNull(vxLongAct);
    Assert.assertEquals(vxLongExp, vxLongAct);
    Assert.assertEquals(vxLongExp.getValue(), vxLongAct.getValue());
    Mockito.verify(searchUtil).extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any());
    Mockito.verify(xAuditMgr).getXTrxLogSearchCount(searchCriteria);
}
Also used : VXLong(org.apache.ranger.view.VXLong) SortField(org.apache.ranger.common.SortField) Test(org.junit.Test)

Example 17 with SortField

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

the class TestXAuditREST method Test8countXAccessAudits.

@SuppressWarnings("unchecked")
@Test
public void Test8countXAccessAudits() {
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    searchCriteria.addParam("name", name);
    VXLong vxLongExp = new VXLong();
    vxLongExp.setValue(id);
    Mockito.when(searchUtil.extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any())).thenReturn(searchCriteria);
    Mockito.when(xAuditMgr.getXAccessAuditSearchCount(searchCriteria)).thenReturn(vxLongExp);
    VXLong vxLongAct = auditREST.countXAccessAudits(request);
    Assert.assertNotNull(vxLongAct);
    Assert.assertEquals(vxLongExp, vxLongAct);
    Assert.assertEquals(vxLongExp.getValue(), vxLongAct.getValue());
    Mockito.verify(searchUtil).extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any());
    Mockito.verify(xAuditMgr).getXAccessAuditSearchCount(searchCriteria);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) VXLong(org.apache.ranger.view.VXLong) SortField(org.apache.ranger.common.SortField) Test(org.junit.Test)

Example 18 with SortField

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

the class TestXUserREST method test80searchXModuleDef.

@SuppressWarnings("unchecked")
@Test
public void test80searchXModuleDef() {
    VXModuleDefList testVXModuleDefList = new VXModuleDefList();
    VXModuleDef vXModuleDef = createVXModuleDef();
    List<VXModuleDef> VXModuleDefs = new ArrayList<VXModuleDef>();
    VXModuleDefs.add(vXModuleDef);
    testVXModuleDefList.setvXModuleDef(VXModuleDefs);
    testVXModuleDefList.setTotalCount(1);
    testVXModuleDefList.setStartIndex(1);
    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, "module", "modulename", null)).thenReturn("");
    Mockito.when(searchUtil.extractString(request, testSearchCriteria, "moduleDefList", "id", null)).thenReturn("");
    Mockito.when(searchUtil.extractString(request, testSearchCriteria, "userName", "userName", null)).thenReturn("");
    Mockito.when(searchUtil.extractString(request, testSearchCriteria, "groupName", "groupName", null)).thenReturn("");
    Mockito.when(xUserMgr.searchXModuleDef(testSearchCriteria)).thenReturn(testVXModuleDefList);
    VXModuleDefList outputVXModuleDefList = xUserRest.searchXModuleDef(request);
    assertNotNull(outputVXModuleDefList);
    assertEquals(outputVXModuleDefList.getTotalCount(), testVXModuleDefList.getTotalCount());
    assertEquals(outputVXModuleDefList.getStartIndex(), testVXModuleDefList.getStartIndex());
    Mockito.verify(xUserMgr).searchXModuleDef(testSearchCriteria);
    Mockito.verify(searchUtil).extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any());
    Mockito.verify(searchUtil).extractString(request, testSearchCriteria, "module", "modulename", null);
    Mockito.verify(searchUtil).extractString(request, testSearchCriteria, "moduleDefList", "id", null);
    Mockito.verify(searchUtil).extractString(request, testSearchCriteria, "userName", "userName", null);
    Mockito.verify(searchUtil).extractString(request, testSearchCriteria, "groupName", "groupName", null);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) VXModuleDefList(org.apache.ranger.view.VXModuleDefList) VXModuleDef(org.apache.ranger.view.VXModuleDef) ArrayList(java.util.ArrayList) SortField(org.apache.ranger.common.SortField) SearchCriteria(org.apache.ranger.common.SearchCriteria) Test(org.junit.Test)

Example 19 with SortField

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

the class TestXUserREST method test73getXGroupUsers.

@SuppressWarnings("unchecked")
@Test
public void test73getXGroupUsers() {
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    SearchCriteria testSearchCriteria = createsearchCriteria();
    testSearchCriteria.addParam("xGroupId", id);
    Mockito.when(searchUtil.extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any())).thenReturn(testSearchCriteria);
    VXUser testVXUser = createVXUser();
    VXUserList testVXUserList = new VXUserList();
    List<VXUser> testVXUsers = new ArrayList<VXUser>();
    testVXUsers.add(testVXUser);
    testVXUserList.setVXUsers(testVXUsers);
    testVXUserList.setStartIndex(1);
    testVXUserList.setTotalCount(1);
    Mockito.when(xUserMgr.getXGroupUsers(testSearchCriteria)).thenReturn(testVXUserList);
    VXUserList retVxGroupList = xUserRest.getXGroupUsers(request, id);
    assertNotNull(retVxGroupList);
    assertEquals(testVXUserList.getTotalCount(), retVxGroupList.getTotalCount());
    assertEquals(testVXUserList.getStartIndex(), retVxGroupList.getStartIndex());
    Mockito.verify(xUserMgr).getXGroupUsers(testSearchCriteria);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ArrayList(java.util.ArrayList) SortField(org.apache.ranger.common.SortField) VXUser(org.apache.ranger.view.VXUser) VXUserList(org.apache.ranger.view.VXUserList) SearchCriteria(org.apache.ranger.common.SearchCriteria) Test(org.junit.Test)

Example 20 with SortField

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

the class TestXUserREST method test30searchXGroupUsers.

@SuppressWarnings("unchecked")
@Test
public void test30searchXGroupUsers() {
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    SearchCriteria testSearchCriteria = createsearchCriteria();
    Mockito.when(searchUtil.extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any())).thenReturn(testSearchCriteria);
    VXGroupUserList testVXGroupUserList = new VXGroupUserList();
    VXGroupUser vXGroupUser = createVXGroupUser();
    List<VXGroupUser> vXGroupUsers = new ArrayList<VXGroupUser>();
    vXGroupUsers.add(vXGroupUser);
    testVXGroupUserList.setVXGroupUsers(vXGroupUsers);
    Mockito.when(xUserMgr.searchXGroupUsers(testSearchCriteria)).thenReturn(testVXGroupUserList);
    VXGroupUserList outputvXGroupList = xUserRest.searchXGroupUsers(request);
    Mockito.verify(xUserMgr).searchXGroupUsers(testSearchCriteria);
    Mockito.verify(searchUtil).extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any());
    assertNotNull(outputvXGroupList);
    assertEquals(outputvXGroupList.getClass(), testVXGroupUserList.getClass());
    assertEquals(outputvXGroupList.getResultSize(), testVXGroupUserList.getResultSize());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) VXGroupUserList(org.apache.ranger.view.VXGroupUserList) ArrayList(java.util.ArrayList) VXGroupUser(org.apache.ranger.view.VXGroupUser) 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