### Question:
ProductIndex { public List<ProductCatalogEntry> search(String queryString) throws IOException, ParseException { List<ProductCatalogEntry> results = new ArrayList<ProductCatalogEntry>(); IndexReader reader = DirectoryReader.open(dir); IndexSearcher searcher = new IndexSearcher(reader); Analyzer analyzer = new SimpleAnalyzer(); QueryParser parser = new QueryParser(searchField, analyzer); Query query = parser.parse(queryString); TopDocs docs = searcher.search(query, 100); ScoreDoc[] hits = docs.scoreDocs; for (ScoreDoc sd: hits) { Document doc = searcher.doc(sd.doc); results.add(prodcat.getProductById(doc.get("id"))); } reader.close(); return results; } ProductIndex(ProductCatalog prodcat); List<ProductCatalogEntry> search(String queryString);  }### Answer:
@Test public void testSimpleSearch() throws Exception { List<ProductCatalogEntry> res = index.search("GE"); assertEquals(5, res.size()); res = index.search("z-wave"); assertEquals(8, res.size()); }
@Test public void test() throws Exception { List<ProductCatalogEntry> res = index.search("lock"); for (ProductCatalogEntry p : res) { System.out.println("[" + p.getId() + "] " + p.getName()); } }