@Test public void testUpdateWithOutKafka() { List<AccountDetailType> expectedResult = getAccountDetailTypes(); AccountDetailTypeEntity entity = new AccountDetailTypeEntity().toEntity(expectedResult.get(0)); when(accountDetailTypeJdbcRepository.update(any(AccountDetailTypeEntity.class))).thenReturn(entity); accountDetailTypeRepositoryWithOutKafka.update(expectedResult, requestInfo); verify(accountDetailTypeQueueRepository).addToSearch(any(Map.class)); }
@Transactional public List<AccountDetailType> update(List<AccountDetailType> accountDetailTypes, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); AccountDetailTypeContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { AccountDetailTypeRequest request = new AccountDetailTypeRequest(); request.setRequestInfo(requestInfo); request.setAccountDetailTypes(new ArrayList<>()); for (AccountDetailType f : accountDetailTypes) { contract = new AccountDetailTypeContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getAccountDetailTypes().add(contract); } addToQue(request); return accountDetailTypes; } else { List<AccountDetailType> resultList = new ArrayList<AccountDetailType>(); for (AccountDetailType f : accountDetailTypes) { resultList.add(update(f)); } AccountDetailTypeRequest request = new AccountDetailTypeRequest(); request.setRequestInfo(requestInfo); request.setAccountDetailTypes(new ArrayList<>()); for (AccountDetailType f : resultList) { contract = new AccountDetailTypeContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getAccountDetailTypes().add(contract); } addToSearchQueue(request); return resultList; } }
AccountDetailTypeRepository { @Transactional public List<AccountDetailType> update(List<AccountDetailType> accountDetailTypes, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); AccountDetailTypeContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { AccountDetailTypeRequest request = new AccountDetailTypeRequest(); request.setRequestInfo(requestInfo); request.setAccountDetailTypes(new ArrayList<>()); for (AccountDetailType f : accountDetailTypes) { contract = new AccountDetailTypeContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getAccountDetailTypes().add(contract); } addToQue(request); return accountDetailTypes; } else { List<AccountDetailType> resultList = new ArrayList<AccountDetailType>(); for (AccountDetailType f : accountDetailTypes) { resultList.add(update(f)); } AccountDetailTypeRequest request = new AccountDetailTypeRequest(); request.setRequestInfo(requestInfo); request.setAccountDetailTypes(new ArrayList<>()); for (AccountDetailType f : resultList) { contract = new AccountDetailTypeContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getAccountDetailTypes().add(contract); } addToSearchQueue(request); return resultList; } } }
AccountDetailTypeRepository { @Transactional public List<AccountDetailType> update(List<AccountDetailType> accountDetailTypes, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); AccountDetailTypeContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { AccountDetailTypeRequest request = new AccountDetailTypeRequest(); request.setRequestInfo(requestInfo); request.setAccountDetailTypes(new ArrayList<>()); for (AccountDetailType f : accountDetailTypes) { contract = new AccountDetailTypeContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getAccountDetailTypes().add(contract); } addToQue(request); return accountDetailTypes; } else { List<AccountDetailType> resultList = new ArrayList<AccountDetailType>(); for (AccountDetailType f : accountDetailTypes) { resultList.add(update(f)); } AccountDetailTypeRequest request = new AccountDetailTypeRequest(); request.setRequestInfo(requestInfo); request.setAccountDetailTypes(new ArrayList<>()); for (AccountDetailType f : resultList) { contract = new AccountDetailTypeContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getAccountDetailTypes().add(contract); } addToSearchQueue(request); return resultList; } } @Autowired  AccountDetailTypeRepository(AccountDetailTypeJdbcRepository accountDetailTypeJdbcRepository,
			MastersQueueRepository accountDetailTypeQueueRepository,
			FinancialConfigurationService financialConfigurationService,
			AccountDetailTypeESRepository accountDetailTypeESRepository,
			@Value("${persist.through.kafka}") String persistThroughKafka); }
