DocumentServlet extends HttpServlet { @Override public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { PrintWriter out = resp.getWriter(); Document document = Document.newBuilder() .addField(Field.newBuilder().setName("coverLetter").setText("CoverLetter")) .addField(Field.newBuilder().setName("resume").setHTML("<html></html>")) .addField(Field.newBuilder().setName("fullName").setAtom("Foo Bar")) .addField(Field.newBuilder().setName("submissionDate").setDate(new Date())) .build(); String coverLetter = document.getOnlyField("coverLetter").getText(); String resume = document.getOnlyField("resume").getHTML(); String fullName = document.getOnlyField("fullName").getAtom(); Date submissionDate = document.getOnlyField("submissionDate").getDate(); out.println("coverLetter: " + coverLetter); out.println("resume: " + resume); out.println("fullName: " + fullName); out.println("submissionDate: " + submissionDate.toString()); }  Document createDocument(); @Override void doGet(HttpServletRequest req, HttpServletResponse resp);  }
@Test public void doGet_successfulyInvoked() throws Exception { servletUnderTest.doGet(mockRequest, mockResponse); String content = responseWriter.toString(); assertWithMessage("DocumentServlet response: coverLetter") .that(content) .contains("coverLetter: CoverLetter"); assertWithMessage("DocumentServlet response: resume") .that(content) .contains("resume: <html></html>"); assertWithMessage("DocumentServlet response: fullName") .that(content) .contains("fullName: Foo Bar"); assertWithMessage("DocumentServlet response: submissionDate") .that(content) .contains("submissionDate: "); }