### Question:
RangerServiceServiceBase extends RangerBaseModelService<T, V> { @SuppressWarnings("unchecked") public RangerServiceList searchRangerServices(SearchFilter searchFilter) { RangerServiceList retList = new RangerServiceList(); int startIndex = searchFilter.getStartIndex(); int pageSize = searchFilter.getMaxRows(); searchFilter.setStartIndex(0); searchFilter.setMaxRows(Integer.MAX_VALUE); List<XXService> xSvcList = (List<XXService>) searchResources(searchFilter, searchFields, sortFields, retList); List<XXService> permittedServices = new ArrayList<XXService>(); for (XXService xSvc : xSvcList) { if(bizUtil.hasAccess(xSvc, null)){ permittedServices.add(xSvc); } } if(permittedServices.size() > 0) { populatePageList(permittedServices, startIndex, pageSize, retList); } return retList; } RangerServiceServiceBase(); @SuppressWarnings("unchecked") RangerServiceList searchRangerServices(SearchFilter searchFilter);  }### Answer:
@Test public void test3searchRangerServices() { EntityManager entityManager = Mockito.mock(EntityManager.class); SearchFilter searchFilter = new SearchFilter(); searchFilter.setParam(SearchFilter.POLICY_NAME, "policyName"); searchFilter.setParam(SearchFilter.SERVICE_NAME, "serviceName"); String searchString = "policyName"; String sortString = "asc"; List<SearchField> searchFieldList = new ArrayList<SearchField>(); boolean isCountQuery = false; BaseDao baseDao = Mockito.mock(BaseDao.class); Mockito.when(daoManager.getDaoForClassName(Mockito.anyString())) .thenReturn(baseDao); Mockito.when(daoManager.getEntityManager()).thenReturn(entityManager); Mockito.when( searchUtil .createSearchQuery(entityManager, searchString, sortString, searchFilter, searchFieldList, isCountQuery)).thenReturn(null); Mockito.when(bizUtil.getClassType(getClass())).thenReturn(1); RangerServiceList dbRangerServiceList = rangerServiceService .searchRangerServices(searchFilter); Assert.assertNotNull(dbRangerServiceList); Mockito.verify(daoManager).getDaoForClassName(Mockito.anyString()); }