@Test public void testSearch1() { Pagination<BankAccount> expectedResult = new Pagination<>(); expectedResult.setPageSize(500); expectedResult.setOffset(0); when(financialConfigurationService.fetchDataFrom()).thenReturn("es"); when(bankAccountESRepository.search(any(BankAccountSearchContract.class))).thenReturn(expectedResult); Pagination<BankAccount> actualResult = bankAccountRepository.search(getBankAccountSearch()); assertEquals(expectedResult, actualResult); }
public Pagination<BankAccount> search(BankAccountSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { BankAccountSearchContract bankAccountSearchContract = new BankAccountSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, bankAccountSearchContract); return bankAccountESRepository.search(bankAccountSearchContract); } else { return bankAccountJdbcRepository.search(domain); } }
BankAccountRepository { public Pagination<BankAccount> search(BankAccountSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { BankAccountSearchContract bankAccountSearchContract = new BankAccountSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, bankAccountSearchContract); return bankAccountESRepository.search(bankAccountSearchContract); } else { return bankAccountJdbcRepository.search(domain); } } }
BankAccountRepository { public Pagination<BankAccount> search(BankAccountSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { BankAccountSearchContract bankAccountSearchContract = new BankAccountSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, bankAccountSearchContract); return bankAccountESRepository.search(bankAccountSearchContract); } else { return bankAccountJdbcRepository.search(domain); } } @Autowired  BankAccountRepository(BankAccountJdbcRepository bankAccountJdbcRepository,
			MastersQueueRepository bankAccountQueueRepository,
			FinancialConfigurationService financialConfigurationService,
			BankAccountESRepository bankAccountESRepository,
			@Value("${persist.through.kafka}") String persistThroughKafka); }
BankAccountRepository { public Pagination<BankAccount> search(BankAccountSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { BankAccountSearchContract bankAccountSearchContract = new BankAccountSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, bankAccountSearchContract); return bankAccountESRepository.search(bankAccountSearchContract); } else { return bankAccountJdbcRepository.search(domain); } } @Autowired  BankAccountRepository(BankAccountJdbcRepository bankAccountJdbcRepository,
			MastersQueueRepository bankAccountQueueRepository,
			FinancialConfigurationService financialConfigurationService,
			BankAccountESRepository bankAccountESRepository,
			@Value("${persist.through.kafka}") String persistThroughKafka); BankAccount findById(BankAccount bankAccount); String getNextSequence(); @Transactional BankAccount save(BankAccount bankAccount); @Transactional BankAccount update(BankAccount bankAccount); boolean uniqueCheck(String fieldName, BankAccount bankAccount); void add(BankAccountRequest request); Pagination<BankAccount> search(BankAccountSearch domain); @Transactional List<BankAccount> save(List<BankAccount> bankAccounts, RequestInfo requestInfo); @Transactional List<BankAccount> update(List<BankAccount> bankAccounts, RequestInfo requestInfo); void addToQue(BankAccountRequest request); void addToSearchQueue(BankAccountRequest request); }
BankAccountRepository { public Pagination<BankAccount> search(BankAccountSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { BankAccountSearchContract bankAccountSearchContract = new BankAccountSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, bankAccountSearchContract); return bankAccountESRepository.search(bankAccountSearchContract); } else { return bankAccountJdbcRepository.search(domain); } } @Autowired  BankAccountRepository(BankAccountJdbcRepository bankAccountJdbcRepository,
			MastersQueueRepository bankAccountQueueRepository,
			FinancialConfigurationService financialConfigurationService,
			BankAccountESRepository bankAccountESRepository,
			@Value("${persist.through.kafka}") String persistThroughKafka); BankAccount findById(BankAccount bankAccount); String getNextSequence(); @Transactional BankAccount save(BankAccount bankAccount); @Transactional BankAccount update(BankAccount bankAccount); boolean uniqueCheck(String fieldName, BankAccount bankAccount); void add(BankAccountRequest request); Pagination<BankAccount> search(BankAccountSearch domain); @Transactional List<BankAccount> save(List<BankAccount> bankAccounts, RequestInfo requestInfo); @Transactional List<BankAccount> update(List<BankAccount> bankAccounts, RequestInfo requestInfo); void addToQue(BankAccountRequest request); void addToSearchQueue(BankAccountRequest request);  }