@Test public void testSearch() { Pagination<ChartOfAccount> expectedResult = new Pagination<>(); expectedResult.setPageSize(500); expectedResult.setOffset(0); when(financialConfigurationService.fetchDataFrom()).thenReturn("db"); when(chartofAccountJdbcRepository.search(any(ChartOfAccountSearch.class))).thenReturn(expectedResult); Pagination<ChartOfAccount> actualResult = chartOfAccountRepository.search(getChartOfAccountSearch()); assertEquals(expectedResult, actualResult); }
public Pagination<ChartOfAccount> search(ChartOfAccountSearch domain) { Set<ChartOfAccount> chartOfAccountSet = new HashSet<ChartOfAccount>(); Pagination<ChartOfAccount> finalResult = new Pagination<>(); Pagination<ChartOfAccount> result = new Pagination<>(); if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { ChartOfAccountSearchContract chartOfAccountSearchContract = new ChartOfAccountSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, chartOfAccountSearchContract); result = chartOfAccountESRepository.search(chartOfAccountSearchContract); } else { result = chartOfAccountJdbcRepository.search(domain); } if (domain != null && domain.getAccountCodePurpose() != null && domain.getAccountCodePurpose().getId() != null) { domain.setAccountCodePurpose(null); for (ChartOfAccount coa : result.getPagedData()) { chartOfAccountSet.add(coa); domain.setGlcode(coa.getGlcode() + "%"); Pagination<ChartOfAccount> result1 = chartOfAccountJdbcRepository.search(domain); for (ChartOfAccount temp : result1.getPagedData()) { chartOfAccountSet.add(temp); } finalResult = result1; } finalResult.setTotalResults(chartOfAccountSet.size()); finalResult.setPagedData(new ArrayList<>(chartOfAccountSet)); return finalResult; } else return result; }
ChartOfAccountRepository { public Pagination<ChartOfAccount> search(ChartOfAccountSearch domain) { Set<ChartOfAccount> chartOfAccountSet = new HashSet<ChartOfAccount>(); Pagination<ChartOfAccount> finalResult = new Pagination<>(); Pagination<ChartOfAccount> result = new Pagination<>(); if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { ChartOfAccountSearchContract chartOfAccountSearchContract = new ChartOfAccountSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, chartOfAccountSearchContract); result = chartOfAccountESRepository.search(chartOfAccountSearchContract); } else { result = chartOfAccountJdbcRepository.search(domain); } if (domain != null && domain.getAccountCodePurpose() != null && domain.getAccountCodePurpose().getId() != null) { domain.setAccountCodePurpose(null); for (ChartOfAccount coa : result.getPagedData()) { chartOfAccountSet.add(coa); domain.setGlcode(coa.getGlcode() + "%"); Pagination<ChartOfAccount> result1 = chartOfAccountJdbcRepository.search(domain); for (ChartOfAccount temp : result1.getPagedData()) { chartOfAccountSet.add(temp); } finalResult = result1; } finalResult.setTotalResults(chartOfAccountSet.size()); finalResult.setPagedData(new ArrayList<>(chartOfAccountSet)); return finalResult; } else return result; } }
ChartOfAccountRepository { public Pagination<ChartOfAccount> search(ChartOfAccountSearch domain) { Set<ChartOfAccount> chartOfAccountSet = new HashSet<ChartOfAccount>(); Pagination<ChartOfAccount> finalResult = new Pagination<>(); Pagination<ChartOfAccount> result = new Pagination<>(); if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { ChartOfAccountSearchContract chartOfAccountSearchContract = new ChartOfAccountSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, chartOfAccountSearchContract); result = chartOfAccountESRepository.search(chartOfAccountSearchContract); } else { result = chartOfAccountJdbcRepository.search(domain); } if (domain != null && domain.getAccountCodePurpose() != null && domain.getAccountCodePurpose().getId() != null) { domain.setAccountCodePurpose(null); for (ChartOfAccount coa : result.getPagedData()) { chartOfAccountSet.add(coa); domain.setGlcode(coa.getGlcode() + "%"); Pagination<ChartOfAccount> result1 = chartOfAccountJdbcRepository.search(domain); for (ChartOfAccount temp : result1.getPagedData()) { chartOfAccountSet.add(temp); } finalResult = result1; } finalResult.setTotalResults(chartOfAccountSet.size()); finalResult.setPagedData(new ArrayList<>(chartOfAccountSet)); return finalResult; } else return result; }  }
ChartOfAccountRepository { public Pagination<ChartOfAccount> search(ChartOfAccountSearch domain) { Set<ChartOfAccount> chartOfAccountSet = new HashSet<ChartOfAccount>(); Pagination<ChartOfAccount> finalResult = new Pagination<>(); Pagination<ChartOfAccount> result = new Pagination<>(); if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { ChartOfAccountSearchContract chartOfAccountSearchContract = new ChartOfAccountSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, chartOfAccountSearchContract); result = chartOfAccountESRepository.search(chartOfAccountSearchContract); } else { result = chartOfAccountJdbcRepository.search(domain); } if (domain != null && domain.getAccountCodePurpose() != null && domain.getAccountCodePurpose().getId() != null) { domain.setAccountCodePurpose(null); for (ChartOfAccount coa : result.getPagedData()) { chartOfAccountSet.add(coa); domain.setGlcode(coa.getGlcode() + "%"); Pagination<ChartOfAccount> result1 = chartOfAccountJdbcRepository.search(domain); for (ChartOfAccount temp : result1.getPagedData()) { chartOfAccountSet.add(temp); } finalResult = result1; } finalResult.setTotalResults(chartOfAccountSet.size()); finalResult.setPagedData(new ArrayList<>(chartOfAccountSet)); return finalResult; } else return result; }  ChartOfAccount findById(ChartOfAccount chartOfAccount); String getNextSequence(); @Transactional ChartOfAccount save(ChartOfAccount chartOfAccount); @Transactional ChartOfAccount update(ChartOfAccount chartOfAccount); void add(ChartOfAccountRequest request); Pagination<ChartOfAccount> search(ChartOfAccountSearch domain); boolean uniqueCheck(String fieldName, ChartOfAccount chartOfAccount); }
ChartOfAccountRepository { public Pagination<ChartOfAccount> search(ChartOfAccountSearch domain) { Set<ChartOfAccount> chartOfAccountSet = new HashSet<ChartOfAccount>(); Pagination<ChartOfAccount> finalResult = new Pagination<>(); Pagination<ChartOfAccount> result = new Pagination<>(); if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { ChartOfAccountSearchContract chartOfAccountSearchContract = new ChartOfAccountSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, chartOfAccountSearchContract); result = chartOfAccountESRepository.search(chartOfAccountSearchContract); } else { result = chartOfAccountJdbcRepository.search(domain); } if (domain != null && domain.getAccountCodePurpose() != null && domain.getAccountCodePurpose().getId() != null) { domain.setAccountCodePurpose(null); for (ChartOfAccount coa : result.getPagedData()) { chartOfAccountSet.add(coa); domain.setGlcode(coa.getGlcode() + "%"); Pagination<ChartOfAccount> result1 = chartOfAccountJdbcRepository.search(domain); for (ChartOfAccount temp : result1.getPagedData()) { chartOfAccountSet.add(temp); } finalResult = result1; } finalResult.setTotalResults(chartOfAccountSet.size()); finalResult.setPagedData(new ArrayList<>(chartOfAccountSet)); return finalResult; } else return result; }  ChartOfAccount findById(ChartOfAccount chartOfAccount); String getNextSequence(); @Transactional ChartOfAccount save(ChartOfAccount chartOfAccount); @Transactional ChartOfAccount update(ChartOfAccount chartOfAccount); void add(ChartOfAccountRequest request); Pagination<ChartOfAccount> search(ChartOfAccountSearch domain); boolean uniqueCheck(String fieldName, ChartOfAccount chartOfAccount);  }