@Test public void getTrendProgressTest() throws Exception { Map<String,Long> taggingInfoMap = new HashMap<>(); taggingInfoMap.put("tagged", 100l); taggingInfoMap.put("untagged", 2114l); taggingInfoMap.put("assets", 2123l); taggingInfoMap.put("compliance", 21l); taggingInfoMap.put("certificates", 21l); taggingInfoMap.put("patched_instances", 100l); taggingInfoMap.put("unpatched_instances", 2114l); taggingInfoMap.put("total_instances", 2123l); taggingInfoMap.put("patching_percentage", 21l); taggingInfoMap.put("certificates_expiring", 1000l); Map<String, Object> vulnInfoMap = new HashMap<>(); vulnInfoMap.put("hosts", "200"); vulnInfoMap.put("totalVulnerableAssets", "2000"); when(repository.getTrendProgress(anyString(), anyString(),anyObject(),anyObject(),anyString())) .thenReturn(CommonTestUtil.getListMapObject()); when(complianceService.getTagging(anyString(), anyString())) .thenReturn(taggingInfoMap); when(complianceService.getCertificates(anyString())) .thenReturn(taggingInfoMap); when(complianceService.getRulecompliance(anyObject())) .thenReturn(CommonTestUtil.getResponseWithOrder()); when(complianceService.getPatching(anyString(),anyString(),anyString())) .thenReturn(taggingInfoMap); when(complianceService.getOverallComplianceByDomain(anyString(),anyString())) .thenReturn(CommonTestUtil.getMapObject()); when(complianceService.getDistribution(anyString(),anyString())) .thenReturn(CommonTestUtil.getMapObject()); assertThat(issueTrendServiceImpl.getTrendProgress("ansString", "s3",LocalDate.now(),LocalDate.now(),"tagcompliance"), is(notNullValue())); assertThat(issueTrendServiceImpl.getTrendProgress("", "",LocalDate.now(),LocalDate.now(),"certcompliance"), is(notNullValue())); assertThat(issueTrendServiceImpl.getTrendProgress("", "",LocalDate.now(),LocalDate.now(),"vulncompliance"), is(notNullValue())); assertThat(issueTrendServiceImpl.getTrendProgress("", "",LocalDate.now(),LocalDate.now(),"issuecompliance"), is(notNullValue())); assertThat(issueTrendServiceImpl.getTrendProgress("", "",LocalDate.now(),LocalDate.now(),"patching"), is(notNullValue())); assertThat(issueTrendServiceImpl.getTrendProgress("", "",LocalDate.now(),LocalDate.now(),"compliance"), is(notNullValue())); assertThat(issueTrendServiceImpl.getTrendProgress("", "",LocalDate.now(),LocalDate.now(),"issues"), is(notNullValue())); }
@Override public Map<String, Object> getTrendProgress(String assetGroup, String ruleId, LocalDate startDate, LocalDate endDate, String trendCategory) throws ServiceException { List<Map<String, Object>> trendList; try{ trendList = repository.getTrendProgress( assetGroup, ruleId, startDate, endDate, trendCategory); }catch(DataException e){ throw new ServiceException(e); } if (!trendList.isEmpty()) { Comparator<Map<String, Object>> comp = (m1, m2) -> LocalDate.parse( m1.get("date").toString(), DateTimeFormatter.ISO_DATE) .compareTo( LocalDate.parse(m2.get("date").toString(), DateTimeFormatter.ISO_DATE)); Collections.sort(trendList, comp); LocalDate trendStartDate = LocalDate.parse(trendList.get(0) .get("date").toString()); fillNoDataDatesWithPrevious(trendList, trendStartDate, endDate); useRealTimeDataForLatestDate(trendList, assetGroup, trendCategory, ruleId, null); appendWithCompliancePercent(trendList); return segregateTrendProgressByWeek(assetGroup, trendList, trendStartDate, endDate); } else { return new HashMap<>(); } }
IssueTrendServiceImpl implements IssueTrendService, Constants { @Override public Map<String, Object> getTrendProgress(String assetGroup, String ruleId, LocalDate startDate, LocalDate endDate, String trendCategory) throws ServiceException { List<Map<String, Object>> trendList; try{ trendList = repository.getTrendProgress( assetGroup, ruleId, startDate, endDate, trendCategory); }catch(DataException e){ throw new ServiceException(e); } if (!trendList.isEmpty()) { Comparator<Map<String, Object>> comp = (m1, m2) -> LocalDate.parse( m1.get("date").toString(), DateTimeFormatter.ISO_DATE) .compareTo( LocalDate.parse(m2.get("date").toString(), DateTimeFormatter.ISO_DATE)); Collections.sort(trendList, comp); LocalDate trendStartDate = LocalDate.parse(trendList.get(0) .get("date").toString()); fillNoDataDatesWithPrevious(trendList, trendStartDate, endDate); useRealTimeDataForLatestDate(trendList, assetGroup, trendCategory, ruleId, null); appendWithCompliancePercent(trendList); return segregateTrendProgressByWeek(assetGroup, trendList, trendStartDate, endDate); } else { return new HashMap<>(); } } }
IssueTrendServiceImpl implements IssueTrendService, Constants { @Override public Map<String, Object> getTrendProgress(String assetGroup, String ruleId, LocalDate startDate, LocalDate endDate, String trendCategory) throws ServiceException { List<Map<String, Object>> trendList; try{ trendList = repository.getTrendProgress( assetGroup, ruleId, startDate, endDate, trendCategory); }catch(DataException e){ throw new ServiceException(e); } if (!trendList.isEmpty()) { Comparator<Map<String, Object>> comp = (m1, m2) -> LocalDate.parse( m1.get("date").toString(), DateTimeFormatter.ISO_DATE) .compareTo( LocalDate.parse(m2.get("date").toString(), DateTimeFormatter.ISO_DATE)); Collections.sort(trendList, comp); LocalDate trendStartDate = LocalDate.parse(trendList.get(0) .get("date").toString()); fillNoDataDatesWithPrevious(trendList, trendStartDate, endDate); useRealTimeDataForLatestDate(trendList, assetGroup, trendCategory, ruleId, null); appendWithCompliancePercent(trendList); return segregateTrendProgressByWeek(assetGroup, trendList, trendStartDate, endDate); } else { return new HashMap<>(); } }  }
IssueTrendServiceImpl implements IssueTrendService, Constants { @Override public Map<String, Object> getTrendProgress(String assetGroup, String ruleId, LocalDate startDate, LocalDate endDate, String trendCategory) throws ServiceException { List<Map<String, Object>> trendList; try{ trendList = repository.getTrendProgress( assetGroup, ruleId, startDate, endDate, trendCategory); }catch(DataException e){ throw new ServiceException(e); } if (!trendList.isEmpty()) { Comparator<Map<String, Object>> comp = (m1, m2) -> LocalDate.parse( m1.get("date").toString(), DateTimeFormatter.ISO_DATE) .compareTo( LocalDate.parse(m2.get("date").toString(), DateTimeFormatter.ISO_DATE)); Collections.sort(trendList, comp); LocalDate trendStartDate = LocalDate.parse(trendList.get(0) .get("date").toString()); fillNoDataDatesWithPrevious(trendList, trendStartDate, endDate); useRealTimeDataForLatestDate(trendList, assetGroup, trendCategory, ruleId, null); appendWithCompliancePercent(trendList); return segregateTrendProgressByWeek(assetGroup, trendList, trendStartDate, endDate); } else { return new HashMap<>(); } }  Asset finfindByName(String accountName); @Override Map<String, Long> getTrendForIssues(String assetGroup,
            String fromDate, String toDate, String severity, String ruleId,
            String policyId, String app, String env); @Override Map<String, Object> getComplianceTrendProgress(String assetGroup,
            LocalDate fromDate, String domain); @Override Map<String, Object> getTrendProgress(String assetGroup,
            String ruleId, LocalDate startDate, LocalDate endDate,
            String trendCategory); @Override void useRealTimeDataForLatestDate(
            List<Map<String, Object>> trendList, String ag,
            String trendCategory, String ruleId, String domain); @Override Map<String, Object> getTrendIssues(String assetGroup,
            LocalDate from, LocalDate to, Map<String, String> filter,
            String domain); }
