@Test public void shouldThrowErrorIfFileNotPresent() throws Exception { expectedException.expect(DataException.class); expectedException.expectMessage("report.template.error.file.missing"); service.validateFileAndInsertTemplate(new Template(), null); }
public void validateFileAndInsertTemplate(Template template, MultipartFile file) throws IOException { throwIfTemplateWithSameNameAlreadyExists(template.getName()); validateFile(template, file); repository.insertWithParameters(template); Right right = new Right(template.getName(), REPORTING); rightService.insertRight(right); ReportRight reportRight = new ReportRight(template, right); reportRightService.insert(reportRight); }
TemplateService { public void validateFileAndInsertTemplate(Template template, MultipartFile file) throws IOException { throwIfTemplateWithSameNameAlreadyExists(template.getName()); validateFile(template, file); repository.insertWithParameters(template); Right right = new Right(template.getName(), REPORTING); rightService.insertRight(right); ReportRight reportRight = new ReportRight(template, right); reportRightService.insert(reportRight); } }
TemplateService { public void validateFileAndInsertTemplate(Template template, MultipartFile file) throws IOException { throwIfTemplateWithSameNameAlreadyExists(template.getName()); validateFile(template, file); repository.insertWithParameters(template); Right right = new Right(template.getName(), REPORTING); rightService.insertRight(right); ReportRight reportRight = new ReportRight(template, right); reportRightService.insert(reportRight); }  }
TemplateService { public void validateFileAndInsertTemplate(Template template, MultipartFile file) throws IOException { throwIfTemplateWithSameNameAlreadyExists(template.getName()); validateFile(template, file); repository.insertWithParameters(template); Right right = new Right(template.getName(), REPORTING); rightService.insertRight(right); ReportRight reportRight = new ReportRight(template, right); reportRightService.insert(reportRight); }  List<Template> getAllTemplatesForUser(Long userId); Template getByName(String name); Template getById(Long id); Template getLWById(Long id); void validateFileAndInsertTemplate(Template template, MultipartFile file); Map<String, Object> getParametersMap(Template template, int userId, HttpServletRequest request, String format); }
TemplateService { public void validateFileAndInsertTemplate(Template template, MultipartFile file) throws IOException { throwIfTemplateWithSameNameAlreadyExists(template.getName()); validateFile(template, file); repository.insertWithParameters(template); Right right = new Right(template.getName(), REPORTING); rightService.insertRight(right); ReportRight reportRight = new ReportRight(template, right); reportRightService.insert(reportRight); }  List<Template> getAllTemplatesForUser(Long userId); Template getByName(String name); Template getById(Long id); Template getLWById(Long id); void validateFileAndInsertTemplate(Template template, MultipartFile file); Map<String, Object> getParametersMap(Template template, int userId, HttpServletRequest request, String format); static final String PDF_VIEW; static final String USER_ID_PARAM; }