@Test public void shouldSetResponseInHeader() throws Exception { csvView.renderMergedOutputModel(model, request, response); String expectedFileName = FILE_PREFIX + orderId + ".csv"; verify(response).setHeader("Content-Disposition", "attachment; filename=" + expectedFileName); }
@Override protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) { Order order = (Order) model.get(ORDER); OrderFileTemplateDTO orderFileTemplateDTO = (OrderFileTemplateDTO) model.get(ORDER_FILE_TEMPLATE); String fileName = orderFileTemplateDTO.getOrderConfiguration().getFilePrefix() + order.getId() + ".csv"; response.setHeader("Content-Disposition", "attachment; filename=" + fileName); try (BufferedWriter writer = new BufferedWriter(response.getWriter())) { csvHelper.writeCsvFile(order, orderFileTemplateDTO, writer); writer.flush(); } catch (IOException e) { throw new DataException(e.getMessage()); } }
OrderCsvView extends AbstractView { @Override protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) { Order order = (Order) model.get(ORDER); OrderFileTemplateDTO orderFileTemplateDTO = (OrderFileTemplateDTO) model.get(ORDER_FILE_TEMPLATE); String fileName = orderFileTemplateDTO.getOrderConfiguration().getFilePrefix() + order.getId() + ".csv"; response.setHeader("Content-Disposition", "attachment; filename=" + fileName); try (BufferedWriter writer = new BufferedWriter(response.getWriter())) { csvHelper.writeCsvFile(order, orderFileTemplateDTO, writer); writer.flush(); } catch (IOException e) { throw new DataException(e.getMessage()); } } }
OrderCsvView extends AbstractView { @Override protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) { Order order = (Order) model.get(ORDER); OrderFileTemplateDTO orderFileTemplateDTO = (OrderFileTemplateDTO) model.get(ORDER_FILE_TEMPLATE); String fileName = orderFileTemplateDTO.getOrderConfiguration().getFilePrefix() + order.getId() + ".csv"; response.setHeader("Content-Disposition", "attachment; filename=" + fileName); try (BufferedWriter writer = new BufferedWriter(response.getWriter())) { csvHelper.writeCsvFile(order, orderFileTemplateDTO, writer); writer.flush(); } catch (IOException e) { throw new DataException(e.getMessage()); } }  }
OrderCsvView extends AbstractView { @Override protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) { Order order = (Order) model.get(ORDER); OrderFileTemplateDTO orderFileTemplateDTO = (OrderFileTemplateDTO) model.get(ORDER_FILE_TEMPLATE); String fileName = orderFileTemplateDTO.getOrderConfiguration().getFilePrefix() + order.getId() + ".csv"; response.setHeader("Content-Disposition", "attachment; filename=" + fileName); try (BufferedWriter writer = new BufferedWriter(response.getWriter())) { csvHelper.writeCsvFile(order, orderFileTemplateDTO, writer); writer.flush(); } catch (IOException e) { throw new DataException(e.getMessage()); } }   }
OrderCsvView extends AbstractView { @Override protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) { Order order = (Order) model.get(ORDER); OrderFileTemplateDTO orderFileTemplateDTO = (OrderFileTemplateDTO) model.get(ORDER_FILE_TEMPLATE); String fileName = orderFileTemplateDTO.getOrderConfiguration().getFilePrefix() + order.getId() + ".csv"; response.setHeader("Content-Disposition", "attachment; filename=" + fileName); try (BufferedWriter writer = new BufferedWriter(response.getWriter())) { csvHelper.writeCsvFile(order, orderFileTemplateDTO, writer); writer.flush(); } catch (IOException e) { throw new DataException(e.getMessage()); } }    }