@Test public void vulnerabilityAssetsCountTest() throws Exception { List<Map<String, Object>> results = new ArrayList<Map<String, Object>>(); Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map1 = new HashMap<String, Object>(); map.put("ac", "66"); map.put("acname", "second"); map.put("res", "int"); map.put("vp", "brt3"); map.put("geid", "amigo"); map1.put("rr", "345"); map1.put("fd", "sec"); map1.put("ij", "i"); map1.put("cid", "b3"); map1.put("mad", "mi"); results.add(map); results.add(map1); String assetGroup = "abc"; Map<String, Object> mustFilter = new HashMap<>(); Map<String, Object> mustTermsFilter = new HashMap<>(); mustFilter.put("latest", "true"); String targetType = "vulninfo"; int from = 0; int size = 0; String response1 = "{\"aggregations\":{\"severity\":{\"buckets\":[{\"key\":4,\"doc_count\":320}," + "{\"key\":3,\"doc_count\":294},{\"key\":5,\"doc_count\":71}]}}}"; mockStatic(PacHttpUtils.class); when(PacHttpUtils.doHttpPost(anyString(), anyString())).thenReturn(response1); ReflectionTestUtils.setField(vulnerabilityRepository, "esUrl", "dummyEsURL"); when(elasticSearchRepository.getSortedDataFromES(anyString(), anyString(), anyObject(), anyObject(), anyObject(), anyObject(), anyObject(), anyObject())).thenReturn(results); assertThat(vulnerabilityRepository.vulnerabilityAssetsCount(assetGroup, targetType, mustFilter, from, size,mustTermsFilter), is(2)); }
public int vulnerabilityAssetsCount(String assetGroup, String targetType, Map<String, Object> mustFilter, int from, int size, Map<String, Object> mustTermsFilter) throws Exception { List<Map<String, Object>> results = new ArrayList<>(); results = elasticSearchRepository.getSortedDataFromES(assetGroup, targetType, mustFilter, null, null, null, mustTermsFilter, null); return results.size(); }
VulnerabilityRepository implements Constants { public int vulnerabilityAssetsCount(String assetGroup, String targetType, Map<String, Object> mustFilter, int from, int size, Map<String, Object> mustTermsFilter) throws Exception { List<Map<String, Object>> results = new ArrayList<>(); results = elasticSearchRepository.getSortedDataFromES(assetGroup, targetType, mustFilter, null, null, null, mustTermsFilter, null); return results.size(); } }
VulnerabilityRepository implements Constants { public int vulnerabilityAssetsCount(String assetGroup, String targetType, Map<String, Object> mustFilter, int from, int size, Map<String, Object> mustTermsFilter) throws Exception { List<Map<String, Object>> results = new ArrayList<>(); results = elasticSearchRepository.getSortedDataFromES(assetGroup, targetType, mustFilter, null, null, null, mustTermsFilter, null); return results.size(); }  }
VulnerabilityRepository implements Constants { public int vulnerabilityAssetsCount(String assetGroup, String targetType, Map<String, Object> mustFilter, int from, int size, Map<String, Object> mustTermsFilter) throws Exception { List<Map<String, Object>> results = new ArrayList<>(); results = elasticSearchRepository.getSortedDataFromES(assetGroup, targetType, mustFilter, null, null, null, mustTermsFilter, null); return results.size(); }  List<Map<String, Object>> getAllVulnerabilities(List<String> vulnAssetsAffectedQids); List<Map<String, Object>> getAllVulnerabilitiesByAssetGroup(String assetGroup, String targetType,
			Map<String, Object> mustFilter, List<String> occurrenceFieldList, int from, int size,
			Map<String, Object> mustTermsFilter); List<Map<String, Object>> getDetailsByResourceId(String assetGroup, Map<String, Object> mustFilter,
			List<String> resourceFieldList, Map<String, Object> mustTermFilter); Map<String, Long> getAssetsAffectedCount(String assetGroup, Map<String, String> filter, String parentType); List<Map<String, Object>> getVulnerabilyAcrossAppAndEnv(String assetGroup, String filter, String application,
			String parentType, String severity); List<Map<String, Object>> getVulnerabilityTrend(String assetGroup, Map<String, String> filter, Date from,
			Date to); List<Map<String, Object>> getVulnerabilitiesDistribution(String assetGroup, String parentType); Map<String, Object> getVulnerabilitysummaryByResourceId(String resourceId); List<Map<String, Object>> getVulnerabilityDetailsByResourceId(String resourceId); @SuppressWarnings("deprecation") List<Map<String, Object>> fetchExecDirectorApps(); Map<String, Object> getUniqueHost(String assetGroup, String severity); Map<String, Object> getVulnInfo(String assetGroup, String severity); Map<String, Object> getUniqueApp(String assetGroup); List<Map<String, Object>> getAgingSummary(String assetGroup); long getTotalQualysHostCount(String index, String vulnType); Map<String, Object> getVulnerabilityByQid(String qid); Map<String, Object> getDistributionSummaryByInfraType(String assetGroup, String severitylevel,
			String parentType); Map<String, Long> getProdInfoByEnv(String assetGroup, String severitylevel); Map<String, Long> getNonProdInfoByEnv(String assetGroup, String severitylevel); List<Map<String, Object>> getDistributionSummaryByVulnType(String assetGroup, String severity); Map<String, Object> getAllQidByAG(String assetGroup, String severity); Map<String, Long> getAppsBySeverity(String assetGroup, String parentType, String severity); boolean createTrendAnnotation(TrendNote request); void createIndex(String indexName); List<Map<String, Object>> getTrendAnnotations(String ag, Date from); boolean deleteTrendAnnotation(String noteId); List<Map<String, Object>> getDataFromPacmanRDS(String query); long getRunningInstancesCount(String index, String vulnType); long getExemptedByRuleCount(String index, String vulnType); Map<String, Object> getUniqueHostBySeverity(String index, String severity); Map<String, Object> getCompliantHostsBySeverity(String assetGroup); List<String> getNonCompliantResourceIds(String index); @SuppressWarnings("deprecation") List<Map<String, Object>> fetchOrgInfoForApps(); List<Map<String, Object>> getTrendProgress(String assetGroup, String ruleId, LocalDate startDate,
			LocalDate endDate, String trendCategory); int vulnerabilityAssetsCount(String assetGroup, String targetType, Map<String, Object> mustFilter, int from,
			int size, Map<String, Object> mustTermsFilter); }