AccountDetailTypeRepository { @Transactional public List<AccountDetailType> update(List<AccountDetailType> accountDetailTypes, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); AccountDetailTypeContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { AccountDetailTypeRequest request = new AccountDetailTypeRequest(); request.setRequestInfo(requestInfo); request.setAccountDetailTypes(new ArrayList<>()); for (AccountDetailType f : accountDetailTypes) { contract = new AccountDetailTypeContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getAccountDetailTypes().add(contract); } addToQue(request); return accountDetailTypes; } else { List<AccountDetailType> resultList = new ArrayList<AccountDetailType>(); for (AccountDetailType f : accountDetailTypes) { resultList.add(update(f)); } AccountDetailTypeRequest request = new AccountDetailTypeRequest(); request.setRequestInfo(requestInfo); request.setAccountDetailTypes(new ArrayList<>()); for (AccountDetailType f : resultList) { contract = new AccountDetailTypeContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getAccountDetailTypes().add(contract); } addToSearchQueue(request); return resultList; } } @Autowired  AccountDetailTypeRepository(AccountDetailTypeJdbcRepository accountDetailTypeJdbcRepository,
			MastersQueueRepository accountDetailTypeQueueRepository,
			FinancialConfigurationService financialConfigurationService,
			AccountDetailTypeESRepository accountDetailTypeESRepository,
			@Value("${persist.through.kafka}") String persistThroughKafka); @Transactional List<AccountDetailType> save(List<AccountDetailType> accountDetailTypes, RequestInfo requestInfo); @Transactional List<AccountDetailType> update(List<AccountDetailType> accountDetailTypes, RequestInfo requestInfo); AccountDetailType findById(AccountDetailType accountDetailType); String getNextSequence(); @Transactional AccountDetailType save(AccountDetailType accountDetailType); @Transactional AccountDetailType update(AccountDetailType accountDetailType); void add(AccountDetailTypeRequest request); Pagination<AccountDetailType> search(AccountDetailTypeSearch domain); void addToQue(AccountDetailTypeRequest request); void addToSearchQueue(AccountDetailTypeRequest request); boolean uniqueCheck(String fieldName, AccountDetailType accountDetailType); }
AccountDetailTypeRepository { @Transactional public List<AccountDetailType> update(List<AccountDetailType> accountDetailTypes, RequestInfo requestInfo) { ModelMapper mapper = new ModelMapper(); AccountDetailTypeContract contract; if (persistThroughKafka != null && !persistThroughKafka.isEmpty() && persistThroughKafka.equalsIgnoreCase("yes")) { AccountDetailTypeRequest request = new AccountDetailTypeRequest(); request.setRequestInfo(requestInfo); request.setAccountDetailTypes(new ArrayList<>()); for (AccountDetailType f : accountDetailTypes) { contract = new AccountDetailTypeContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getAccountDetailTypes().add(contract); } addToQue(request); return accountDetailTypes; } else { List<AccountDetailType> resultList = new ArrayList<AccountDetailType>(); for (AccountDetailType f : accountDetailTypes) { resultList.add(update(f)); } AccountDetailTypeRequest request = new AccountDetailTypeRequest(); request.setRequestInfo(requestInfo); request.setAccountDetailTypes(new ArrayList<>()); for (AccountDetailType f : resultList) { contract = new AccountDetailTypeContract(); contract.setCreatedDate(new Date()); mapper.map(f, contract); request.getAccountDetailTypes().add(contract); } addToSearchQueue(request); return resultList; } } @Autowired  AccountDetailTypeRepository(AccountDetailTypeJdbcRepository accountDetailTypeJdbcRepository,
			MastersQueueRepository accountDetailTypeQueueRepository,
			FinancialConfigurationService financialConfigurationService,
			AccountDetailTypeESRepository accountDetailTypeESRepository,
			@Value("${persist.through.kafka}") String persistThroughKafka); @Transactional List<AccountDetailType> save(List<AccountDetailType> accountDetailTypes, RequestInfo requestInfo); @Transactional List<AccountDetailType> update(List<AccountDetailType> accountDetailTypes, RequestInfo requestInfo); AccountDetailType findById(AccountDetailType accountDetailType); String getNextSequence(); @Transactional AccountDetailType save(AccountDetailType accountDetailType); @Transactional AccountDetailType update(AccountDetailType accountDetailType); void add(AccountDetailTypeRequest request); Pagination<AccountDetailType> search(AccountDetailTypeSearch domain); void addToQue(AccountDetailTypeRequest request); void addToSearchQueue(AccountDetailTypeRequest request); boolean uniqueCheck(String fieldName, AccountDetailType accountDetailType);  }