@Test public void testUpdateWithOutKafka() { List<BankBranch> expectedResult = getBankBranches(); BankBranchEntity entity = new BankBranchEntity().toEntity(expectedResult.get(0)); when(bankBranchJdbcRepository.update(any(BankBranchEntity.class))).thenReturn(entity); bankBranchRepositoryWithOutKafka.update(expectedResult, requestInfo); verify(bankBranchQueueRepository).addToSearch(any(Map.class)); }
@Transactional public List<BankBranch> update(List<BankBranch> bankBranches, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); BankBranchContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && "yes".equalsIgnoreCase(persistThroughKafka)) { BankBranchRequest request = new BankBranchRequest(); request.setRequestInfo(requestInfo); request.setBankBranches(new ArrayList<>()); for (BankBranch b : bankBranches) { contract = new BankBranchContract(); contract.setCreatedDate(new Date()); mapper.map(b, contract); request.getBankBranches().add(contract); } addToQue(request); return bankBranches; } else { List<BankBranch> resultList = new ArrayList<>(); for (BankBranch b : bankBranches) { resultList.add(update(b)); } BankBranchRequest request = new BankBranchRequest(); request.setRequestInfo(requestInfo); request.setBankBranches(new ArrayList<>()); for (BankBranch b : resultList) { contract = new BankBranchContract(); contract.setCreatedDate(new Date()); mapper.map(b, contract); request.getBankBranches().add(contract); } addToSearchQueue(request); return resultList; } }
BankBranchRepository { @Transactional public List<BankBranch> update(List<BankBranch> bankBranches, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); BankBranchContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && "yes".equalsIgnoreCase(persistThroughKafka)) { BankBranchRequest request = new BankBranchRequest(); request.setRequestInfo(requestInfo); request.setBankBranches(new ArrayList<>()); for (BankBranch b : bankBranches) { contract = new BankBranchContract(); contract.setCreatedDate(new Date()); mapper.map(b, contract); request.getBankBranches().add(contract); } addToQue(request); return bankBranches; } else { List<BankBranch> resultList = new ArrayList<>(); for (BankBranch b : bankBranches) { resultList.add(update(b)); } BankBranchRequest request = new BankBranchRequest(); request.setRequestInfo(requestInfo); request.setBankBranches(new ArrayList<>()); for (BankBranch b : resultList) { contract = new BankBranchContract(); contract.setCreatedDate(new Date()); mapper.map(b, contract); request.getBankBranches().add(contract); } addToSearchQueue(request); return resultList; } } }
BankBranchRepository { @Transactional public List<BankBranch> update(List<BankBranch> bankBranches, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); BankBranchContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && "yes".equalsIgnoreCase(persistThroughKafka)) { BankBranchRequest request = new BankBranchRequest(); request.setRequestInfo(requestInfo); request.setBankBranches(new ArrayList<>()); for (BankBranch b : bankBranches) { contract = new BankBranchContract(); contract.setCreatedDate(new Date()); mapper.map(b, contract); request.getBankBranches().add(contract); } addToQue(request); return bankBranches; } else { List<BankBranch> resultList = new ArrayList<>(); for (BankBranch b : bankBranches) { resultList.add(update(b)); } BankBranchRequest request = new BankBranchRequest(); request.setRequestInfo(requestInfo); request.setBankBranches(new ArrayList<>()); for (BankBranch b : resultList) { contract = new BankBranchContract(); contract.setCreatedDate(new Date()); mapper.map(b, contract); request.getBankBranches().add(contract); } addToSearchQueue(request); return resultList; } } @Autowired  BankBranchRepository(BankBranchJdbcRepository bankBranchJdbcRepository,
			MastersQueueRepository bankBranchQueueRepository,
			FinancialConfigurationService financialConfigurationService, BankBranchESRepository bankBranchESRepository,
			@Value("${persist.through.kafka}") String persistThroughKafka); }
