### Question:
WorkflowDownloader extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { List<Workflow> workflows = new ArrayList<Workflow>(); String myExpData; String[] wfId = request.getParameterValues("id"); InputStream in = new URL( "http: try { myExpData = IOUtils.toString(in); } finally { IOUtils.closeQuietly(in); } PrintWriter out = response.getWriter(); String dl = ""; try { DocumentBuilder b = DocumentBuilderFactory.newInstance().newDocumentBuilder(); ByteArrayInputStream input = new ByteArrayInputStream(myExpData.getBytes()); Document doc = b.parse(input); XPath xPath = XPathFactory.newInstance().newXPath(); dl = xPath.compile(" } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } catch (XPathExpressionException e) { e.printStackTrace(); } in = new URL(dl).openStream(); myExpData = IOUtils.toString(in); HttpSession session = request.getSession(true); Workflow currentWorkflow = WorkflowParser.parseWorkflow(myExpData); workflows.add(currentWorkflow); session.setAttribute("workflows", workflows); request.setAttribute("round1", "round1"); RequestDispatcher rd = getServletContext().getRequestDispatcher("/"); rd.forward(request, response); } WorkflowDownloader();   }### Answer:
@Test public void testDoGet() throws Exception { HttpServletRequest request = mock(HttpServletRequest.class); HttpServletResponse response = mock(HttpServletResponse.class); HttpSession sesion = mock(HttpSession.class); ServletConfig config = mock(ServletConfig.class); ServletContext context = mock(ServletContext.class); RequestDispatcher dispatcher = mock(RequestDispatcher.class); ServletOutputStream stream = mock(ServletOutputStream.class); when(request.getSession(true)).thenReturn(sesion); when(request.getParameterValues("id")).thenReturn(new String[]{"914"}); when(response.getWriter()).thenReturn(null); when(config.getServletContext()).thenReturn(context); when(context.getRequestDispatcher("/")).thenReturn(dispatcher); WorkflowDownloader downloader = new WorkflowDownloader(); try { downloader.init(config); downloader.doGet(request, response); } catch (ServletException ex) { fail("Should not raise exception " + ex.toString()); } catch (IOException ex) { fail("Should not raise exception " + ex.toString()); } catch (Exception ex) { } }