### Question:
TrendRepositoryImpl implements TrendRepository, Constants { @Override public List<Map<String, Object>> getTrendProgress(String assetGroup, String ruleId, LocalDate startDate, LocalDate endDate, String trendCategory) throws DataException { Map<String, Object> mustFilter = new HashMap<>(); mustFilter.put(CommonUtils.convertAttributetoKeyword("ag"), assetGroup); if ("issuecompliance".equals(trendCategory)) { mustFilter.put(CommonUtils.convertAttributetoKeyword("ruleId"), ruleId); } 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(AG_STATS, trendCategory, mustFilter, null, null, Arrays.asList("date", "total", "compliant", "noncompliant", "compliance_percent"), null,null); }catch(Exception e){ throw new DataException(e); } }  @Override List<Map<String, Object>> getComplianceTrendProgress(
            String assetGroup, LocalDate fromDate, String domain,
            Set<String> ruleCat); @Override List<Map<String, Object>> getTrendProgress(String assetGroup,
            String ruleId, LocalDate startDate, LocalDate endDate,
            String trendCategory); @Override List<Map<String, Object>> getTrendIssues(String assetGroup,
            LocalDate startDate, LocalDate endDate, Map<String, String> filter,
            Set<String> ruleSev);  }### Answer:
@Test public void getTrendProgressTest() throws Exception { List<Map<String, Object>> issueTrendProgress = new ArrayList<>(); Map<String, Object> issueTrend = new HashMap<>(); issueTrend.put("date", 01 - 10 - 2018); issueTrend.put("total", 1000); issueTrend.put("compliant", 700); issueTrend.put("non-compliant", 300); issueTrend.put("compliance_percent", 70); issueTrendProgress.add(issueTrend); when( elasticSearchRepository.getSortedDataFromES(anyString(), anyString(), anyObject(), anyObject(), anyObject(), anyObject(), anyObject(), anyObject())).thenReturn(issueTrendProgress); trendRepositoryImpl.getTrendProgress("aws-all", "tagging-rule", LocalDate.now(), LocalDate.now(), "issuecompliance"); trendRepositoryImpl.getTrendProgress("aws-all", "tagging-rule", LocalDate.now(), LocalDate.now(), "othercategory"); when( elasticSearchRepository.getSortedDataFromES(anyString(), anyString(), anyObject(), anyObject(), anyObject(), anyObject(), anyObject(), anyObject())).thenThrow(new RuntimeException()); assertThatThrownBy( () -> trendRepositoryImpl.getTrendProgress("aws-all", "tagging-rule", LocalDate.now(), LocalDate.now(), "issuecompliance")).isInstanceOf(DataException.class); }