@Test public void test_delete_with_out_kafka() { final List<BudgetDetail> expectedResult = getBudgetDetails(); final BudgetDetailEntity entity = new BudgetDetailEntity().toEntity(expectedResult.get(0)); when(budgetDetailJdbcRepository.delete(any(BudgetDetailEntity.class))).thenReturn(entity); budgetDetailRepositoryWithOutKafka.delete(expectedResult, requestInfo); verify(budgetDetailQueueRepository).addToSearchQue(captor.capture()); final BudgetDetailRequest actualRequest = captor.getValue(); assertEquals(expectedResult.get(0).getAnticipatoryAmount(), actualRequest.getBudgetDetails().get(0).getAnticipatoryAmount()); assertEquals(expectedResult.get(0).getApprovedAmount(), actualRequest.getBudgetDetails().get(0).getApprovedAmount()); assertEquals(expectedResult.get(0).getBudgetAvailable(), actualRequest.getBudgetDetails().get(0).getBudgetAvailable()); assertEquals(expectedResult.get(0).getOriginalAmount(), actualRequest.getBudgetDetails().get(0).getOriginalAmount()); assertEquals(expectedResult.get(0).getPlanningPercent(), actualRequest.getBudgetDetails().get(0).getPlanningPercent()); }
@Transactional public List<BudgetDetail> delete(final List<BudgetDetail> budgetDetails, final RequestInfo requestInfo) { final BudgetDetailMapper mapper = new BudgetDetailMapper(); if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { final BudgetDetailRequest request = new BudgetDetailRequest(); request.setRequestInfo(requestInfo); request.setBudgetDetails(new ArrayList<>()); for (final BudgetDetail iac : budgetDetails) request.getBudgetDetails().add(mapper.toContract(iac)); budgetDetailQueueRepository.addToQue(request); return budgetDetails; } else { final List<BudgetDetail> resultList = new ArrayList<BudgetDetail>(); for (final BudgetDetail iac : budgetDetails) resultList.add(delete(iac)); final BudgetDetailRequest request = new BudgetDetailRequest(); request.setRequestInfo(requestInfo); request.setBudgetDetails(new ArrayList<>()); for (final BudgetDetail iac : resultList) request.getBudgetDetails().add(mapper.toContract(iac)); budgetDetailQueueRepository.addToSearchQue(request); return resultList; } }
BudgetDetailRepository { @Transactional public List<BudgetDetail> delete(final List<BudgetDetail> budgetDetails, final RequestInfo requestInfo) { final BudgetDetailMapper mapper = new BudgetDetailMapper(); if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { final BudgetDetailRequest request = new BudgetDetailRequest(); request.setRequestInfo(requestInfo); request.setBudgetDetails(new ArrayList<>()); for (final BudgetDetail iac : budgetDetails) request.getBudgetDetails().add(mapper.toContract(iac)); budgetDetailQueueRepository.addToQue(request); return budgetDetails; } else { final List<BudgetDetail> resultList = new ArrayList<BudgetDetail>(); for (final BudgetDetail iac : budgetDetails) resultList.add(delete(iac)); final BudgetDetailRequest request = new BudgetDetailRequest(); request.setRequestInfo(requestInfo); request.setBudgetDetails(new ArrayList<>()); for (final BudgetDetail iac : resultList) request.getBudgetDetails().add(mapper.toContract(iac)); budgetDetailQueueRepository.addToSearchQue(request); return resultList; } } }
BudgetDetailRepository { @Transactional public List<BudgetDetail> delete(final List<BudgetDetail> budgetDetails, final RequestInfo requestInfo) { final BudgetDetailMapper mapper = new BudgetDetailMapper(); if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { final BudgetDetailRequest request = new BudgetDetailRequest(); request.setRequestInfo(requestInfo); request.setBudgetDetails(new ArrayList<>()); for (final BudgetDetail iac : budgetDetails) request.getBudgetDetails().add(mapper.toContract(iac)); budgetDetailQueueRepository.addToQue(request); return budgetDetails; } else { final List<BudgetDetail> resultList = new ArrayList<BudgetDetail>(); for (final BudgetDetail iac : budgetDetails) resultList.add(delete(iac)); final BudgetDetailRequest request = new BudgetDetailRequest(); request.setRequestInfo(requestInfo); request.setBudgetDetails(new ArrayList<>()); for (final BudgetDetail iac : resultList) request.getBudgetDetails().add(mapper.toContract(iac)); budgetDetailQueueRepository.addToSearchQue(request); return resultList; } } @Autowired  BudgetDetailRepository(final BudgetDetailJdbcRepository budgetDetailJdbcRepository,
                                  final BudgetDetailQueueRepository budgetDetailQueueRepository,
                                  @Value("${persist.through.kafka}") final String persistThroughKafka,
                                  FinancialConfigurationContractRepository financialConfigurationContractRepository,
                                  BudgetDetailESRepository budgetDetailESRepository
    ); }
