@Test public void getTrendAnnotationTest() throws Exception { List<Map<String, Object>> annotations = new ArrayList<>(); Map<String, Object> annotation = new HashMap<>(); annotation.put("ag", "ag"); annotations.add(annotation); annotation = new HashMap<>(); annotation.put("ag", ""); annotations.add(annotation); when(vulnerabilityRepository.getTrendAnnotations(anyString(), any(Date.class))).thenReturn(annotations); assertThat(vulnerabilityService.getTrendAnnotations("ag", new Date()).size(), is(2)); }
public List<Map<String, Object>> getTrendAnnotations(String assetGroup, Date from) throws DataException { List<Map<String, Object>> globalAnnotations = new ArrayList<>(); List<Map<String, Object>> assetGroupAnnotations = new ArrayList<>(); List<Map<String, Object>> annotations = vulnerabilityRepository.getTrendAnnotations(assetGroup, from); annotations.parallelStream().forEach(annotation -> { if (StringUtils.isEmpty(annotation.get("ag").toString())) { synchronized (globalAnnotations) { globalAnnotations.add(annotation); } } else { synchronized (assetGroupAnnotations) { assetGroupAnnotations.add(annotation); } } }); Map<String, Object> gloablMap = new HashMap<>(); gloablMap.put("type", "Global"); gloablMap.put("data", globalAnnotations); Map<String, Object> agMap = new HashMap<>(); agMap.put("type", "AssetGroup"); agMap.put("data", assetGroupAnnotations); List<Map<String, Object>> noteList = new ArrayList<>(); noteList.add(agMap); noteList.add(gloablMap); return noteList; }
VulnerabilityService implements Constants { public List<Map<String, Object>> getTrendAnnotations(String assetGroup, Date from) throws DataException { List<Map<String, Object>> globalAnnotations = new ArrayList<>(); List<Map<String, Object>> assetGroupAnnotations = new ArrayList<>(); List<Map<String, Object>> annotations = vulnerabilityRepository.getTrendAnnotations(assetGroup, from); annotations.parallelStream().forEach(annotation -> { if (StringUtils.isEmpty(annotation.get("ag").toString())) { synchronized (globalAnnotations) { globalAnnotations.add(annotation); } } else { synchronized (assetGroupAnnotations) { assetGroupAnnotations.add(annotation); } } }); Map<String, Object> gloablMap = new HashMap<>(); gloablMap.put("type", "Global"); gloablMap.put("data", globalAnnotations); Map<String, Object> agMap = new HashMap<>(); agMap.put("type", "AssetGroup"); agMap.put("data", assetGroupAnnotations); List<Map<String, Object>> noteList = new ArrayList<>(); noteList.add(agMap); noteList.add(gloablMap); return noteList; } }
VulnerabilityService implements Constants { public List<Map<String, Object>> getTrendAnnotations(String assetGroup, Date from) throws DataException { List<Map<String, Object>> globalAnnotations = new ArrayList<>(); List<Map<String, Object>> assetGroupAnnotations = new ArrayList<>(); List<Map<String, Object>> annotations = vulnerabilityRepository.getTrendAnnotations(assetGroup, from); annotations.parallelStream().forEach(annotation -> { if (StringUtils.isEmpty(annotation.get("ag").toString())) { synchronized (globalAnnotations) { globalAnnotations.add(annotation); } } else { synchronized (assetGroupAnnotations) { assetGroupAnnotations.add(annotation); } } }); Map<String, Object> gloablMap = new HashMap<>(); gloablMap.put("type", "Global"); gloablMap.put("data", globalAnnotations); Map<String, Object> agMap = new HashMap<>(); agMap.put("type", "AssetGroup"); agMap.put("data", assetGroupAnnotations); List<Map<String, Object>> noteList = new ArrayList<>(); noteList.add(agMap); noteList.add(gloablMap); return noteList; }  }
VulnerabilityService implements Constants { public List<Map<String, Object>> getTrendAnnotations(String assetGroup, Date from) throws DataException { List<Map<String, Object>> globalAnnotations = new ArrayList<>(); List<Map<String, Object>> assetGroupAnnotations = new ArrayList<>(); List<Map<String, Object>> annotations = vulnerabilityRepository.getTrendAnnotations(assetGroup, from); annotations.parallelStream().forEach(annotation -> { if (StringUtils.isEmpty(annotation.get("ag").toString())) { synchronized (globalAnnotations) { globalAnnotations.add(annotation); } } else { synchronized (assetGroupAnnotations) { assetGroupAnnotations.add(annotation); } } }); Map<String, Object> gloablMap = new HashMap<>(); gloablMap.put("type", "Global"); gloablMap.put("data", globalAnnotations); Map<String, Object> agMap = new HashMap<>(); agMap.put("type", "AssetGroup"); agMap.put("data", assetGroupAnnotations); List<Map<String, Object>> noteList = new ArrayList<>(); noteList.add(agMap); noteList.add(gloablMap); return noteList; }  List<Map<String, Object>> getVulnerabilitiesDetails(String assetGroup, Map<String, String> filter); @SuppressWarnings("unchecked") List<Map<String, Object>> getAllVulnerabilitiesDetailsByAssetGroup(String assetGroup,
			Map<String, String> filter,String applicationFilter,String environmentFilter, String searchText, int from, int size); List<Map<String, Object>> getResourcedetailsByResourceId(String assetGroup,
			List<String> listDistinctResourceId, boolean flag); @SuppressWarnings({ "unchecked" }) Map<String, Object> getVulnerabilitySummary(String assetGroup, String reqSeverity); List<Map<String, Object>> getVulnerabilityByAppAndEnv(String assetGroup, String filter, String application); List<Map<String, Object>> getVulnerabilityTrend(String assetGroup, Map<String, String> filter, Date from,
			Date to); List<Map<String, Object>> getVulnerabilityNewOpenTrend(String assetGroup, String severity, Date from); List<Map<String, Object>> getVulnerabilitiesDistribution(String assetGroup); Object filterMatchingCollectionElements(List<Map<String, Object>> masterDetailList, String searchText,
			boolean b); Map<String, Object> getVulnerabilitysummaryByResourceId(String instanceId); List<Map<String, Object>> getVulnerabilityDetailsByResourceId(String instanceId); List<Map<String, Object>> getAgingSummary(String assetGroup); List<Map<String, Object>> getVulnerabilityByQid(String qid); @SuppressWarnings("unchecked") Map<String, Integer> getHighestLowestPerformers(String assetGroup, String severity, String type); List<Map<String, Object>> getDistributionSummaryByInfraType(String assetGroup, String severity); List<Map<String, Object>> getDistributionSummaryByEnv(String assetGroup, String severity); List<Map<String, Object>> getDistributionSummaryByVulnType(String assetGroup, String severity); List<Map<String, Object>> getRemediationActionsSummary(String assetGroup, String severity); boolean createTrendAnnotation(TrendNote request); List<Map<String, Object>> getTrendAnnotations(String assetGroup, Date from); boolean deleteTrendAnnotation(String noteId); Map<String, Object> getVulnerabilitySummaryByAssets(String assetGroup); List<Map<String, Object>> getVulnerabilityAssetsTrend(String assetGroup, String severity, Date from); Map<String, Map<String, String>> getDirectorsForAGByApp(Set<String> appNames); ResponseEntity<Object> formatException(ServiceException e); Map<String, Object> getTrendProgress(String assetGroup, String ruleId, LocalDate startDate,
			LocalDate endDate, String trendCategory); void useRealTimeDataForLatestDate(List<Map<String, Object>> trendList, String ag, String trendCategory,
			String ruleId, String domain); List<String> getResourceId(List<Map<String, Object>> vulnerabilityOccuranceList); List<Map<String, Object>> getCartesianProduct(List<Map<String, Object>> vulnerabilityOccuranceList,
			List<Map<String, Object>> resourceIdDetails); int vulnerabilityAssetCount(String assetGroup, Map<String, String> termsFilter, String applicationFilter,
			String environmentFilter, int from, int size); int countForTargetType(String assetGroup, String parentType, Map<String, String> termsFilter,
			String applicationFilter, String environmentFilter, int from, int size); }
