@Test public void testSaveWithOutKafka() { List<AccountDetailKey> expectedResult = getAccountDetailKies(); AccountDetailKeyEntity entity = new AccountDetailKeyEntity().toEntity(expectedResult.get(0)); when(accountDetailKeyJdbcRepository.create(any(AccountDetailKeyEntity.class))).thenReturn(entity); accountDetailKeyRepositoryWithOutKafka.save(expectedResult, requestInfo); verify(accountDetailKeyQueueRepository).addToSearch(any(Map.class)); }
@Transactional public List<AccountDetailKey> save(List<AccountDetailKey> accountDetailKies, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); AccountDetailKeyContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { AccountDetailKeyRequest request = new AccountDetailKeyRequest(); request.setRequestInfo(requestInfo); request.setAccountDetailKeys(new ArrayList<>()); for (AccountDetailKey f : accountDetailKies) { contract = new AccountDetailKeyContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getAccountDetailKeys().add(contract); } addToQue(request); return accountDetailKies; } else { List<AccountDetailKey> resultList = new ArrayList<>(); for (AccountDetailKey f : accountDetailKies) { resultList.add(save(f)); } AccountDetailKeyRequest request = new AccountDetailKeyRequest(); request.setRequestInfo(requestInfo); request.setAccountDetailKeys(new ArrayList<>()); for (AccountDetailKey f : resultList) { contract = new AccountDetailKeyContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getAccountDetailKeys().add(contract); } addToSearchQueue(request); return resultList; } }
AccountDetailKeyRepository { @Transactional public List<AccountDetailKey> save(List<AccountDetailKey> accountDetailKies, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); AccountDetailKeyContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { AccountDetailKeyRequest request = new AccountDetailKeyRequest(); request.setRequestInfo(requestInfo); request.setAccountDetailKeys(new ArrayList<>()); for (AccountDetailKey f : accountDetailKies) { contract = new AccountDetailKeyContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getAccountDetailKeys().add(contract); } addToQue(request); return accountDetailKies; } else { List<AccountDetailKey> resultList = new ArrayList<>(); for (AccountDetailKey f : accountDetailKies) { resultList.add(save(f)); } AccountDetailKeyRequest request = new AccountDetailKeyRequest(); request.setRequestInfo(requestInfo); request.setAccountDetailKeys(new ArrayList<>()); for (AccountDetailKey f : resultList) { contract = new AccountDetailKeyContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getAccountDetailKeys().add(contract); } addToSearchQueue(request); return resultList; } } }
AccountDetailKeyRepository { @Transactional public List<AccountDetailKey> save(List<AccountDetailKey> accountDetailKies, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); AccountDetailKeyContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { AccountDetailKeyRequest request = new AccountDetailKeyRequest(); request.setRequestInfo(requestInfo); request.setAccountDetailKeys(new ArrayList<>()); for (AccountDetailKey f : accountDetailKies) { contract = new AccountDetailKeyContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getAccountDetailKeys().add(contract); } addToQue(request); return accountDetailKies; } else { List<AccountDetailKey> resultList = new ArrayList<>(); for (AccountDetailKey f : accountDetailKies) { resultList.add(save(f)); } AccountDetailKeyRequest request = new AccountDetailKeyRequest(); request.setRequestInfo(requestInfo); request.setAccountDetailKeys(new ArrayList<>()); for (AccountDetailKey f : resultList) { contract = new AccountDetailKeyContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getAccountDetailKeys().add(contract); } addToSearchQueue(request); return resultList; } } @Autowired  AccountDetailKeyRepository(AccountDetailKeyJdbcRepository accountDetailKeyJdbcRepository,
			MastersQueueRepository accountDetailKeyQueueRepository,
			FinancialConfigurationService financialConfigurationService,
			AccountDetailKeyESRepository accountDetailKeyESRepository,
			@Value("${persist.through.kafka}") String persistThroughKafka); }
