@Test public void getFAQSFromESTest() throws Exception { List<Map<String, Object>> faqsList = new ArrayList<>(); Map<String, Object> faq = new HashMap<>(); faq.put("faqid", "w1q1"); faq.put("widgetid", "w1"); faq.put("faq", "how is overallComplaince % calculated"); faqsList.add(faq); when( elasticSearchRepository.getSortedDataFromES(anyString(), anyString(), anyObject(), anyObject(), anyObject(), anyObject(), anyObject(), anyObject())).thenReturn(faqsList); List<Map<String, Object>> faqsFromES = faqRepositoryImpl.getFAQSFromEs("w1", "1"); assertTrue(faqsFromES.size() > 0); faqsFromES = faqRepositoryImpl.getFAQSFromEs("w1", null); assertTrue(faqsFromES.size() > 0); when( elasticSearchRepository.getSortedDataFromES(anyString(), anyString(), anyObject(), anyObject(), anyObject(), anyObject(), anyObject(), anyObject())).thenThrow(new DataException()); assertThatThrownBy(() -> faqRepositoryImpl.getFAQSFromEs("w1", "1")).isInstanceOf(DataException.class); }
@Override public List<Map<String, Object>> getFAQSFromEs(String widgetId, String domainId) throws DataException { Map<String, Object> mustFilter = new HashMap<>(); mustFilter.put(CommonUtils.convertAttributetoKeyword("widgetid"), widgetId); if (!Strings.isNullOrEmpty(domainId)) { mustFilter.put(CommonUtils.convertAttributetoKeyword("domainid"), domainId); } try{ return elasticSearchRepository.getSortedDataFromES("faqs", "faqinfo", mustFilter, null, null, null, null, null); }catch(Exception e){ throw new DataException(e); } }
FAQRespositoryImpl implements FAQRepository, Constants { @Override public List<Map<String, Object>> getFAQSFromEs(String widgetId, String domainId) throws DataException { Map<String, Object> mustFilter = new HashMap<>(); mustFilter.put(CommonUtils.convertAttributetoKeyword("widgetid"), widgetId); if (!Strings.isNullOrEmpty(domainId)) { mustFilter.put(CommonUtils.convertAttributetoKeyword("domainid"), domainId); } try{ return elasticSearchRepository.getSortedDataFromES("faqs", "faqinfo", mustFilter, null, null, null, null, null); }catch(Exception e){ throw new DataException(e); } } }
FAQRespositoryImpl implements FAQRepository, Constants { @Override public List<Map<String, Object>> getFAQSFromEs(String widgetId, String domainId) throws DataException { Map<String, Object> mustFilter = new HashMap<>(); mustFilter.put(CommonUtils.convertAttributetoKeyword("widgetid"), widgetId); if (!Strings.isNullOrEmpty(domainId)) { mustFilter.put(CommonUtils.convertAttributetoKeyword("domainid"), domainId); } try{ return elasticSearchRepository.getSortedDataFromES("faqs", "faqinfo", mustFilter, null, null, null, null, null); }catch(Exception e){ throw new DataException(e); } }  }
FAQRespositoryImpl implements FAQRepository, Constants { @Override public List<Map<String, Object>> getFAQSFromEs(String widgetId, String domainId) throws DataException { Map<String, Object> mustFilter = new HashMap<>(); mustFilter.put(CommonUtils.convertAttributetoKeyword("widgetid"), widgetId); if (!Strings.isNullOrEmpty(domainId)) { mustFilter.put(CommonUtils.convertAttributetoKeyword("domainid"), domainId); } try{ return elasticSearchRepository.getSortedDataFromES("faqs", "faqinfo", mustFilter, null, null, null, null, null); }catch(Exception e){ throw new DataException(e); } }  @Override List<Map<String, Object>> getFAQSFromEs(String widgetId,
            String domainId); @Override List<Map<String, Object>> getRelevantFAQSFromEs(String widgetId,
            String domainId, List<String> tag, List<String> faqid,
            List<Map<String, Object>> releventfaqs); }
FAQRespositoryImpl implements FAQRepository, Constants { @Override public List<Map<String, Object>> getFAQSFromEs(String widgetId, String domainId) throws DataException { Map<String, Object> mustFilter = new HashMap<>(); mustFilter.put(CommonUtils.convertAttributetoKeyword("widgetid"), widgetId); if (!Strings.isNullOrEmpty(domainId)) { mustFilter.put(CommonUtils.convertAttributetoKeyword("domainid"), domainId); } try{ return elasticSearchRepository.getSortedDataFromES("faqs", "faqinfo", mustFilter, null, null, null, null, null); }catch(Exception e){ throw new DataException(e); } }  @Override List<Map<String, Object>> getFAQSFromEs(String widgetId,
            String domainId); @Override List<Map<String, Object>> getRelevantFAQSFromEs(String widgetId,
            String domainId, List<String> tag, List<String> faqid,
            List<Map<String, Object>> releventfaqs);  }