@Test public void testSaveWithOutKafka() { List<AccountEntity> expectedResult = getAccountEntitys(); AccountEntityEntity entity = new AccountEntityEntity().toEntity(expectedResult.get(0)); when(accountEntityJdbcRepository.create(any(AccountEntityEntity.class))).thenReturn(entity); accountEntityRepositoryWithOutKafka.save(expectedResult, requestInfo); verify(accountEntityQueueRepository).addToSearch(any(Map.class)); }
@Transactional public List<AccountEntity> save(List<AccountEntity> accountEntities, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); AccountEntityContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { AccountEntityRequest request = new AccountEntityRequest(); request.setRequestInfo(requestInfo); request.setAccountEntities(new ArrayList<>()); for (AccountEntity f : accountEntities) { contract = new AccountEntityContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getAccountEntities().add(contract); } addToQue(request); return accountEntities; } else { List<AccountEntity> resultList = new ArrayList<AccountEntity>(); for (AccountEntity f : accountEntities) { resultList.add(save(f)); } AccountEntityRequest request = new AccountEntityRequest(); request.setRequestInfo(requestInfo); request.setAccountEntities(new ArrayList<>()); for (AccountEntity f : resultList) { contract = new AccountEntityContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getAccountEntities().add(contract); } addToSearchQueue(request); return resultList; } }
AccountEntityRepository { @Transactional public List<AccountEntity> save(List<AccountEntity> accountEntities, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); AccountEntityContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { AccountEntityRequest request = new AccountEntityRequest(); request.setRequestInfo(requestInfo); request.setAccountEntities(new ArrayList<>()); for (AccountEntity f : accountEntities) { contract = new AccountEntityContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getAccountEntities().add(contract); } addToQue(request); return accountEntities; } else { List<AccountEntity> resultList = new ArrayList<AccountEntity>(); for (AccountEntity f : accountEntities) { resultList.add(save(f)); } AccountEntityRequest request = new AccountEntityRequest(); request.setRequestInfo(requestInfo); request.setAccountEntities(new ArrayList<>()); for (AccountEntity f : resultList) { contract = new AccountEntityContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getAccountEntities().add(contract); } addToSearchQueue(request); return resultList; } } }
AccountEntityRepository { @Transactional public List<AccountEntity> save(List<AccountEntity> accountEntities, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); AccountEntityContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { AccountEntityRequest request = new AccountEntityRequest(); request.setRequestInfo(requestInfo); request.setAccountEntities(new ArrayList<>()); for (AccountEntity f : accountEntities) { contract = new AccountEntityContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getAccountEntities().add(contract); } addToQue(request); return accountEntities; } else { List<AccountEntity> resultList = new ArrayList<AccountEntity>(); for (AccountEntity f : accountEntities) { resultList.add(save(f)); } AccountEntityRequest request = new AccountEntityRequest(); request.setRequestInfo(requestInfo); request.setAccountEntities(new ArrayList<>()); for (AccountEntity f : resultList) { contract = new AccountEntityContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getAccountEntities().add(contract); } addToSearchQueue(request); return resultList; } } @Autowired  AccountEntityRepository(AccountEntityJdbcRepository accountEntityJdbcRepository,
                                   MastersQueueRepository accountEntityQueueRepository, FinancialConfigurationService financialConfigurationService,
                                   AccountEntityESRepository accountEntityESRepository, @Value("${persist.through.kafka}") String persistThroughKafka); }
AccountEntityRepository { @Transactional public List<AccountEntity> save(List<AccountEntity> accountEntities, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); AccountEntityContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { AccountEntityRequest request = new AccountEntityRequest(); request.setRequestInfo(requestInfo); request.setAccountEntities(new ArrayList<>()); for (AccountEntity f : accountEntities) { contract = new AccountEntityContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getAccountEntities().add(contract); } addToQue(request); return accountEntities; } else { List<AccountEntity> resultList = new ArrayList<AccountEntity>(); for (AccountEntity f : accountEntities) { resultList.add(save(f)); } AccountEntityRequest request = new AccountEntityRequest(); request.setRequestInfo(requestInfo); request.setAccountEntities(new ArrayList<>()); for (AccountEntity f : resultList) { contract = new AccountEntityContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getAccountEntities().add(contract); } addToSearchQueue(request); return resultList; } } @Autowired  AccountEntityRepository(AccountEntityJdbcRepository accountEntityJdbcRepository,
                                   MastersQueueRepository accountEntityQueueRepository, FinancialConfigurationService financialConfigurationService,
                                   AccountEntityESRepository accountEntityESRepository, @Value("${persist.through.kafka}") String persistThroughKafka); @Transactional List<AccountEntity> save(List<AccountEntity> accountEntities, RequestInfo requestInfo); @Transactional List<AccountEntity> update(List<AccountEntity> accountEntities, RequestInfo requestInfo); void addToQue(AccountEntityRequest request); void addToSearchQueue(AccountEntityRequest request); AccountEntity findById(AccountEntity accountEntity); String getNextSequence(); @Transactional AccountEntity save(AccountEntity accountEntity); @Transactional AccountEntity update(AccountEntity accountEntity); void add(AccountEntityRequest request); Pagination<AccountEntity> search(AccountEntitySearch domain); boolean uniqueCheck(String fieldName, AccountEntity accountEntity); }
AccountEntityRepository { @Transactional public List<AccountEntity> save(List<AccountEntity> accountEntities, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); AccountEntityContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { AccountEntityRequest request = new AccountEntityRequest(); request.setRequestInfo(requestInfo); request.setAccountEntities(new ArrayList<>()); for (AccountEntity f : accountEntities) { contract = new AccountEntityContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getAccountEntities().add(contract); } addToQue(request); return accountEntities; } else { List<AccountEntity> resultList = new ArrayList<AccountEntity>(); for (AccountEntity f : accountEntities) { resultList.add(save(f)); } AccountEntityRequest request = new AccountEntityRequest(); request.setRequestInfo(requestInfo); request.setAccountEntities(new ArrayList<>()); for (AccountEntity f : resultList) { contract = new AccountEntityContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getAccountEntities().add(contract); } addToSearchQueue(request); return resultList; } } @Autowired  AccountEntityRepository(AccountEntityJdbcRepository accountEntityJdbcRepository,
                                   MastersQueueRepository accountEntityQueueRepository, FinancialConfigurationService financialConfigurationService,
                                   AccountEntityESRepository accountEntityESRepository, @Value("${persist.through.kafka}") String persistThroughKafka); @Transactional List<AccountEntity> save(List<AccountEntity> accountEntities, RequestInfo requestInfo); @Transactional List<AccountEntity> update(List<AccountEntity> accountEntities, RequestInfo requestInfo); void addToQue(AccountEntityRequest request); void addToSearchQueue(AccountEntityRequest request); AccountEntity findById(AccountEntity accountEntity); String getNextSequence(); @Transactional AccountEntity save(AccountEntity accountEntity); @Transactional AccountEntity update(AccountEntity accountEntity); void add(AccountEntityRequest request); Pagination<AccountEntity> search(AccountEntitySearch domain); boolean uniqueCheck(String fieldName, AccountEntity accountEntity);  }