SearchOptionServlet extends HttpServlet { @Override public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { Document document = Document.newBuilder() .setId("theOnlyCoffeeRoaster") .addField(Field.newBuilder().setName("price").setNumber(200)) .addField(Field.newBuilder().setName("model").setText("TZ4000")) .addField(Field.newBuilder().setName("brand").setText("MyBrand")) .addField(Field.newBuilder().setName("product").setText("coffee roaster")) .addField( Field.newBuilder().setName("description").setText("A coffee bean roaster at home")) .build(); try { Utils.indexADocument(SEARCH_INDEX, document); } catch (InterruptedException e) { } PrintWriter out = resp.getWriter(); Results<ScoredDocument> result = doSearch(); for (ScoredDocument doc : result.getResults()) { out.println(doc.toString()); } }  @Override void doGet(HttpServletRequest req, HttpServletResponse resp);  }
@Test public void doGet_successfulyInvoked() throws Exception { servletUnderTest.doGet(mockRequest, mockResponse); assertWithMessage("SearchOptionServlet response") .that(responseWriter.toString()) .contains("documentId=theOnlyCoffeeRoaster"); }