@Test public void testSearch1() { Pagination<Bank> expectedResult = new Pagination<>(); expectedResult.setPageSize(500); expectedResult.setOffset(0); when(financialConfigurationService.fetchDataFrom()).thenReturn("es"); when(bankESRepository.search(any(BankSearchContract.class))).thenReturn(expectedResult); Pagination<Bank> actualResult = bankRepository.search(getBankSearch()); assertEquals(expectedResult, actualResult); }
public Pagination<Bank> search(BankSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { BankSearchContract bankSearchContract = new BankSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, bankSearchContract); return bankESRepository.search(bankSearchContract); } else { return bankJdbcRepository.search(domain); } }
BankRepository { public Pagination<Bank> search(BankSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { BankSearchContract bankSearchContract = new BankSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, bankSearchContract); return bankESRepository.search(bankSearchContract); } else { return bankJdbcRepository.search(domain); } } }
BankRepository { public Pagination<Bank> search(BankSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { BankSearchContract bankSearchContract = new BankSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, bankSearchContract); return bankESRepository.search(bankSearchContract); } else { return bankJdbcRepository.search(domain); } } @Autowired  BankRepository(BankJdbcRepository bankJdbcRepository, MastersQueueRepository bankQueueRepository,
			FinancialConfigurationService financialConfigurationService, BankESRepository bankESRepository,
			@Value("${persist.through.kafka}") String persistThroughKafka); }
BankRepository { public Pagination<Bank> search(BankSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { BankSearchContract bankSearchContract = new BankSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, bankSearchContract); return bankESRepository.search(bankSearchContract); } else { return bankJdbcRepository.search(domain); } } @Autowired  BankRepository(BankJdbcRepository bankJdbcRepository, MastersQueueRepository bankQueueRepository,
			FinancialConfigurationService financialConfigurationService, BankESRepository bankESRepository,
			@Value("${persist.through.kafka}") String persistThroughKafka); Bank findById(Bank bank); String getNextSequence(); @Transactional Bank save(Bank bank); @Transactional Bank update(Bank bank); void add(BankRequest request); Pagination<Bank> search(BankSearch domain); @Transactional List<Bank> save(List<Bank> banks, RequestInfo requestInfo); @Transactional List<Bank> update(List<Bank> banks, RequestInfo requestInfo); void addToQue(BankRequest request); void addToSearchQueue(BankRequest request); boolean uniqueCheck(String fieldName, Bank bank); }
BankRepository { public Pagination<Bank> search(BankSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { BankSearchContract bankSearchContract = new BankSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, bankSearchContract); return bankESRepository.search(bankSearchContract); } else { return bankJdbcRepository.search(domain); } } @Autowired  BankRepository(BankJdbcRepository bankJdbcRepository, MastersQueueRepository bankQueueRepository,
			FinancialConfigurationService financialConfigurationService, BankESRepository bankESRepository,
			@Value("${persist.through.kafka}") String persistThroughKafka); Bank findById(Bank bank); String getNextSequence(); @Transactional Bank save(Bank bank); @Transactional Bank update(Bank bank); void add(BankRequest request); Pagination<Bank> search(BankSearch domain); @Transactional List<Bank> save(List<Bank> banks, RequestInfo requestInfo); @Transactional List<Bank> update(List<Bank> banks, RequestInfo requestInfo); void addToQue(BankRequest request); void addToSearchQueue(BankRequest request); boolean uniqueCheck(String fieldName, Bank bank);  }