@Test public void getQuartersWithPatchingData() throws Exception { Map<String, Long> patchingDataByQuarter = new HashMap<>(); patchingDataByQuarter.put("1", 100l); patchingDataByQuarter.put("2", 200l); when( elasticSearchRepository.getDateHistogramForIndexAndTypeByInterval(anyString(), anyString(), anyObject(), anyObject(), anyObject(), anyString(), anyString())).thenReturn( patchingDataByQuarter); patchingRepositoryImpl.getQuartersWithPatchingData("aws-all"); patchingRepositoryImpl.getQuartersWithPatchingData(null); when( elasticSearchRepository.getDateHistogramForIndexAndTypeByInterval(anyString(), anyString(), anyObject(), anyObject(), anyObject(), anyString(), anyString())).thenThrow( new RuntimeException()); assertThatThrownBy(() -> patchingRepositoryImpl.getQuartersWithPatchingData("aws-all")).isInstanceOf( DataException.class); }
@Override public Map<String, Long> getQuartersWithPatchingData(String assetGroup) throws DataException { Map<String, Object> mustFilter = null; if (StringUtils.isNotBlank(assetGroup)) { mustFilter = new HashMap<>(); mustFilter.put(CommonUtils.convertAttributetoKeyword("ag"), assetGroup); } try{ return elasticSearchRepository .getDateHistogramForIndexAndTypeByInterval("assetgroup_stats", "patching", mustFilter, null, null, "date", "quarter"); } catch(Exception e){ throw new DataException(e); } }
PatchingRepositoryImpl implements PatchingRepository, Constants { @Override public Map<String, Long> getQuartersWithPatchingData(String assetGroup) throws DataException { Map<String, Object> mustFilter = null; if (StringUtils.isNotBlank(assetGroup)) { mustFilter = new HashMap<>(); mustFilter.put(CommonUtils.convertAttributetoKeyword("ag"), assetGroup); } try{ return elasticSearchRepository .getDateHistogramForIndexAndTypeByInterval("assetgroup_stats", "patching", mustFilter, null, null, "date", "quarter"); } catch(Exception e){ throw new DataException(e); } } }
PatchingRepositoryImpl implements PatchingRepository, Constants { @Override public Map<String, Long> getQuartersWithPatchingData(String assetGroup) throws DataException { Map<String, Object> mustFilter = null; if (StringUtils.isNotBlank(assetGroup)) { mustFilter = new HashMap<>(); mustFilter.put(CommonUtils.convertAttributetoKeyword("ag"), assetGroup); } try{ return elasticSearchRepository .getDateHistogramForIndexAndTypeByInterval("assetgroup_stats", "patching", mustFilter, null, null, "date", "quarter"); } catch(Exception e){ throw new DataException(e); } }  }
PatchingRepositoryImpl implements PatchingRepository, Constants { @Override public Map<String, Long> getQuartersWithPatchingData(String assetGroup) throws DataException { Map<String, Object> mustFilter = null; if (StringUtils.isNotBlank(assetGroup)) { mustFilter = new HashMap<>(); mustFilter.put(CommonUtils.convertAttributetoKeyword("ag"), assetGroup); } try{ return elasticSearchRepository .getDateHistogramForIndexAndTypeByInterval("assetgroup_stats", "patching", mustFilter, null, null, "date", "quarter"); } 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 Map<String, Long> getQuartersWithPatchingData(String assetGroup) throws DataException { Map<String, Object> mustFilter = null; if (StringUtils.isNotBlank(assetGroup)) { mustFilter = new HashMap<>(); mustFilter.put(CommonUtils.convertAttributetoKeyword("ag"), assetGroup); } try{ return elasticSearchRepository .getDateHistogramForIndexAndTypeByInterval("assetgroup_stats", "patching", mustFilter, null, null, "date", "quarter"); } 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);  }