@Test public final void testCreateInvalid() { Function function1 = Function.builder().id("a").code("code").active(true).parentId(null).level(1).build(); functions.add(function1); when(functionRepository.uniqueCheck(any(String.class), any(Function.class))).thenReturn(true); functionService.create(functions, errors, requestInfo); }
@Transactional public List<Function> create(List<Function> functions, BindingResult errors, RequestInfo requestInfo) { try { functions = fetchRelated(functions); validate(functions, Constants.ACTION_CREATE, errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } for (Function b : functions) { b.setId(functionRepository.getNextSequence()); b.add(); } } catch (CustomBindException e) { throw new CustomBindException(errors); } return functionRepository.save(functions, requestInfo); }
FunctionService { @Transactional public List<Function> create(List<Function> functions, BindingResult errors, RequestInfo requestInfo) { try { functions = fetchRelated(functions); validate(functions, Constants.ACTION_CREATE, errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } for (Function b : functions) { b.setId(functionRepository.getNextSequence()); b.add(); } } catch (CustomBindException e) { throw new CustomBindException(errors); } return functionRepository.save(functions, requestInfo); } }
FunctionService { @Transactional public List<Function> create(List<Function> functions, BindingResult errors, RequestInfo requestInfo) { try { functions = fetchRelated(functions); validate(functions, Constants.ACTION_CREATE, errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } for (Function b : functions) { b.setId(functionRepository.getNextSequence()); b.add(); } } catch (CustomBindException e) { throw new CustomBindException(errors); } return functionRepository.save(functions, requestInfo); }  }
FunctionService { @Transactional public List<Function> create(List<Function> functions, BindingResult errors, RequestInfo requestInfo) { try { functions = fetchRelated(functions); validate(functions, Constants.ACTION_CREATE, errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } for (Function b : functions) { b.setId(functionRepository.getNextSequence()); b.add(); } } catch (CustomBindException e) { throw new CustomBindException(errors); } return functionRepository.save(functions, requestInfo); }  @Transactional List<Function> create(List<Function> functions, BindingResult errors, RequestInfo requestInfo); @Transactional List<Function> update(List<Function> functions, BindingResult errors, RequestInfo requestInfo); List<Function> fetchRelated(List<Function> functions); Pagination<Function> search(FunctionSearch functionSearch, BindingResult errors); @Transactional Function save(Function function); @Transactional Function update(Function function); }
FunctionService { @Transactional public List<Function> create(List<Function> functions, BindingResult errors, RequestInfo requestInfo) { try { functions = fetchRelated(functions); validate(functions, Constants.ACTION_CREATE, errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } for (Function b : functions) { b.setId(functionRepository.getNextSequence()); b.add(); } } catch (CustomBindException e) { throw new CustomBindException(errors); } return functionRepository.save(functions, requestInfo); }  @Transactional List<Function> create(List<Function> functions, BindingResult errors, RequestInfo requestInfo); @Transactional List<Function> update(List<Function> functions, BindingResult errors, RequestInfo requestInfo); List<Function> fetchRelated(List<Function> functions); Pagination<Function> search(FunctionSearch functionSearch, BindingResult errors); @Transactional Function save(Function function); @Transactional Function update(Function function);  }