VulnerabilityService implements Constants { public List<Map<String, Object>> getTrendAnnotations(String assetGroup, Date from) throws DataException { List<Map<String, Object>> globalAnnotations = new ArrayList<>(); List<Map<String, Object>> assetGroupAnnotations = new ArrayList<>(); List<Map<String, Object>> annotations = vulnerabilityRepository.getTrendAnnotations(assetGroup, from); annotations.parallelStream().forEach(annotation -> { if (StringUtils.isEmpty(annotation.get("ag").toString())) { synchronized (globalAnnotations) { globalAnnotations.add(annotation); } } else { synchronized (assetGroupAnnotations) { assetGroupAnnotations.add(annotation); } } }); Map<String, Object> gloablMap = new HashMap<>(); gloablMap.put("type", "Global"); gloablMap.put("data", globalAnnotations); Map<String, Object> agMap = new HashMap<>(); agMap.put("type", "AssetGroup"); agMap.put("data", assetGroupAnnotations); List<Map<String, Object>> noteList = new ArrayList<>(); noteList.add(agMap); noteList.add(gloablMap); return noteList; }  List<Map<String, Object>> getVulnerabilitiesDetails(String assetGroup, Map<String, String> filter); @SuppressWarnings("unchecked") List<Map<String, Object>> getAllVulnerabilitiesDetailsByAssetGroup(String assetGroup,
			Map<String, String> filter,String applicationFilter,String environmentFilter, String searchText, int from, int size); List<Map<String, Object>> getResourcedetailsByResourceId(String assetGroup,
			List<String> listDistinctResourceId, boolean flag); @SuppressWarnings({ "unchecked" }) Map<String, Object> getVulnerabilitySummary(String assetGroup, String reqSeverity); List<Map<String, Object>> getVulnerabilityByAppAndEnv(String assetGroup, String filter, String application); List<Map<String, Object>> getVulnerabilityTrend(String assetGroup, Map<String, String> filter, Date from,
			Date to); List<Map<String, Object>> getVulnerabilityNewOpenTrend(String assetGroup, String severity, Date from); List<Map<String, Object>> getVulnerabilitiesDistribution(String assetGroup); Object filterMatchingCollectionElements(List<Map<String, Object>> masterDetailList, String searchText,
			boolean b); Map<String, Object> getVulnerabilitysummaryByResourceId(String instanceId); List<Map<String, Object>> getVulnerabilityDetailsByResourceId(String instanceId); List<Map<String, Object>> getAgingSummary(String assetGroup); List<Map<String, Object>> getVulnerabilityByQid(String qid); @SuppressWarnings("unchecked") Map<String, Integer> getHighestLowestPerformers(String assetGroup, String severity, String type); List<Map<String, Object>> getDistributionSummaryByInfraType(String assetGroup, String severity); List<Map<String, Object>> getDistributionSummaryByEnv(String assetGroup, String severity); List<Map<String, Object>> getDistributionSummaryByVulnType(String assetGroup, String severity); List<Map<String, Object>> getRemediationActionsSummary(String assetGroup, String severity); boolean createTrendAnnotation(TrendNote request); List<Map<String, Object>> getTrendAnnotations(String assetGroup, Date from); boolean deleteTrendAnnotation(String noteId); Map<String, Object> getVulnerabilitySummaryByAssets(String assetGroup); List<Map<String, Object>> getVulnerabilityAssetsTrend(String assetGroup, String severity, Date from); Map<String, Map<String, String>> getDirectorsForAGByApp(Set<String> appNames); ResponseEntity<Object> formatException(ServiceException e); Map<String, Object> getTrendProgress(String assetGroup, String ruleId, LocalDate startDate,
			LocalDate endDate, String trendCategory); void useRealTimeDataForLatestDate(List<Map<String, Object>> trendList, String ag, String trendCategory,
			String ruleId, String domain); List<String> getResourceId(List<Map<String, Object>> vulnerabilityOccuranceList); List<Map<String, Object>> getCartesianProduct(List<Map<String, Object>> vulnerabilityOccuranceList,
			List<Map<String, Object>> resourceIdDetails); int vulnerabilityAssetCount(String assetGroup, Map<String, String> termsFilter, String applicationFilter,
			String environmentFilter, int from, int size); int countForTargetType(String assetGroup, String parentType, Map<String, String> termsFilter,
			String applicationFilter, String environmentFilter, int from, int size);  }