VulnerabilityRepository implements Constants { public int vulnerabilityAssetsCount(String assetGroup, String targetType, Map<String, Object> mustFilter, int from, int size, Map<String, Object> mustTermsFilter) throws Exception { List<Map<String, Object>> results = new ArrayList<>(); results = elasticSearchRepository.getSortedDataFromES(assetGroup, targetType, mustFilter, null, null, null, mustTermsFilter, null); return results.size(); }  List<Map<String, Object>> getAllVulnerabilities(List<String> vulnAssetsAffectedQids); List<Map<String, Object>> getAllVulnerabilitiesByAssetGroup(String assetGroup, String targetType,
			Map<String, Object> mustFilter, List<String> occurrenceFieldList, int from, int size,
			Map<String, Object> mustTermsFilter); List<Map<String, Object>> getDetailsByResourceId(String assetGroup, Map<String, Object> mustFilter,
			List<String> resourceFieldList, Map<String, Object> mustTermFilter); Map<String, Long> getAssetsAffectedCount(String assetGroup, Map<String, String> filter, String parentType); List<Map<String, Object>> getVulnerabilyAcrossAppAndEnv(String assetGroup, String filter, String application,
			String parentType, String severity); List<Map<String, Object>> getVulnerabilityTrend(String assetGroup, Map<String, String> filter, Date from,
			Date to); List<Map<String, Object>> getVulnerabilitiesDistribution(String assetGroup, String parentType); Map<String, Object> getVulnerabilitysummaryByResourceId(String resourceId); List<Map<String, Object>> getVulnerabilityDetailsByResourceId(String resourceId); @SuppressWarnings("deprecation") List<Map<String, Object>> fetchExecDirectorApps(); Map<String, Object> getUniqueHost(String assetGroup, String severity); Map<String, Object> getVulnInfo(String assetGroup, String severity); Map<String, Object> getUniqueApp(String assetGroup); List<Map<String, Object>> getAgingSummary(String assetGroup); long getTotalQualysHostCount(String index, String vulnType); Map<String, Object> getVulnerabilityByQid(String qid); Map<String, Object> getDistributionSummaryByInfraType(String assetGroup, String severitylevel,
			String parentType); Map<String, Long> getProdInfoByEnv(String assetGroup, String severitylevel); Map<String, Long> getNonProdInfoByEnv(String assetGroup, String severitylevel); List<Map<String, Object>> getDistributionSummaryByVulnType(String assetGroup, String severity); Map<String, Object> getAllQidByAG(String assetGroup, String severity); Map<String, Long> getAppsBySeverity(String assetGroup, String parentType, String severity); boolean createTrendAnnotation(TrendNote request); void createIndex(String indexName); List<Map<String, Object>> getTrendAnnotations(String ag, Date from); boolean deleteTrendAnnotation(String noteId); List<Map<String, Object>> getDataFromPacmanRDS(String query); long getRunningInstancesCount(String index, String vulnType); long getExemptedByRuleCount(String index, String vulnType); Map<String, Object> getUniqueHostBySeverity(String index, String severity); Map<String, Object> getCompliantHostsBySeverity(String assetGroup); List<String> getNonCompliantResourceIds(String index); @SuppressWarnings("deprecation") List<Map<String, Object>> fetchOrgInfoForApps(); List<Map<String, Object>> getTrendProgress(String assetGroup, String ruleId, LocalDate startDate,
			LocalDate endDate, String trendCategory); int vulnerabilityAssetsCount(String assetGroup, String targetType, Map<String, Object> mustFilter, int from,
			int size, Map<String, Object> mustTermsFilter);  }