BankBranchRepository { @Transactional public List<BankBranch> update(List<BankBranch> bankBranches, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); BankBranchContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && "yes".equalsIgnoreCase(persistThroughKafka)) { BankBranchRequest request = new BankBranchRequest(); request.setRequestInfo(requestInfo); request.setBankBranches(new ArrayList<>()); for (BankBranch b : bankBranches) { contract = new BankBranchContract(); contract.setCreatedDate(new Date()); mapper.map(b, contract); request.getBankBranches().add(contract); } addToQue(request); return bankBranches; } else { List<BankBranch> resultList = new ArrayList<>(); for (BankBranch b : bankBranches) { resultList.add(update(b)); } BankBranchRequest request = new BankBranchRequest(); request.setRequestInfo(requestInfo); request.setBankBranches(new ArrayList<>()); for (BankBranch b : resultList) { contract = new BankBranchContract(); contract.setCreatedDate(new Date()); mapper.map(b, contract); request.getBankBranches().add(contract); } addToSearchQueue(request); return resultList; } } @Autowired  BankBranchRepository(BankBranchJdbcRepository bankBranchJdbcRepository,
			MastersQueueRepository bankBranchQueueRepository,
			FinancialConfigurationService financialConfigurationService, BankBranchESRepository bankBranchESRepository,
			@Value("${persist.through.kafka}") String persistThroughKafka); BankBranch findById(BankBranch bankBranch); String getNextSequence(); @Transactional List<BankBranch> save(List<BankBranch> bankBranches, RequestInfo requestInfo); @Transactional List<BankBranch> update(List<BankBranch> bankBranches, RequestInfo requestInfo); @Transactional BankBranch save(BankBranch bankBranch); @Transactional BankBranch update(BankBranch bankBranch); void add(BankBranchRequest request); Pagination<BankBranch> search(BankBranchSearch domain); void addToQue(BankBranchRequest request); void addToSearchQueue(BankBranchRequest request); boolean uniqueCheck(String fieldName, BankBranch bankBranch); }
BankBranchRepository { @Transactional public List<BankBranch> update(List<BankBranch> bankBranches, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); BankBranchContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && "yes".equalsIgnoreCase(persistThroughKafka)) { BankBranchRequest request = new BankBranchRequest(); request.setRequestInfo(requestInfo); request.setBankBranches(new ArrayList<>()); for (BankBranch b : bankBranches) { contract = new BankBranchContract(); contract.setCreatedDate(new Date()); mapper.map(b, contract); request.getBankBranches().add(contract); } addToQue(request); return bankBranches; } else { List<BankBranch> resultList = new ArrayList<>(); for (BankBranch b : bankBranches) { resultList.add(update(b)); } BankBranchRequest request = new BankBranchRequest(); request.setRequestInfo(requestInfo); request.setBankBranches(new ArrayList<>()); for (BankBranch b : resultList) { contract = new BankBranchContract(); contract.setCreatedDate(new Date()); mapper.map(b, contract); request.getBankBranches().add(contract); } addToSearchQueue(request); return resultList; } } @Autowired  BankBranchRepository(BankBranchJdbcRepository bankBranchJdbcRepository,
			MastersQueueRepository bankBranchQueueRepository,
			FinancialConfigurationService financialConfigurationService, BankBranchESRepository bankBranchESRepository,
			@Value("${persist.through.kafka}") String persistThroughKafka); BankBranch findById(BankBranch bankBranch); String getNextSequence(); @Transactional List<BankBranch> save(List<BankBranch> bankBranches, RequestInfo requestInfo); @Transactional List<BankBranch> update(List<BankBranch> bankBranches, RequestInfo requestInfo); @Transactional BankBranch save(BankBranch bankBranch); @Transactional BankBranch update(BankBranch bankBranch); void add(BankBranchRequest request); Pagination<BankBranch> search(BankBranchSearch domain); void addToQue(BankBranchRequest request); void addToSearchQueue(BankBranchRequest request); boolean uniqueCheck(String fieldName, BankBranch bankBranch);  }