@Test public void test_update_with_kafka() { final List<Budget> expectedResult = getBudgets(); budgetRepositoryWithKafka.update(expectedResult, requestInfo); verify(budgetQueueRepository).addToQue(captor.capture()); final BudgetRequest actualRequest = captor.getValue(); assertEquals(expectedResult.get(0).getName(), actualRequest.getBudgets().get(0).getName()); assertEquals(expectedResult.get(0).getFinancialYear().getId(), actualRequest.getBudgets().get(0).getFinancialYear().getId()); assertEquals(expectedResult.get(0).getPrimaryBudget(), actualRequest.getBudgets().get(0).getPrimaryBudget()); assertEquals(expectedResult.get(0).getEstimationType().name(), actualRequest.getBudgets().get(0).getEstimationType().name()); assertEquals(expectedResult.get(0).getTenantId(), actualRequest.getBudgets().get(0).getTenantId()); }
@Transactional public List<Budget> update(final List<Budget> budgets, final RequestInfo requestInfo) { final BudgetMapper mapper = new BudgetMapper(); if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { final BudgetRequest request = new BudgetRequest(); request.setRequestInfo(requestInfo); request.setBudgets(new ArrayList<>()); for (final Budget iac : budgets) request.getBudgets().add(mapper.toContract(iac)); budgetQueueRepository.addToQue(request); return budgets; } else { final List<Budget> resultList = new ArrayList<Budget>(); for (final Budget iac : budgets) resultList.add(update(iac)); final BudgetRequest request = new BudgetRequest(); request.setRequestInfo(requestInfo); request.setBudgets(new ArrayList<>()); for (final Budget iac : resultList) request.getBudgets().add(mapper.toContract(iac)); budgetQueueRepository.addToSearchQue(request); return resultList; } }
BudgetRepository { @Transactional public List<Budget> update(final List<Budget> budgets, final RequestInfo requestInfo) { final BudgetMapper mapper = new BudgetMapper(); if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { final BudgetRequest request = new BudgetRequest(); request.setRequestInfo(requestInfo); request.setBudgets(new ArrayList<>()); for (final Budget iac : budgets) request.getBudgets().add(mapper.toContract(iac)); budgetQueueRepository.addToQue(request); return budgets; } else { final List<Budget> resultList = new ArrayList<Budget>(); for (final Budget iac : budgets) resultList.add(update(iac)); final BudgetRequest request = new BudgetRequest(); request.setRequestInfo(requestInfo); request.setBudgets(new ArrayList<>()); for (final Budget iac : resultList) request.getBudgets().add(mapper.toContract(iac)); budgetQueueRepository.addToSearchQue(request); return resultList; } } }
BudgetRepository { @Transactional public List<Budget> update(final List<Budget> budgets, final RequestInfo requestInfo) { final BudgetMapper mapper = new BudgetMapper(); if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { final BudgetRequest request = new BudgetRequest(); request.setRequestInfo(requestInfo); request.setBudgets(new ArrayList<>()); for (final Budget iac : budgets) request.getBudgets().add(mapper.toContract(iac)); budgetQueueRepository.addToQue(request); return budgets; } else { final List<Budget> resultList = new ArrayList<Budget>(); for (final Budget iac : budgets) resultList.add(update(iac)); final BudgetRequest request = new BudgetRequest(); request.setRequestInfo(requestInfo); request.setBudgets(new ArrayList<>()); for (final Budget iac : resultList) request.getBudgets().add(mapper.toContract(iac)); budgetQueueRepository.addToSearchQue(request); return resultList; } } @Autowired  BudgetRepository(BudgetJdbcRepository budgetJdbcRepository, BudgetQueueRepository budgetQueueRepository,
                            @Value("${persist.through.kafka}") String persistThroughKafka,FinancialConfigurationContractRepository financialConfigurationContractRepository,
                            BudgetESRepository budgetESRepository); }
BudgetRepository { @Transactional public List<Budget> update(final List<Budget> budgets, final RequestInfo requestInfo) { final BudgetMapper mapper = new BudgetMapper(); if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { final BudgetRequest request = new BudgetRequest(); request.setRequestInfo(requestInfo); request.setBudgets(new ArrayList<>()); for (final Budget iac : budgets) request.getBudgets().add(mapper.toContract(iac)); budgetQueueRepository.addToQue(request); return budgets; } else { final List<Budget> resultList = new ArrayList<Budget>(); for (final Budget iac : budgets) resultList.add(update(iac)); final BudgetRequest request = new BudgetRequest(); request.setRequestInfo(requestInfo); request.setBudgets(new ArrayList<>()); for (final Budget iac : resultList) request.getBudgets().add(mapper.toContract(iac)); budgetQueueRepository.addToSearchQue(request); return resultList; } } @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 { @Transactional public List<Budget> update(final List<Budget> budgets, final RequestInfo requestInfo) { final BudgetMapper mapper = new BudgetMapper(); if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { final BudgetRequest request = new BudgetRequest(); request.setRequestInfo(requestInfo); request.setBudgets(new ArrayList<>()); for (final Budget iac : budgets) request.getBudgets().add(mapper.toContract(iac)); budgetQueueRepository.addToQue(request); return budgets; } else { final List<Budget> resultList = new ArrayList<Budget>(); for (final Budget iac : budgets) resultList.add(update(iac)); final BudgetRequest request = new BudgetRequest(); request.setRequestInfo(requestInfo); request.setBudgets(new ArrayList<>()); for (final Budget iac : resultList) request.getBudgets().add(mapper.toContract(iac)); budgetQueueRepository.addToSearchQue(request); return resultList; } } @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);  }