### Question:
ESUtils { public static List<Map<String, String>> getResourcesFromEs(String index, String targetType, Map<String, String> filter, List<String> fields) throws Exception { if (Strings.isNullOrEmpty(index) || Strings.isNullOrEmpty(targetType)) { throw new Exception("pac_es or targetType cannot be null"); } String url = getEsUrl(); if (Strings.isNullOrEmpty(url)) { throw new Exception("ES_URI not found in the enviroment variables, do define one end point for ES"); } Map<String, Object> effectiveFilter = new HashMap<>(); effectiveFilter.putAll(getFilterForType(targetType)); if (null != filter) { effectiveFilter.putAll(filter); } logger.debug("querying ES for target type:" + targetType); Long totalDocs = getTotalDocumentCountForIndexAndType(url, index, targetType, effectiveFilter, null, null); logger.debug("total resource count" + totalDocs); List<Map<String, String>> details = getDataFromES(url, index.toLowerCase(), targetType.toLowerCase(), effectiveFilter, null, null, fields, 0, totalDocs); return details; }  static List<Map<String, String>> getResourcesFromEs(String index, String targetType,
            Map<String, String> filter, List<String> fields); @SuppressWarnings("unchecked") static long getTotalDocumentCountForIndexAndType(String url, String index, String type,
            Map<String, Object> filter, Map<String, Object> mustNotFilter, HashMultimap<String, Object> shouldFilter); static boolean isValidIndex(final String url, final String index); static boolean isValidType(final String url, final String index, final String type); static String getEsUrl(); static String createMapping(String esUrl, String index, String type); static String createMappingWithParent(String esUrl, String index, String type, String parentType); static void createIndex(String url, String indexName); static void ensureIndexAndTypeForAnnotation(Annotation annotation, Boolean createIndexIfNotFound); static String buildIndexNameFromAnnotation(final Annotation annotation); static String getIssueTypeFromAnnotation(Annotation annotation); @SuppressWarnings("unchecked") static List<Map<String, String>> getDataFromES(final String url, String dataSource, String entityType,
            Map<String, Object> mustFilter, final Map<String, Object> mustNotFilter,
            final HashMultimap<String, Object> shouldFilter, List<String> fields, long from, long size); static String convertAttributetoKeyword(String attributeName); static Map<String, String> getDocumentForId(String index, String targetType, String _id); static Boolean publishMetrics(Map<String, Object> evalResults,String type); static int getESPort(); static String getESHost(); static Boolean doESPublish(Map<String, Object> evalResults, String indexName, String type); static Boolean doESUpdate(String docId,Map<String, Object> evalResults, String indexName, String type); static String createKeyword(final String key);  }### Answer:
@Test(expected=Exception.class) public void testGetResourcesFromEsWithNoEsURL() throws Exception{ ESUtils.getResourcesFromEs("test", "test", null, null); }
@Test public void testGetResourcesFromEs() throws Exception{ PowerMockito.when(CommonUtils.doHttpPost(anyString(), anyString(),anyMap())).thenReturn("{\"count\":\"10\"}"); assertNotNull(ESUtils.getResourcesFromEs("test", "test", null, null)); }