@Test public void getPatchingProgressTest() throws Exception { List<Map<String, Object>> pathingProgress = new ArrayList<>(); Map<String, Object> patching = new HashMap<String, Object>(); patching.put("week", 1); patching.put("compliance", 10); when( elasticSearchRepository.getSortedDataFromES(anyString(), anyString(), anyObject(), anyObject(), anyObject(), anyObject(), anyObject(), anyObject())).thenReturn(pathingProgress); patchingRepositoryImpl.getPatchingProgress("aws-all", LocalDate.now(), LocalDate.now()); when( elasticSearchRepository.getSortedDataFromES(anyString(), anyString(), anyObject(), anyObject(), anyObject(), anyObject(), anyObject(), anyObject())).thenThrow(new RuntimeException()); assertThatThrownBy( () -> patchingRepositoryImpl.getPatchingProgress("aws-all", LocalDate.now(), LocalDate.now())) .isInstanceOf(DataException.class); }
@Override public List<Map<String, Object>> getPatchingProgress(String assetGroup, LocalDate startDate, LocalDate endDate) throws DataException { Map<String, Object> mustFilter = new HashMap<>(); mustFilter.put(CommonUtils.convertAttributetoKeyword("ag"), assetGroup); Map<String, Object> rangeMap = new HashMap<>(); rangeMap.put("gte", startDate.format(DateTimeFormatter.ISO_DATE)); rangeMap.put("lte", endDate.format(DateTimeFormatter.ISO_DATE)); Map<String, Object> dateRangeMap = new HashMap<>(); dateRangeMap.put("date", rangeMap); mustFilter.put("range", dateRangeMap); try{ return elasticSearchRepository.getSortedDataFromES("assetgroup_stats", "patching", mustFilter, null, null, Arrays.asList("date", "unpatched_instances", "patched_instances", "total_instances", "patching_percentage"), null, null); } catch(Exception e){ throw new DataException(e); } }
PatchingRepositoryImpl implements PatchingRepository, Constants { @Override public List<Map<String, Object>> getPatchingProgress(String assetGroup, LocalDate startDate, LocalDate endDate) throws DataException { Map<String, Object> mustFilter = new HashMap<>(); mustFilter.put(CommonUtils.convertAttributetoKeyword("ag"), assetGroup); Map<String, Object> rangeMap = new HashMap<>(); rangeMap.put("gte", startDate.format(DateTimeFormatter.ISO_DATE)); rangeMap.put("lte", endDate.format(DateTimeFormatter.ISO_DATE)); Map<String, Object> dateRangeMap = new HashMap<>(); dateRangeMap.put("date", rangeMap); mustFilter.put("range", dateRangeMap); try{ return elasticSearchRepository.getSortedDataFromES("assetgroup_stats", "patching", mustFilter, null, null, Arrays.asList("date", "unpatched_instances", "patched_instances", "total_instances", "patching_percentage"), null, null); } catch(Exception e){ throw new DataException(e); } } }
PatchingRepositoryImpl implements PatchingRepository, Constants { @Override public List<Map<String, Object>> getPatchingProgress(String assetGroup, LocalDate startDate, LocalDate endDate) throws DataException { Map<String, Object> mustFilter = new HashMap<>(); mustFilter.put(CommonUtils.convertAttributetoKeyword("ag"), assetGroup); Map<String, Object> rangeMap = new HashMap<>(); rangeMap.put("gte", startDate.format(DateTimeFormatter.ISO_DATE)); rangeMap.put("lte", endDate.format(DateTimeFormatter.ISO_DATE)); Map<String, Object> dateRangeMap = new HashMap<>(); dateRangeMap.put("date", rangeMap); mustFilter.put("range", dateRangeMap); try{ return elasticSearchRepository.getSortedDataFromES("assetgroup_stats", "patching", mustFilter, null, null, Arrays.asList("date", "unpatched_instances", "patched_instances", "total_instances", "patching_percentage"), null, null); } catch(Exception e){ throw new DataException(e); } }  }
PatchingRepositoryImpl implements PatchingRepository, Constants { @Override public List<Map<String, Object>> getPatchingProgress(String assetGroup, LocalDate startDate, LocalDate endDate) throws DataException { Map<String, Object> mustFilter = new HashMap<>(); mustFilter.put(CommonUtils.convertAttributetoKeyword("ag"), assetGroup); Map<String, Object> rangeMap = new HashMap<>(); rangeMap.put("gte", startDate.format(DateTimeFormatter.ISO_DATE)); rangeMap.put("lte", endDate.format(DateTimeFormatter.ISO_DATE)); Map<String, Object> dateRangeMap = new HashMap<>(); dateRangeMap.put("date", rangeMap); mustFilter.put("range", dateRangeMap); try{ return elasticSearchRepository.getSortedDataFromES("assetgroup_stats", "patching", mustFilter, null, null, Arrays.asList("date", "unpatched_instances", "patched_instances", "total_instances", "patching_percentage"), null, null); } catch(Exception e){ throw new DataException(e); } }  @Override List<Map<String, Object>> getPatchingProgress(String assetGroup,
            LocalDate startDate, LocalDate endDate); @Override List<Map<String, Object>> getIssueInfo(String assetGroup); List<Map<String, Object>> getClosedIssueInfo(String assetGroup,
            int size); @Override List<Map<String, Object>> getInstanceInfo(String assetGroup,
            Map<String, String> filters); @Override List<Map<String, Object>> getExecAndDirectorInfo(); @Override long getInstanceInfoCount(String assetGroup,
            Map<String, String> filters, String searchText); @Override String getAmilAvailDate(int year, int quarter); @Override int getPatchingWindow(); @Override Map<String, Long> getQuartersWithPatchingData(String assetGroup); Map<String, Object> addParentConditionPatching(String targetType); @Override List<Map<String, Object>> getOnpremIssueInfo(String assetGroup); @Override List<Map<String, Object>> getOnpremResourceInfo(String assetGroup,
            Map<String, String> filters); @Override Map<String, Object> getDirectorsAndExcutiveSponsers(String appTag,
            String appType); @Override Map<String, Long> getNonCompliantNumberForAgAndResourceType(
            String assetGroup, String resourceType); @Override List<Map<String, Object>> getPatchingPercentForDateRange(String assetGroup, LocalDate fromDate,
			LocalDate toDate); }
