use of org.apache.ranger.view.VXModuleDefList in project ranger by apache.
the class XModuleDefServiceBase method searchModuleDef.
/**
* @param searchCriteria
* @return
*/
public VXModuleDefList searchModuleDef(SearchCriteria searchCriteria) {
VXModuleDefList returnList = new VXModuleDefList();
List<VXModuleDef> vXModuleDefList = new ArrayList<VXModuleDef>();
searchCriteria.setMaxRows(Integer.MAX_VALUE);
List<T> resultList = searchResources(searchCriteria, searchFields, sortFields, returnList);
Map<Long, T> matchModule = new HashMap<Long, T>();
for (T moduleDef : resultList) {
matchModule.put(moduleDef.getId(), moduleDef);
}
List<T> moduleDefList = new ArrayList<T>(matchModule.values());
// Iterate over the result list and create the return list
for (T gjXModuleDef : moduleDefList) {
VXModuleDef vXModuleDef = populateViewBean(gjXModuleDef);
vXModuleDefList.add(vXModuleDef);
}
returnList.setTotalCount(vXModuleDefList.size());
returnList.setvXModuleDef(vXModuleDefList);
return returnList;
}
use of org.apache.ranger.view.VXModuleDefList 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);
}
Aggregations