如何编写生成文件并将其放置在某个临时位置的JUnit测试用例。
控制器:
@RequestMapping(value="/generateSalesReport", method=RequestMethod.POST, produces="application/pdf")
public void generateSalesReport(
@RequestBody SalesReportVO salesReportVO,
HttpServletRequest request, HttpServletResponse
response) {
SalesService.salesService(salesReportVO, request, response);
}
//Service: SalesService.java
public void salesService(SalesReportVO salesReportVO,
HttpServletRequest request, HttpServletResponse
response){
//access the database and create a PDF and save at temp location
//fileNameReport -- it is the newly created file name which is returned to Angular page as response text and other get method open this file in browser new tab
response.getWriter().write(fileNameReport);
}