@Test public final void testSearch(){ List<ChartOfAccount> search = new ArrayList<>(); search.add(getChartOfAccountSearch()); Pagination<ChartOfAccount> expectedResult = new Pagination<>(); expectedResult.setPagedData(search); when(chartOfAccountRepository.search(any(ChartOfAccountSearch.class))).thenReturn(expectedResult); Pagination<ChartOfAccount> actualResult = chartOfAccountService.search(getChartOfAccountSearch(), errors); assertEquals(expectedResult, actualResult); }
public Pagination<ChartOfAccount> search(ChartOfAccountSearch chartOfAccountSearch, BindingResult errors) { try { List<ChartOfAccount> chartOfAccounts = new ArrayList<>(); chartOfAccounts.add(chartOfAccountSearch); validate(chartOfAccounts, Constants.ACTION_SEARCH, errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } } catch (CustomBindException e) { throw new CustomBindException(errors); } return chartOfAccountRepository.search(chartOfAccountSearch); }
ChartOfAccountService { public Pagination<ChartOfAccount> search(ChartOfAccountSearch chartOfAccountSearch, BindingResult errors) { try { List<ChartOfAccount> chartOfAccounts = new ArrayList<>(); chartOfAccounts.add(chartOfAccountSearch); validate(chartOfAccounts, Constants.ACTION_SEARCH, errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } } catch (CustomBindException e) { throw new CustomBindException(errors); } return chartOfAccountRepository.search(chartOfAccountSearch); } }
ChartOfAccountService { public Pagination<ChartOfAccount> search(ChartOfAccountSearch chartOfAccountSearch, BindingResult errors) { try { List<ChartOfAccount> chartOfAccounts = new ArrayList<>(); chartOfAccounts.add(chartOfAccountSearch); validate(chartOfAccounts, Constants.ACTION_SEARCH, errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } } catch (CustomBindException e) { throw new CustomBindException(errors); } return chartOfAccountRepository.search(chartOfAccountSearch); }  }
ChartOfAccountService { public Pagination<ChartOfAccount> search(ChartOfAccountSearch chartOfAccountSearch, BindingResult errors) { try { List<ChartOfAccount> chartOfAccounts = new ArrayList<>(); chartOfAccounts.add(chartOfAccountSearch); validate(chartOfAccounts, Constants.ACTION_SEARCH, errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } } catch (CustomBindException e) { throw new CustomBindException(errors); } return chartOfAccountRepository.search(chartOfAccountSearch); }  List<ChartOfAccount> fetchRelated(List<ChartOfAccount> chartofaccounts); @Transactional List<ChartOfAccount> add(List<ChartOfAccount> chartofaccounts, BindingResult errors); @Transactional List<ChartOfAccount> update(List<ChartOfAccount> chartofaccounts, BindingResult errors); void addToQue(ChartOfAccountRequest request); Pagination<ChartOfAccount> search(ChartOfAccountSearch chartOfAccountSearch, BindingResult errors); @Transactional ChartOfAccount save(ChartOfAccount chartOfAccount); @Transactional ChartOfAccount update(ChartOfAccount chartOfAccount); }
ChartOfAccountService { public Pagination<ChartOfAccount> search(ChartOfAccountSearch chartOfAccountSearch, BindingResult errors) { try { List<ChartOfAccount> chartOfAccounts = new ArrayList<>(); chartOfAccounts.add(chartOfAccountSearch); validate(chartOfAccounts, Constants.ACTION_SEARCH, errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } } catch (CustomBindException e) { throw new CustomBindException(errors); } return chartOfAccountRepository.search(chartOfAccountSearch); }  List<ChartOfAccount> fetchRelated(List<ChartOfAccount> chartofaccounts); @Transactional List<ChartOfAccount> add(List<ChartOfAccount> chartofaccounts, BindingResult errors); @Transactional List<ChartOfAccount> update(List<ChartOfAccount> chartofaccounts, BindingResult errors); void addToQue(ChartOfAccountRequest request); Pagination<ChartOfAccount> search(ChartOfAccountSearch chartOfAccountSearch, BindingResult errors); @Transactional ChartOfAccount save(ChartOfAccount chartOfAccount); @Transactional ChartOfAccount update(ChartOfAccount chartOfAccount);  }