### Question:
RangerServiceDefServiceBase extends RangerBaseModelService<T, V> { @SuppressWarnings("unchecked") public RangerServiceDefList searchRangerServiceDefs(SearchFilter searchFilter) { RangerServiceDefList retList = new RangerServiceDefList(); int startIndex = searchFilter.getStartIndex(); int pageSize = searchFilter.getMaxRows(); searchFilter.setStartIndex(0); searchFilter.setMaxRows(Integer.MAX_VALUE); List<XXServiceDef> xSvcDefList = (List<XXServiceDef>) searchResources(searchFilter, searchFields, sortFields, retList); List<XXServiceDef> permittedServiceDefs = new ArrayList<XXServiceDef>(); for (XXServiceDef xSvcDef : xSvcDefList) { if (bizUtil.hasAccess(xSvcDef, null)) { permittedServiceDefs.add(xSvcDef); } } if (permittedServiceDefs.size() > 0) { populatePageList(permittedServiceDefs, startIndex, pageSize, retList); } return retList; } RangerServiceDefServiceBase(); XXServiceConfigDef populateRangerServiceConfigDefToXX(RangerServiceConfigDef vObj, XXServiceConfigDef xObj,
			XXServiceDef serviceDef, int operationContext); RangerServiceConfigDef populateXXToRangerServiceConfigDef(XXServiceConfigDef xObj); XXResourceDef populateRangerResourceDefToXX(RangerResourceDef vObj, XXResourceDef xObj,
			XXServiceDef serviceDef, int operationContext); RangerResourceDef populateXXToRangerResourceDef(XXResourceDef xObj); XXAccessTypeDef populateRangerAccessTypeDefToXX(RangerAccessTypeDef vObj, XXAccessTypeDef xObj,
			XXServiceDef serviceDef, int operationContext); RangerAccessTypeDef populateXXToRangerAccessTypeDef(XXAccessTypeDef xObj); XXPolicyConditionDef populateRangerPolicyConditionDefToXX(RangerPolicyConditionDef vObj,
			XXPolicyConditionDef xObj, XXServiceDef serviceDef, int operationContext); RangerPolicyConditionDef populateXXToRangerPolicyConditionDef(XXPolicyConditionDef xObj); XXContextEnricherDef populateRangerContextEnricherDefToXX(RangerContextEnricherDef vObj,
			XXContextEnricherDef xObj, XXServiceDef serviceDef, int operationContext); RangerContextEnricherDef populateXXToRangerContextEnricherDef(XXContextEnricherDef xObj); XXEnumDef populateRangerEnumDefToXX(RangerEnumDef vObj, XXEnumDef xObj, XXServiceDef serviceDef,
			int operationContext); RangerEnumDef populateXXToRangerEnumDef(XXEnumDef xObj); XXEnumElementDef populateRangerEnumElementDefToXX(RangerEnumElementDef vObj, XXEnumElementDef xObj,
			XXEnumDef enumDef, int operationContext); RangerEnumElementDef populateXXToRangerEnumElementDef(XXEnumElementDef xObj); @SuppressWarnings("unchecked") RangerServiceDefList searchRangerServiceDefs(SearchFilter searchFilter);  }### Answer:
@Test public void test21searchRangerServiceDefs() { setup(); 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); RangerServiceDefList dbRangerServiceDefList = rangerServiceDefService .searchRangerServiceDefs(searchFilter); Assert.assertNotNull(dbRangerServiceDefList); Mockito.verify(daoManager).getDaoForClassName(Mockito.anyString()); }