@Test public void test_save() { List<Recovery> expectedResult = getRecoverys(); requestInfo.setAction(Constants.ACTION_CREATE); recoveryRepositoryWithKafka.save(expectedResult, requestInfo); verify(recoveryQueueRepository).add(captor.capture()); }
@Transactional public List<Recovery> save(List<Recovery> recoveries, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); RecoveryContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { RecoveryRequest request = new RecoveryRequest(); request.setRequestInfo(requestInfo); request.setRecoverys(new ArrayList<>()); for (Recovery f : recoveries) { contract = new RecoveryContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getRecoverys().add(contract); } addToQue(request); return recoveries; } else { List<Recovery> resultList = new ArrayList<Recovery>(); for (Recovery f : recoveries) { resultList.add(save(f)); } RecoveryRequest request = new RecoveryRequest(); request.setRequestInfo(requestInfo); request.setRecoverys(new ArrayList<>()); for (Recovery f : resultList) { contract = new RecoveryContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getRecoverys().add(contract); } addToSearchQueue(request); return resultList; } }
RecoveryRepository { @Transactional public List<Recovery> save(List<Recovery> recoveries, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); RecoveryContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { RecoveryRequest request = new RecoveryRequest(); request.setRequestInfo(requestInfo); request.setRecoverys(new ArrayList<>()); for (Recovery f : recoveries) { contract = new RecoveryContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getRecoverys().add(contract); } addToQue(request); return recoveries; } else { List<Recovery> resultList = new ArrayList<Recovery>(); for (Recovery f : recoveries) { resultList.add(save(f)); } RecoveryRequest request = new RecoveryRequest(); request.setRequestInfo(requestInfo); request.setRecoverys(new ArrayList<>()); for (Recovery f : resultList) { contract = new RecoveryContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getRecoverys().add(contract); } addToSearchQueue(request); return resultList; } } }
RecoveryRepository { @Transactional public List<Recovery> save(List<Recovery> recoveries, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); RecoveryContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { RecoveryRequest request = new RecoveryRequest(); request.setRequestInfo(requestInfo); request.setRecoverys(new ArrayList<>()); for (Recovery f : recoveries) { contract = new RecoveryContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getRecoverys().add(contract); } addToQue(request); return recoveries; } else { List<Recovery> resultList = new ArrayList<Recovery>(); for (Recovery f : recoveries) { resultList.add(save(f)); } RecoveryRequest request = new RecoveryRequest(); request.setRequestInfo(requestInfo); request.setRecoverys(new ArrayList<>()); for (Recovery f : resultList) { contract = new RecoveryContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getRecoverys().add(contract); } addToSearchQueue(request); return resultList; } } @Autowired  RecoveryRepository(MastersQueueRepository recoveryQueueRepository, FinancialConfigurationService financialConfigurationService,
                              @Value("${persist.through.kafka}") String persistThroughKafka,
                              RecoveryJdbcRepository recoveryJdbcRepository,
                              RecoveryESRepository recoveryESRepository); }
RecoveryRepository { @Transactional public List<Recovery> save(List<Recovery> recoveries, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); RecoveryContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { RecoveryRequest request = new RecoveryRequest(); request.setRequestInfo(requestInfo); request.setRecoverys(new ArrayList<>()); for (Recovery f : recoveries) { contract = new RecoveryContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getRecoverys().add(contract); } addToQue(request); return recoveries; } else { List<Recovery> resultList = new ArrayList<Recovery>(); for (Recovery f : recoveries) { resultList.add(save(f)); } RecoveryRequest request = new RecoveryRequest(); request.setRequestInfo(requestInfo); request.setRecoverys(new ArrayList<>()); for (Recovery f : resultList) { contract = new RecoveryContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getRecoverys().add(contract); } addToSearchQueue(request); return resultList; } } @Autowired  RecoveryRepository(MastersQueueRepository recoveryQueueRepository, FinancialConfigurationService financialConfigurationService,
                              @Value("${persist.through.kafka}") String persistThroughKafka,
                              RecoveryJdbcRepository recoveryJdbcRepository,
                              RecoveryESRepository recoveryESRepository); @Transactional List<Recovery> save(List<Recovery> recoveries,
                               RequestInfo requestInfo); @Transactional List<Recovery> update(List<Recovery> recoveries,
                                 RequestInfo requestInfo); String getNextSequence(); Recovery findById(Recovery recovery); @Transactional Recovery save(Recovery recovery); @Transactional Recovery update(Recovery recovery); void addToQue(RecoveryRequest request); void addToSearchQueue(RecoveryRequest request); Pagination<Recovery> search(RecoverySearch domain); boolean uniqueCheck(String fieldName, Recovery recovery); }
RecoveryRepository { @Transactional public List<Recovery> save(List<Recovery> recoveries, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); RecoveryContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { RecoveryRequest request = new RecoveryRequest(); request.setRequestInfo(requestInfo); request.setRecoverys(new ArrayList<>()); for (Recovery f : recoveries) { contract = new RecoveryContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getRecoverys().add(contract); } addToQue(request); return recoveries; } else { List<Recovery> resultList = new ArrayList<Recovery>(); for (Recovery f : recoveries) { resultList.add(save(f)); } RecoveryRequest request = new RecoveryRequest(); request.setRequestInfo(requestInfo); request.setRecoverys(new ArrayList<>()); for (Recovery f : resultList) { contract = new RecoveryContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getRecoverys().add(contract); } addToSearchQueue(request); return resultList; } } @Autowired  RecoveryRepository(MastersQueueRepository recoveryQueueRepository, FinancialConfigurationService financialConfigurationService,
                              @Value("${persist.through.kafka}") String persistThroughKafka,
                              RecoveryJdbcRepository recoveryJdbcRepository,
                              RecoveryESRepository recoveryESRepository); @Transactional List<Recovery> save(List<Recovery> recoveries,
                               RequestInfo requestInfo); @Transactional List<Recovery> update(List<Recovery> recoveries,
                                 RequestInfo requestInfo); String getNextSequence(); Recovery findById(Recovery recovery); @Transactional Recovery save(Recovery recovery); @Transactional Recovery update(Recovery recovery); void addToQue(RecoveryRequest request); void addToSearchQueue(RecoveryRequest request); Pagination<Recovery> search(RecoverySearch domain); boolean uniqueCheck(String fieldName, Recovery recovery);  }