@Test public void getAccountsFromESTest()throws Exception{ List<Map<String, Object>>accountList= new ArrayList<>(); Map<String,Object>accountDetails = new HashMap<>(); accountDetails.put("accountName", "name"); accountDetails.put("accountid", "1234"); accountList.add(accountDetails); when( elasticSearchRepository.getSortedDataFromES(anyString(), anyString(), anyObject(), anyObject(), anyObject(), anyObject(), anyObject(), anyObject())).thenReturn(accountList); filterRepositoryImpl.getAccountsFromES("aws-all"); when( elasticSearchRepository.getSortedDataFromES(anyString(), anyString(), anyObject(), anyObject(), anyObject(), anyObject(), anyObject(), anyObject())).thenThrow(new RuntimeException()); assertThatThrownBy(() -> filterRepositoryImpl.getAccountsFromES("aws-all")).isInstanceOf(DataException.class); }
public List<Map<String, Object>> getAccountsFromES(String assetGroup) throws DataException { Map<String, Object> mustFilter = new HashMap<>(); mustFilter.put("latest", "true"); ArrayList<String> fields = new ArrayList<>(); fields.add("accountname"); fields.add("accountid"); try{ return elasticSearchRepository.getSortedDataFromES(assetGroup, "account", mustFilter, null, null, fields, null, null); }catch(Exception e){ throw new DataException(e); } }
FilterRepositoryImpl implements FilterRepository, Constants { public List<Map<String, Object>> getAccountsFromES(String assetGroup) throws DataException { Map<String, Object> mustFilter = new HashMap<>(); mustFilter.put("latest", "true"); ArrayList<String> fields = new ArrayList<>(); fields.add("accountname"); fields.add("accountid"); try{ return elasticSearchRepository.getSortedDataFromES(assetGroup, "account", mustFilter, null, null, fields, null, null); }catch(Exception e){ throw new DataException(e); } } }
FilterRepositoryImpl implements FilterRepository, Constants { public List<Map<String, Object>> getAccountsFromES(String assetGroup) throws DataException { Map<String, Object> mustFilter = new HashMap<>(); mustFilter.put("latest", "true"); ArrayList<String> fields = new ArrayList<>(); fields.add("accountname"); fields.add("accountid"); try{ return elasticSearchRepository.getSortedDataFromES(assetGroup, "account", mustFilter, null, null, fields, null, null); }catch(Exception e){ throw new DataException(e); } }  }
FilterRepositoryImpl implements FilterRepository, Constants { public List<Map<String, Object>> getAccountsFromES(String assetGroup) throws DataException { Map<String, Object> mustFilter = new HashMap<>(); mustFilter.put("latest", "true"); ArrayList<String> fields = new ArrayList<>(); fields.add("accountname"); fields.add("accountid"); try{ return elasticSearchRepository.getSortedDataFromES(assetGroup, "account", mustFilter, null, null, fields, null, null); }catch(Exception 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); }
FilterRepositoryImpl implements FilterRepository, Constants { public List<Map<String, Object>> getAccountsFromES(String assetGroup) throws DataException { Map<String, Object> mustFilter = new HashMap<>(); mustFilter.put("latest", "true"); ArrayList<String> fields = new ArrayList<>(); fields.add("accountname"); fields.add("accountid"); try{ return elasticSearchRepository.getSortedDataFromES(assetGroup, "account", mustFilter, null, null, fields, null, null); }catch(Exception 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);  }