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);
}
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);
}
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);
}
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);
}
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());
}
Aggregations