@Test public void test_search() { final Pagination<Budget> expectedResult = new Pagination<>(); expectedResult.setPageSize(500); expectedResult.setOffset(0); when(budgetJdbcRepository.search(any(BudgetSearch.class))).thenReturn(expectedResult); final Pagination<Budget> actualResult = budgetRepositoryWithKafka.search(getBudgetSearch()); assertEquals(expectedResult, actualResult); }
public Pagination<Budget> search(final BudgetSearch domain) { if (financialConfigurationContractRepository.fetchDataFrom() != null && financialConfigurationContractRepository.fetchDataFrom().equalsIgnoreCase("es")) { BudgetMapper mapper = new BudgetMapper(); BudgetSearchContract budgetSearchContract = new BudgetSearchContract(); budgetSearchContract = mapper.toSearchContract(domain); Pagination<Budget> budgets = budgetESRepository.search(budgetSearchContract); return budgets; } else { return budgetJdbcRepository.search(domain); } }
BudgetRepository { public Pagination<Budget> search(final BudgetSearch domain) { if (financialConfigurationContractRepository.fetchDataFrom() != null && financialConfigurationContractRepository.fetchDataFrom().equalsIgnoreCase("es")) { BudgetMapper mapper = new BudgetMapper(); BudgetSearchContract budgetSearchContract = new BudgetSearchContract(); budgetSearchContract = mapper.toSearchContract(domain); Pagination<Budget> budgets = budgetESRepository.search(budgetSearchContract); return budgets; } else { return budgetJdbcRepository.search(domain); } } }
BudgetRepository { public Pagination<Budget> search(final BudgetSearch domain) { if (financialConfigurationContractRepository.fetchDataFrom() != null && financialConfigurationContractRepository.fetchDataFrom().equalsIgnoreCase("es")) { BudgetMapper mapper = new BudgetMapper(); BudgetSearchContract budgetSearchContract = new BudgetSearchContract(); budgetSearchContract = mapper.toSearchContract(domain); Pagination<Budget> budgets = budgetESRepository.search(budgetSearchContract); return budgets; } else { return budgetJdbcRepository.search(domain); } } @Autowired  BudgetRepository(BudgetJdbcRepository budgetJdbcRepository, BudgetQueueRepository budgetQueueRepository,
                            @Value("${persist.through.kafka}") String persistThroughKafka,FinancialConfigurationContractRepository financialConfigurationContractRepository,
                            BudgetESRepository budgetESRepository); }
BudgetRepository { public Pagination<Budget> search(final BudgetSearch domain) { if (financialConfigurationContractRepository.fetchDataFrom() != null && financialConfigurationContractRepository.fetchDataFrom().equalsIgnoreCase("es")) { BudgetMapper mapper = new BudgetMapper(); BudgetSearchContract budgetSearchContract = new BudgetSearchContract(); budgetSearchContract = mapper.toSearchContract(domain); Pagination<Budget> budgets = budgetESRepository.search(budgetSearchContract); return budgets; } else { return budgetJdbcRepository.search(domain); } } @Autowired  BudgetRepository(BudgetJdbcRepository budgetJdbcRepository, BudgetQueueRepository budgetQueueRepository,
                            @Value("${persist.through.kafka}") String persistThroughKafka,FinancialConfigurationContractRepository financialConfigurationContractRepository,
                            BudgetESRepository budgetESRepository); Budget findById(final Budget budget); @Transactional List<Budget> save(final List<Budget> budgets, final RequestInfo requestInfo); @Transactional List<Budget> update(final List<Budget> budgets, final RequestInfo requestInfo); @Transactional List<Budget> delete(final List<Budget> budgets, final RequestInfo requestInfo); @Transactional Budget save(final Budget budget); @Transactional Budget update(final Budget entity); @Transactional Budget delete(final Budget entity); Pagination<Budget> search(final BudgetSearch domain); boolean uniqueCheck(String fieldName, Budget budget); }
BudgetRepository { public Pagination<Budget> search(final BudgetSearch domain) { if (financialConfigurationContractRepository.fetchDataFrom() != null && financialConfigurationContractRepository.fetchDataFrom().equalsIgnoreCase("es")) { BudgetMapper mapper = new BudgetMapper(); BudgetSearchContract budgetSearchContract = new BudgetSearchContract(); budgetSearchContract = mapper.toSearchContract(domain); Pagination<Budget> budgets = budgetESRepository.search(budgetSearchContract); return budgets; } else { return budgetJdbcRepository.search(domain); } } @Autowired  BudgetRepository(BudgetJdbcRepository budgetJdbcRepository, BudgetQueueRepository budgetQueueRepository,
                            @Value("${persist.through.kafka}") String persistThroughKafka,FinancialConfigurationContractRepository financialConfigurationContractRepository,
                            BudgetESRepository budgetESRepository); Budget findById(final Budget budget); @Transactional List<Budget> save(final List<Budget> budgets, final RequestInfo requestInfo); @Transactional List<Budget> update(final List<Budget> budgets, final RequestInfo requestInfo); @Transactional List<Budget> delete(final List<Budget> budgets, final RequestInfo requestInfo); @Transactional Budget save(final Budget budget); @Transactional Budget update(final Budget entity); @Transactional Budget delete(final Budget entity); Pagination<Budget> search(final BudgetSearch domain); boolean uniqueCheck(String fieldName, Budget budget);  }