PatchingRepositoryImpl implements PatchingRepository, Constants { @Override public List<Map<String, Object>> getPatchingProgress(String assetGroup, LocalDate startDate, LocalDate endDate) throws DataException { Map<String, Object> mustFilter = new HashMap<>(); mustFilter.put(CommonUtils.convertAttributetoKeyword("ag"), assetGroup); Map<String, Object> rangeMap = new HashMap<>(); rangeMap.put("gte", startDate.format(DateTimeFormatter.ISO_DATE)); rangeMap.put("lte", endDate.format(DateTimeFormatter.ISO_DATE)); Map<String, Object> dateRangeMap = new HashMap<>(); dateRangeMap.put("date", rangeMap); mustFilter.put("range", dateRangeMap); try{ return elasticSearchRepository.getSortedDataFromES("assetgroup_stats", "patching", mustFilter, null, null, Arrays.asList("date", "unpatched_instances", "patched_instances", "total_instances", "patching_percentage"), null, null); } catch(Exception e){ throw new DataException(e); } }  @Override List<Map<String, Object>> getPatchingProgress(String assetGroup,
            LocalDate startDate, LocalDate endDate); @Override List<Map<String, Object>> getIssueInfo(String assetGroup); List<Map<String, Object>> getClosedIssueInfo(String assetGroup,
            int size); @Override List<Map<String, Object>> getInstanceInfo(String assetGroup,
            Map<String, String> filters); @Override List<Map<String, Object>> getExecAndDirectorInfo(); @Override long getInstanceInfoCount(String assetGroup,
            Map<String, String> filters, String searchText); @Override String getAmilAvailDate(int year, int quarter); @Override int getPatchingWindow(); @Override Map<String, Long> getQuartersWithPatchingData(String assetGroup); Map<String, Object> addParentConditionPatching(String targetType); @Override List<Map<String, Object>> getOnpremIssueInfo(String assetGroup); @Override List<Map<String, Object>> getOnpremResourceInfo(String assetGroup,
            Map<String, String> filters); @Override Map<String, Object> getDirectorsAndExcutiveSponsers(String appTag,
            String appType); @Override Map<String, Long> getNonCompliantNumberForAgAndResourceType(
            String assetGroup, String resourceType); @Override List<Map<String, Object>> getPatchingPercentForDateRange(String assetGroup, LocalDate fromDate,
			LocalDate toDate);  }