@Test public void testSearch() { Pagination<BankBranch> expectedResult = new Pagination<>(); expectedResult.setPageSize(500); expectedResult.setOffset(0); when(financialConfigurationService.fetchDataFrom()).thenReturn("db"); when(bankBranchJdbcRepository.search(any(BankBranchSearch.class))).thenReturn(expectedResult); Pagination<BankBranch> actualResult = bankBranchRepository.search(getBankBranchSearch()); assertEquals(expectedResult, actualResult); }
public Pagination<BankBranch> search(BankBranchSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { BankBranchSearchContract bankBranchSearchContract = new BankBranchSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, bankBranchSearchContract); return bankBranchESRepository.search(bankBranchSearchContract); } else { return bankBranchJdbcRepository.search(domain); } }
BankBranchRepository { public Pagination<BankBranch> search(BankBranchSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { BankBranchSearchContract bankBranchSearchContract = new BankBranchSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, bankBranchSearchContract); return bankBranchESRepository.search(bankBranchSearchContract); } else { return bankBranchJdbcRepository.search(domain); } } }
BankBranchRepository { public Pagination<BankBranch> search(BankBranchSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { BankBranchSearchContract bankBranchSearchContract = new BankBranchSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, bankBranchSearchContract); return bankBranchESRepository.search(bankBranchSearchContract); } else { return bankBranchJdbcRepository.search(domain); } } @Autowired  BankBranchRepository(BankBranchJdbcRepository bankBranchJdbcRepository,
			MastersQueueRepository bankBranchQueueRepository,
			FinancialConfigurationService financialConfigurationService, BankBranchESRepository bankBranchESRepository,
			@Value("${persist.through.kafka}") String persistThroughKafka); }
BankBranchRepository { public Pagination<BankBranch> search(BankBranchSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { BankBranchSearchContract bankBranchSearchContract = new BankBranchSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, bankBranchSearchContract); return bankBranchESRepository.search(bankBranchSearchContract); } else { return bankBranchJdbcRepository.search(domain); } } @Autowired  BankBranchRepository(BankBranchJdbcRepository bankBranchJdbcRepository,
			MastersQueueRepository bankBranchQueueRepository,
			FinancialConfigurationService financialConfigurationService, BankBranchESRepository bankBranchESRepository,
			@Value("${persist.through.kafka}") String persistThroughKafka); BankBranch findById(BankBranch bankBranch); String getNextSequence(); @Transactional List<BankBranch> save(List<BankBranch> bankBranches, RequestInfo requestInfo); @Transactional List<BankBranch> update(List<BankBranch> bankBranches, RequestInfo requestInfo); @Transactional BankBranch save(BankBranch bankBranch); @Transactional BankBranch update(BankBranch bankBranch); void add(BankBranchRequest request); Pagination<BankBranch> search(BankBranchSearch domain); void addToQue(BankBranchRequest request); void addToSearchQueue(BankBranchRequest request); boolean uniqueCheck(String fieldName, BankBranch bankBranch); }
BankBranchRepository { public Pagination<BankBranch> search(BankBranchSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { BankBranchSearchContract bankBranchSearchContract = new BankBranchSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, bankBranchSearchContract); return bankBranchESRepository.search(bankBranchSearchContract); } else { return bankBranchJdbcRepository.search(domain); } } @Autowired  BankBranchRepository(BankBranchJdbcRepository bankBranchJdbcRepository,
			MastersQueueRepository bankBranchQueueRepository,
			FinancialConfigurationService financialConfigurationService, BankBranchESRepository bankBranchESRepository,
			@Value("${persist.through.kafka}") String persistThroughKafka); BankBranch findById(BankBranch bankBranch); String getNextSequence(); @Transactional List<BankBranch> save(List<BankBranch> bankBranches, RequestInfo requestInfo); @Transactional List<BankBranch> update(List<BankBranch> bankBranches, RequestInfo requestInfo); @Transactional BankBranch save(BankBranch bankBranch); @Transactional BankBranch update(BankBranch bankBranch); void add(BankBranchRequest request); Pagination<BankBranch> search(BankBranchSearch domain); void addToQue(BankBranchRequest request); void addToSearchQueue(BankBranchRequest request); boolean uniqueCheck(String fieldName, BankBranch bankBranch);  }