AccountDetailKeyRepository { @Transactional public List<AccountDetailKey> save(List<AccountDetailKey> accountDetailKies, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); AccountDetailKeyContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { AccountDetailKeyRequest request = new AccountDetailKeyRequest(); request.setRequestInfo(requestInfo); request.setAccountDetailKeys(new ArrayList<>()); for (AccountDetailKey f : accountDetailKies) { contract = new AccountDetailKeyContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getAccountDetailKeys().add(contract); } addToQue(request); return accountDetailKies; } else { List<AccountDetailKey> resultList = new ArrayList<>(); for (AccountDetailKey f : accountDetailKies) { resultList.add(save(f)); } AccountDetailKeyRequest request = new AccountDetailKeyRequest(); request.setRequestInfo(requestInfo); request.setAccountDetailKeys(new ArrayList<>()); for (AccountDetailKey f : resultList) { contract = new AccountDetailKeyContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getAccountDetailKeys().add(contract); } addToSearchQueue(request); return resultList; } } @Autowired  AccountDetailKeyRepository(AccountDetailKeyJdbcRepository accountDetailKeyJdbcRepository,
			MastersQueueRepository accountDetailKeyQueueRepository,
			FinancialConfigurationService financialConfigurationService,
			AccountDetailKeyESRepository accountDetailKeyESRepository,
			@Value("${persist.through.kafka}") String persistThroughKafka); @Transactional List<AccountDetailKey> save(List<AccountDetailKey> accountDetailKies, RequestInfo requestInfo); @Transactional List<AccountDetailKey> update(List<AccountDetailKey> accountDetailKies, RequestInfo requestInfo); void addToQue(AccountDetailKeyRequest request); void addToSearchQueue(AccountDetailKeyRequest request); AccountDetailKey findById(AccountDetailKey accountDetailKey); String getNextSequence(); @Transactional AccountDetailKey save(AccountDetailKey accountDetailKey); @Transactional AccountDetailKey update(AccountDetailKey accountDetailKey); void add(AccountDetailKeyRequest request); Pagination<AccountDetailKey> search(final AccountDetailKeySearch domain); boolean uniqueCheck(String fieldName, AccountDetailKey accountDetailKey); }
AccountDetailKeyRepository { @Transactional public List<AccountDetailKey> save(List<AccountDetailKey> accountDetailKies, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); AccountDetailKeyContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { AccountDetailKeyRequest request = new AccountDetailKeyRequest(); request.setRequestInfo(requestInfo); request.setAccountDetailKeys(new ArrayList<>()); for (AccountDetailKey f : accountDetailKies) { contract = new AccountDetailKeyContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getAccountDetailKeys().add(contract); } addToQue(request); return accountDetailKies; } else { List<AccountDetailKey> resultList = new ArrayList<>(); for (AccountDetailKey f : accountDetailKies) { resultList.add(save(f)); } AccountDetailKeyRequest request = new AccountDetailKeyRequest(); request.setRequestInfo(requestInfo); request.setAccountDetailKeys(new ArrayList<>()); for (AccountDetailKey f : resultList) { contract = new AccountDetailKeyContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getAccountDetailKeys().add(contract); } addToSearchQueue(request); return resultList; } } @Autowired  AccountDetailKeyRepository(AccountDetailKeyJdbcRepository accountDetailKeyJdbcRepository,
			MastersQueueRepository accountDetailKeyQueueRepository,
			FinancialConfigurationService financialConfigurationService,
			AccountDetailKeyESRepository accountDetailKeyESRepository,
			@Value("${persist.through.kafka}") String persistThroughKafka); @Transactional List<AccountDetailKey> save(List<AccountDetailKey> accountDetailKies, RequestInfo requestInfo); @Transactional List<AccountDetailKey> update(List<AccountDetailKey> accountDetailKies, RequestInfo requestInfo); void addToQue(AccountDetailKeyRequest request); void addToSearchQueue(AccountDetailKeyRequest request); AccountDetailKey findById(AccountDetailKey accountDetailKey); String getNextSequence(); @Transactional AccountDetailKey save(AccountDetailKey accountDetailKey); @Transactional AccountDetailKey update(AccountDetailKey accountDetailKey); void add(AccountDetailKeyRequest request); Pagination<AccountDetailKey> search(final AccountDetailKeySearch domain); boolean uniqueCheck(String fieldName, AccountDetailKey accountDetailKey);  }