IssueTrendServiceImpl implements IssueTrendService, Constants { @Override public Map<String, Object> getTrendProgress(String assetGroup, String ruleId, LocalDate startDate, LocalDate endDate, String trendCategory) throws ServiceException { List<Map<String, Object>> trendList; try{ trendList = repository.getTrendProgress( assetGroup, ruleId, startDate, endDate, trendCategory); }catch(DataException e){ throw new ServiceException(e); } if (!trendList.isEmpty()) { Comparator<Map<String, Object>> comp = (m1, m2) -> LocalDate.parse( m1.get("date").toString(), DateTimeFormatter.ISO_DATE) .compareTo( LocalDate.parse(m2.get("date").toString(), DateTimeFormatter.ISO_DATE)); Collections.sort(trendList, comp); LocalDate trendStartDate = LocalDate.parse(trendList.get(0) .get("date").toString()); fillNoDataDatesWithPrevious(trendList, trendStartDate, endDate); useRealTimeDataForLatestDate(trendList, assetGroup, trendCategory, ruleId, null); appendWithCompliancePercent(trendList); return segregateTrendProgressByWeek(assetGroup, trendList, trendStartDate, endDate); } else { return new HashMap<>(); } }  Asset finfindByName(String accountName); @Override Map<String, Long> getTrendForIssues(String assetGroup,
            String fromDate, String toDate, String severity, String ruleId,
            String policyId, String app, String env); @Override Map<String, Object> getComplianceTrendProgress(String assetGroup,
            LocalDate fromDate, String domain); @Override Map<String, Object> getTrendProgress(String assetGroup,
            String ruleId, LocalDate startDate, LocalDate endDate,
            String trendCategory); @Override void useRealTimeDataForLatestDate(
            List<Map<String, Object>> trendList, String ag,
            String trendCategory, String ruleId, String domain); @Override Map<String, Object> getTrendIssues(String assetGroup,
            LocalDate from, LocalDate to, Map<String, String> filter,
            String domain);  }