AppCatalogSolrClient { public List<AppStoreEntry> search(String keyword) { List<AppStoreEntry> apps = new ArrayList<AppStoreEntry>(); SolrClient solr = getSolrClient(); SolrQuery query = new SolrQuery(); if (keyword.length()==0) { query.setQuery("*:*"); query.setFilterQueries("type_s:AppStoreEntry"); } else { query.setQuery(keyword); query.setFilterQueries("type_s:AppStoreEntry"); } query.setRows(40); QueryResponse response; try { response = solr.query(query); Iterator<SolrDocument> list = response.getResults().listIterator(); while (list.hasNext()) { SolrDocument d = list.next(); AppStoreEntry entry = new AppStoreEntry(); entry.setId(d.get("id").toString()); entry.setOrg(d.get("org_s").toString()); entry.setName(d.get("name_s").toString()); entry.setDesc(d.get("desc_s").toString()); entry.setLike(Integer.parseInt(d.get("like_i").toString())); entry.setDownload(Integer.parseInt(d.get("download_i").toString())); apps.add(entry); } } catch (SolrServerException | IOException e) { LOG.error("Error in searching for applications: ", e); } return apps; } AppCatalogSolrClient(); SolrClient getSolrClient(); List<AppStoreEntry> getRecommendedApps(); List<AppStoreEntry> search(String keyword); List<AppEntry> listAppEntries(); AppStoreEntry findAppStoreEntry(String id); AppEntry findAppEntry(String id); void deployApp(String id, Service service); void deleteApp(String id); void register(Application app); void upgradeApp(Service service);  }
@Test public void testSearch() throws Exception { Application example = new Application(); example.setOrganization("jenkins-ci.org"); example.setName("jenkins"); example.setDescription("World leading open source automation system."); example.setIcon("/css/img/feather.png"); spy.register(example); List<AppStoreEntry> results = spy.search("name_s:jenkins"); int expected = 1; int actual = results.size(); assertEquals(expected, actual); }