@Test public void test_update_with_out_kafka() { List<VoucherSubType> expectedResult = getVoucherSubTypes(); VoucherSubTypeEntity entity = new VoucherSubTypeEntity().toEntity(expectedResult.get(0)); when(voucherSubTypeJdbcRepository.update(any(VoucherSubTypeEntity.class))).thenReturn(entity); voucherSubTypeRepositoryWithOutKafka.update(expectedResult, requestInfo); verify(voucherSubTypeQueueRepository).addToSearchQue(any(Map.class)); }
@Transactional public List<VoucherSubType> update(List<VoucherSubType> voucherSubTypes, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); VoucherSubTypeContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { VoucherSubTypeRequest request = new VoucherSubTypeRequest(); request.setRequestInfo(requestInfo); request.setVoucherSubTypes(new ArrayList<>()); for (VoucherSubType f : voucherSubTypes) { contract = new VoucherSubTypeContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getVoucherSubTypes().add(contract); } addToQue(request); return voucherSubTypes; } else { List<VoucherSubType> resultList = new ArrayList<VoucherSubType>(); for (VoucherSubType f : voucherSubTypes) { resultList.add(update(f)); } VoucherSubTypeRequest request = new VoucherSubTypeRequest(); request.setRequestInfo(requestInfo); request.setVoucherSubTypes(new ArrayList<>()); for (VoucherSubType f : resultList) { contract = new VoucherSubTypeContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getVoucherSubTypes().add(contract); } addToSearchQueue(request); return resultList; } }
VoucherSubTypeRepository { @Transactional public List<VoucherSubType> update(List<VoucherSubType> voucherSubTypes, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); VoucherSubTypeContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { VoucherSubTypeRequest request = new VoucherSubTypeRequest(); request.setRequestInfo(requestInfo); request.setVoucherSubTypes(new ArrayList<>()); for (VoucherSubType f : voucherSubTypes) { contract = new VoucherSubTypeContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getVoucherSubTypes().add(contract); } addToQue(request); return voucherSubTypes; } else { List<VoucherSubType> resultList = new ArrayList<VoucherSubType>(); for (VoucherSubType f : voucherSubTypes) { resultList.add(update(f)); } VoucherSubTypeRequest request = new VoucherSubTypeRequest(); request.setRequestInfo(requestInfo); request.setVoucherSubTypes(new ArrayList<>()); for (VoucherSubType f : resultList) { contract = new VoucherSubTypeContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getVoucherSubTypes().add(contract); } addToSearchQueue(request); return resultList; } } }
VoucherSubTypeRepository { @Transactional public List<VoucherSubType> update(List<VoucherSubType> voucherSubTypes, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); VoucherSubTypeContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { VoucherSubTypeRequest request = new VoucherSubTypeRequest(); request.setRequestInfo(requestInfo); request.setVoucherSubTypes(new ArrayList<>()); for (VoucherSubType f : voucherSubTypes) { contract = new VoucherSubTypeContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getVoucherSubTypes().add(contract); } addToQue(request); return voucherSubTypes; } else { List<VoucherSubType> resultList = new ArrayList<VoucherSubType>(); for (VoucherSubType f : voucherSubTypes) { resultList.add(update(f)); } VoucherSubTypeRequest request = new VoucherSubTypeRequest(); request.setRequestInfo(requestInfo); request.setVoucherSubTypes(new ArrayList<>()); for (VoucherSubType f : resultList) { contract = new VoucherSubTypeContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getVoucherSubTypes().add(contract); } addToSearchQueue(request); return resultList; } } @Autowired  VoucherSubTypeRepository(
            VoucherSubTypeJdbcRepository voucherSubTypeJdbcRepository,
            FinancialConfigurationContractRepository financialConfigurationContractRepository,
            VoucherSubTypeESRepository voucherSubTypeESRepository,
            VoucherSubTypeQueueRepository voucherSubTypeQueueRepository,
            @Value("${persist.through.kafka}") String persistThroughKafka); }
