@Test public final void testCreate() { bankAccounts.add(getBankAccount()); when(bankBranchRepository.findById(any(BankBranch.class))).thenReturn(getBankBranch()); when(chartOfAccountRepository.findById(any(ChartOfAccount.class))).thenReturn(getChartOfAccount()); when(fundRepository.findById(any(Fund.class))).thenReturn(getFund()); when(bankAccountRepository.uniqueCheck(anyString(), any(BankAccount.class))).thenReturn(true); bankAccountService.create(bankAccounts, errors, requestInfo); }
@Transactional public List<BankAccount> create(List<BankAccount> bankAccounts, BindingResult errors, RequestInfo requestInfo) { try { bankAccounts = fetchRelated(bankAccounts); validate(bankAccounts, Constants.ACTION_CREATE, errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } for (BankAccount b : bankAccounts) { b.setId(bankAccountRepository.getNextSequence()); } } catch (CustomBindException e) { throw new CustomBindException(errors); } return bankAccountRepository.save(bankAccounts, requestInfo); }
BankAccountService { @Transactional public List<BankAccount> create(List<BankAccount> bankAccounts, BindingResult errors, RequestInfo requestInfo) { try { bankAccounts = fetchRelated(bankAccounts); validate(bankAccounts, Constants.ACTION_CREATE, errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } for (BankAccount b : bankAccounts) { b.setId(bankAccountRepository.getNextSequence()); } } catch (CustomBindException e) { throw new CustomBindException(errors); } return bankAccountRepository.save(bankAccounts, requestInfo); } }
BankAccountService { @Transactional public List<BankAccount> create(List<BankAccount> bankAccounts, BindingResult errors, RequestInfo requestInfo) { try { bankAccounts = fetchRelated(bankAccounts); validate(bankAccounts, Constants.ACTION_CREATE, errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } for (BankAccount b : bankAccounts) { b.setId(bankAccountRepository.getNextSequence()); } } catch (CustomBindException e) { throw new CustomBindException(errors); } return bankAccountRepository.save(bankAccounts, requestInfo); }  }
BankAccountService { @Transactional public List<BankAccount> create(List<BankAccount> bankAccounts, BindingResult errors, RequestInfo requestInfo) { try { bankAccounts = fetchRelated(bankAccounts); validate(bankAccounts, Constants.ACTION_CREATE, errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } for (BankAccount b : bankAccounts) { b.setId(bankAccountRepository.getNextSequence()); } } catch (CustomBindException e) { throw new CustomBindException(errors); } return bankAccountRepository.save(bankAccounts, requestInfo); }  @Transactional List<BankAccount> create(List<BankAccount> bankAccounts, BindingResult errors, RequestInfo requestInfo); @Transactional List<BankAccount> update(List<BankAccount> bankAccounts, BindingResult errors, RequestInfo requestInfo); List<BankAccount> fetchRelated(List<BankAccount> bankaccounts); @Transactional List<BankAccount> update(List<BankAccount> bankaccounts, BindingResult errors); void addToQue(BankAccountRequest request); Pagination<BankAccount> search(BankAccountSearch bankAccountSearch, BindingResult errors); @Transactional BankAccount save(BankAccount bankAccount); @Transactional BankAccount update(BankAccount bankAccount); }
BankAccountService { @Transactional public List<BankAccount> create(List<BankAccount> bankAccounts, BindingResult errors, RequestInfo requestInfo) { try { bankAccounts = fetchRelated(bankAccounts); validate(bankAccounts, Constants.ACTION_CREATE, errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } for (BankAccount b : bankAccounts) { b.setId(bankAccountRepository.getNextSequence()); } } catch (CustomBindException e) { throw new CustomBindException(errors); } return bankAccountRepository.save(bankAccounts, requestInfo); }  @Transactional List<BankAccount> create(List<BankAccount> bankAccounts, BindingResult errors, RequestInfo requestInfo); @Transactional List<BankAccount> update(List<BankAccount> bankAccounts, BindingResult errors, RequestInfo requestInfo); List<BankAccount> fetchRelated(List<BankAccount> bankaccounts); @Transactional List<BankAccount> update(List<BankAccount> bankaccounts, BindingResult errors); void addToQue(BankAccountRequest request); Pagination<BankAccount> search(BankAccountSearch bankAccountSearch, BindingResult errors); @Transactional BankAccount save(BankAccount bankAccount); @Transactional BankAccount update(BankAccount bankAccount);  }