@Test public final void testSearch() { List<Function> search = new ArrayList<>(); search.add(getFunctionSearch()); Pagination<Function> expectedResult = new Pagination<>(); expectedResult.setPagedData(search); when(functionRepository.search(any(FunctionSearch.class))).thenReturn(expectedResult); Pagination<Function> actualResult = functionService.search(getFunctionSearch(), errors); assertEquals(expectedResult, actualResult); }
public Pagination<Function> search(FunctionSearch functionSearch, BindingResult errors) { try { List<Function> functions = new ArrayList<>(); functions.add(functionSearch); validate(functions, Constants.ACTION_SEARCH, errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } } catch (CustomBindException e) { throw new CustomBindException(errors); } return functionRepository.search(functionSearch); }
FunctionService { public Pagination<Function> search(FunctionSearch functionSearch, BindingResult errors) { try { List<Function> functions = new ArrayList<>(); functions.add(functionSearch); validate(functions, Constants.ACTION_SEARCH, errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } } catch (CustomBindException e) { throw new CustomBindException(errors); } return functionRepository.search(functionSearch); } }
FunctionService { public Pagination<Function> search(FunctionSearch functionSearch, BindingResult errors) { try { List<Function> functions = new ArrayList<>(); functions.add(functionSearch); validate(functions, Constants.ACTION_SEARCH, errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } } catch (CustomBindException e) { throw new CustomBindException(errors); } return functionRepository.search(functionSearch); }  }
FunctionService { public Pagination<Function> search(FunctionSearch functionSearch, BindingResult errors) { try { List<Function> functions = new ArrayList<>(); functions.add(functionSearch); validate(functions, Constants.ACTION_SEARCH, errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } } catch (CustomBindException e) { throw new CustomBindException(errors); } return functionRepository.search(functionSearch); }  @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 { public Pagination<Function> search(FunctionSearch functionSearch, BindingResult errors) { try { List<Function> functions = new ArrayList<>(); functions.add(functionSearch); validate(functions, Constants.ACTION_SEARCH, errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } } catch (CustomBindException e) { throw new CustomBindException(errors); } return functionRepository.search(functionSearch); }  @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);  }