VoucherSubTypeRepository { @Transactional public List<VoucherSubType> update(List<VoucherSubType> voucherSubTypes, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); VoucherSubTypeContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { VoucherSubTypeRequest request = new VoucherSubTypeRequest(); request.setRequestInfo(requestInfo); request.setVoucherSubTypes(new ArrayList<>()); for (VoucherSubType f : voucherSubTypes) { contract = new VoucherSubTypeContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getVoucherSubTypes().add(contract); } addToQue(request); return voucherSubTypes; } else { List<VoucherSubType> resultList = new ArrayList<VoucherSubType>(); for (VoucherSubType f : voucherSubTypes) { resultList.add(update(f)); } VoucherSubTypeRequest request = new VoucherSubTypeRequest(); request.setRequestInfo(requestInfo); request.setVoucherSubTypes(new ArrayList<>()); for (VoucherSubType f : resultList) { contract = new VoucherSubTypeContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getVoucherSubTypes().add(contract); } addToSearchQueue(request); return resultList; } } @Autowired  VoucherSubTypeRepository(
            VoucherSubTypeJdbcRepository voucherSubTypeJdbcRepository,
            FinancialConfigurationContractRepository financialConfigurationContractRepository,
            VoucherSubTypeESRepository voucherSubTypeESRepository,
            VoucherSubTypeQueueRepository voucherSubTypeQueueRepository,
            @Value("${persist.through.kafka}") String persistThroughKafka); @Transactional List<VoucherSubType> save(List<VoucherSubType> voucherSubTypes,
            RequestInfo requestInfo); @Transactional List<VoucherSubType> update(List<VoucherSubType> voucherSubTypes,
            RequestInfo requestInfo); @Transactional VoucherSubType save(VoucherSubType voucherSubType); @Transactional VoucherSubType update(VoucherSubType voucherSubType); void addToQue(VoucherSubTypeRequest request); void addToSearchQueue(VoucherSubTypeRequest request); Pagination<VoucherSubType> search(VoucherSubTypeSearch domain); }
VoucherSubTypeRepository { @Transactional public List<VoucherSubType> update(List<VoucherSubType> voucherSubTypes, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); VoucherSubTypeContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { VoucherSubTypeRequest request = new VoucherSubTypeRequest(); request.setRequestInfo(requestInfo); request.setVoucherSubTypes(new ArrayList<>()); for (VoucherSubType f : voucherSubTypes) { contract = new VoucherSubTypeContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getVoucherSubTypes().add(contract); } addToQue(request); return voucherSubTypes; } else { List<VoucherSubType> resultList = new ArrayList<VoucherSubType>(); for (VoucherSubType f : voucherSubTypes) { resultList.add(update(f)); } VoucherSubTypeRequest request = new VoucherSubTypeRequest(); request.setRequestInfo(requestInfo); request.setVoucherSubTypes(new ArrayList<>()); for (VoucherSubType f : resultList) { contract = new VoucherSubTypeContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getVoucherSubTypes().add(contract); } addToSearchQueue(request); return resultList; } } @Autowired  VoucherSubTypeRepository(
            VoucherSubTypeJdbcRepository voucherSubTypeJdbcRepository,
            FinancialConfigurationContractRepository financialConfigurationContractRepository,
            VoucherSubTypeESRepository voucherSubTypeESRepository,
            VoucherSubTypeQueueRepository voucherSubTypeQueueRepository,
            @Value("${persist.through.kafka}") String persistThroughKafka); @Transactional List<VoucherSubType> save(List<VoucherSubType> voucherSubTypes,
            RequestInfo requestInfo); @Transactional List<VoucherSubType> update(List<VoucherSubType> voucherSubTypes,
            RequestInfo requestInfo); @Transactional VoucherSubType save(VoucherSubType voucherSubType); @Transactional VoucherSubType update(VoucherSubType voucherSubType); void addToQue(VoucherSubTypeRequest request); void addToSearchQueue(VoucherSubTypeRequest request); Pagination<VoucherSubType> search(VoucherSubTypeSearch domain);  }