### Question:
FilterRepositoryImpl implements FilterRepository, Constants { public Map<String, Long> getPoliciesFromES(String assetGroup) throws DataException { Map<String, Object> mustFilter = new HashMap<>(); Map<String, Object> mustNotFilter = new HashMap<>(); String aggsFilter = CommonUtils.convertAttributetoKeyword("policyId"); try{ return elasticSearchRepository.getTotalDistributionForIndexAndType( assetGroup, null, mustFilter, mustNotFilter, null, aggsFilter, 1000, null); }catch(Exception e){ logger.error("error in getPoliciesFromES",e); throw new DataException(e); } }  @Override List<Map<String, Object>> getFiltersFromDb(int filterId); List<Map<String, Object>> getPoliciesFromDB(String targetTypes); Map<String, Long> getPoliciesFromES(String assetGroup); List<Map<String, Object>> getAccountsFromES(String assetGroup); Map<String, Long> getRegionsFromES(String assetGroup); Map<String, Long> getRulesFromES(String assetGroup); AssetCountDTO[] getListOfApplications(String assetGroup,
            String domain); AssetCountDTO[] getListOfEnvironments(String assetGroup,
            String application, String domain); AssetCountDTO[] getListOfTargetTypes(String assetGroup, String domain);  }### Answer:
@Test public void getPoliciesFromESTest()throws Exception{ Map<String,Long>policy=new HashMap<>(); policy.put("tagging_policy",19l); policy.put("patching_polcy",2l); when( elasticSearchRepository.getTotalDistributionForIndexAndType(anyString(), anyString(), anyObject(), anyObject(), anyObject(), anyObject(), anyInt(), anyObject())).thenReturn(policy); filterRepositoryImpl.getPoliciesFromES("aws-all"); when( elasticSearchRepository.getTotalDistributionForIndexAndType(anyString(), anyString(), anyObject(), anyObject(), anyObject(), anyObject(), anyInt(), anyObject())).thenThrow(new RuntimeException()); assertThatThrownBy(() -> filterRepositoryImpl.getPoliciesFromES("aws-all")).isInstanceOf(DataException.class); }