### Question:
FilterServiceImpl implements FilterService, Constants { public List<Map<String, Object>> getRules(String assetGroup, String domain) throws ServiceException { List<Map<String, Object>> ruleDetList = new ArrayList<>(); String ttypes = complianceRepository.getTargetTypeForAG(assetGroup, domain); List<Map<String, Object>> ruleIdsFromDb; try{ ruleIdsFromDb = complianceRepository .getRuleIdWithDisplayNameQuery(ttypes); }catch(DataException e){ throw new ServiceException(e); } noDataFoundCheck(emptyAssetCount, ruleIdsFromDb); ruleIdsFromDb.parallelStream().forEach(policy -> { Map<String, Object> ruleMap = new HashMap<>(); String ruleId = policy.get(RULEID).toString(); String ruleName = policy.get(RULE_DISPAY_NAME).toString(); ruleMap.put(NAME, ruleName); ruleMap.put(ID, ruleId); synchronized (ruleDetList) { ruleDetList.add(ruleMap); } }); if(ruleDetList.isEmpty()){ throw new ServiceException(NO_DATA_FOUND); } return ruleDetList; }  List<Map<String, Object>> getFilters(int filterId, String domain); List<Map<String, Object>> getPolicies(String assetGroup,
            String domain); List<Map<String, Object>> getRegions(String assetGroup); List<Map<String, Object>> getAccounts(String assetGroup); List<Map<String, Object>> getRules(String assetGroup, String domain); List<Map<String, Object>> getApplications(String assetGroup,
            String domain); List<Map<String, Object>> getEnvironmentsByAssetGroup(
            String assetGroup, String application, String domain); List<Map<String, Object>> getTargetTypesForAssetGroup(
            String assetGroup, String domain);  }### Answer:
@Test public void getRulesTest() throws Exception { String targetTypes = "'ec2','s3','volume'"; Map<String, Object> ruleMap = new HashMap<>(); List<Map<String, Object>> ruleList = new ArrayList<>(); ruleMap.put("ruleId", "ruleId"); ruleMap.put("displayName", "Amazon RDS DB instances should not be idle"); ruleList.add(ruleMap); when(complainceRepository.getTargetTypeForAG(anyString(),anyString())) .thenReturn(targetTypes); when(complainceRepository.getRuleIdWithDisplayNameQuery(anyString())) .thenReturn(ruleList); assertThat(filterServiceImpl.getRules("dummyString","testString"), is(notNullValue())); when(complainceRepository.getRuleIdWithDisplayNameQuery(anyString())).thenThrow(new DataException()); assertThatThrownBy( () -> filterServiceImpl.getRules("dummyString","qwe")).isInstanceOf(ServiceException.class); }