use of org.apache.ranger.common.SearchCriteria in project ranger by apache.
the class TestAssetREST method testGetReportLogs.
@Test
public void testGetReportLogs() {
SearchCriteria searchCriteria = new SearchCriteria();
List<SortField> sortFields = null;
List<VXTrxLog> vXTrxLogs = new ArrayList<VXTrxLog>();
VXTrxLogList vXTrxLogList = new VXTrxLogList();
vXTrxLogList.setVXTrxLogs(vXTrxLogs);
Mockito.when(searchUtil.extractCommonCriterias(request, sortFields)).thenReturn(searchCriteria);
Mockito.when(searchUtil.extractString((HttpServletRequest) Mockito.any(), (SearchCriteria) Mockito.any(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString())).thenReturn("test");
Mockito.when(searchUtil.extractInt((HttpServletRequest) Mockito.any(), (SearchCriteria) Mockito.any(), Mockito.anyString(), Mockito.anyString())).thenReturn((Integer) 8);
Mockito.when(searchUtil.extractDate((HttpServletRequest) Mockito.any(), (SearchCriteria) Mockito.any(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString())).thenReturn(new Date());
Mockito.when(assetMgr.getReportLogs(searchCriteria)).thenReturn(vXTrxLogList);
VXTrxLogList expectedVXTrxLogListt = assetREST.getReportLogs(request);
Assert.assertEquals(vXTrxLogList, expectedVXTrxLogListt);
Mockito.verify(searchUtil, Mockito.times(4)).extractString((HttpServletRequest) Mockito.any(), (SearchCriteria) Mockito.any(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString());
Mockito.verify(searchUtil).extractInt((HttpServletRequest) Mockito.any(), (SearchCriteria) Mockito.any(), Mockito.anyString(), Mockito.anyString());
Mockito.verify(searchUtil, Mockito.times(2)).extractDate((HttpServletRequest) Mockito.any(), (SearchCriteria) Mockito.any(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString());
Mockito.verify(assetMgr).getReportLogs(searchCriteria);
Mockito.verify(searchUtil).extractCommonCriterias(request, sortFields);
}
use of org.apache.ranger.common.SearchCriteria in project ranger by apache.
the class TestAssetREST method testCountXCredentialStores.
@Test
public void testCountXCredentialStores() {
VXLong expectedvXLong = new VXLong();
SearchCriteria searchCriteria = new SearchCriteria();
List<SortField> sortFields = null;
Mockito.when(searchUtil.extractCommonCriterias(request, sortFields)).thenReturn(searchCriteria);
Mockito.when(assetMgr.getXCredentialStoreSearchCount(searchCriteria)).thenReturn(expectedvXLong);
VXLong actualvXLong = assetREST.countXCredentialStores(request);
Assert.assertEquals(expectedvXLong, actualvXLong);
Mockito.verify(assetMgr).getXCredentialStoreSearchCount(searchCriteria);
}
use of org.apache.ranger.common.SearchCriteria in project ranger by apache.
the class TestXUserREST method createsearchCriteria.
private SearchCriteria createsearchCriteria() {
SearchCriteria testsearchCriteria = new SearchCriteria();
testsearchCriteria.setStartIndex(0);
testsearchCriteria.setMaxRows(Integer.MAX_VALUE);
testsearchCriteria.setSortBy("id");
testsearchCriteria.setSortType("asc");
testsearchCriteria.setGetCount(true);
testsearchCriteria.setOwnerId(null);
testsearchCriteria.setGetChildren(false);
testsearchCriteria.setDistinct(false);
return testsearchCriteria;
}
use of org.apache.ranger.common.SearchCriteria 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);
}
use of org.apache.ranger.common.SearchCriteria 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());
}
Aggregations