BudgetDetailRepository { @Transactional public List<BudgetDetail> delete(final List<BudgetDetail> budgetDetails, final RequestInfo requestInfo) { final BudgetDetailMapper mapper = new BudgetDetailMapper(); if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { final BudgetDetailRequest request = new BudgetDetailRequest(); request.setRequestInfo(requestInfo); request.setBudgetDetails(new ArrayList<>()); for (final BudgetDetail iac : budgetDetails) request.getBudgetDetails().add(mapper.toContract(iac)); budgetDetailQueueRepository.addToQue(request); return budgetDetails; } else { final List<BudgetDetail> resultList = new ArrayList<BudgetDetail>(); for (final BudgetDetail iac : budgetDetails) resultList.add(delete(iac)); final BudgetDetailRequest request = new BudgetDetailRequest(); request.setRequestInfo(requestInfo); request.setBudgetDetails(new ArrayList<>()); for (final BudgetDetail iac : resultList) request.getBudgetDetails().add(mapper.toContract(iac)); budgetDetailQueueRepository.addToSearchQue(request); return resultList; } } @Autowired  BudgetDetailRepository(final BudgetDetailJdbcRepository budgetDetailJdbcRepository,
                                  final BudgetDetailQueueRepository budgetDetailQueueRepository,
                                  @Value("${persist.through.kafka}") final String persistThroughKafka,
                                  FinancialConfigurationContractRepository financialConfigurationContractRepository,
                                  BudgetDetailESRepository budgetDetailESRepository
    ); BudgetDetail findById(final BudgetDetail budgetDetail); @Transactional List<BudgetDetail> save(final List<BudgetDetail> budgetDetails, final RequestInfo requestInfo); @Transactional List<BudgetDetail> update(final List<BudgetDetail> budgetDetails, final RequestInfo requestInfo); @Transactional List<BudgetDetail> delete(final List<BudgetDetail> budgetDetails, final RequestInfo requestInfo); @Transactional BudgetDetail save(final BudgetDetail budgetDetail); @Transactional BudgetDetail update(final BudgetDetail entity); @Transactional BudgetDetail delete(final BudgetDetail entity); Pagination<BudgetDetail> search(final BudgetDetailSearch domain); boolean uniqueCheck(String fieldName, BudgetDetail budgetDetail); }
BudgetDetailRepository { @Transactional public List<BudgetDetail> delete(final List<BudgetDetail> budgetDetails, final RequestInfo requestInfo) { final BudgetDetailMapper mapper = new BudgetDetailMapper(); if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { final BudgetDetailRequest request = new BudgetDetailRequest(); request.setRequestInfo(requestInfo); request.setBudgetDetails(new ArrayList<>()); for (final BudgetDetail iac : budgetDetails) request.getBudgetDetails().add(mapper.toContract(iac)); budgetDetailQueueRepository.addToQue(request); return budgetDetails; } else { final List<BudgetDetail> resultList = new ArrayList<BudgetDetail>(); for (final BudgetDetail iac : budgetDetails) resultList.add(delete(iac)); final BudgetDetailRequest request = new BudgetDetailRequest(); request.setRequestInfo(requestInfo); request.setBudgetDetails(new ArrayList<>()); for (final BudgetDetail iac : resultList) request.getBudgetDetails().add(mapper.toContract(iac)); budgetDetailQueueRepository.addToSearchQue(request); return resultList; } } @Autowired  BudgetDetailRepository(final BudgetDetailJdbcRepository budgetDetailJdbcRepository,
                                  final BudgetDetailQueueRepository budgetDetailQueueRepository,
                                  @Value("${persist.through.kafka}") final String persistThroughKafka,
                                  FinancialConfigurationContractRepository financialConfigurationContractRepository,
                                  BudgetDetailESRepository budgetDetailESRepository
    ); BudgetDetail findById(final BudgetDetail budgetDetail); @Transactional List<BudgetDetail> save(final List<BudgetDetail> budgetDetails, final RequestInfo requestInfo); @Transactional List<BudgetDetail> update(final List<BudgetDetail> budgetDetails, final RequestInfo requestInfo); @Transactional List<BudgetDetail> delete(final List<BudgetDetail> budgetDetails, final RequestInfo requestInfo); @Transactional BudgetDetail save(final BudgetDetail budgetDetail); @Transactional BudgetDetail update(final BudgetDetail entity); @Transactional BudgetDetail delete(final BudgetDetail entity); Pagination<BudgetDetail> search(final BudgetDetailSearch domain); boolean uniqueCheck(String fieldName, BudgetDetail budgetDetail);  }