@Test public void testSearch1() { Pagination<Fund> expectedResult = new Pagination<>(); expectedResult.setPageSize(500); expectedResult.setOffset(0); when(financialConfigurationService.fetchDataFrom()).thenReturn("es"); when(fundESRepository.search(any(FundSearchContract.class))).thenReturn(expectedResult); Pagination<Fund> actualResult = fundRepository.search(getFundSearch()); assertEquals(expectedResult, actualResult); }
public Pagination<Fund> search(FundSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { FundSearchContract fundSearchContract = new FundSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, fundSearchContract); return fundESRepository.search(fundSearchContract); } else { return fundJdbcRepository.search(domain); } }
FundRepository { public Pagination<Fund> search(FundSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { FundSearchContract fundSearchContract = new FundSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, fundSearchContract); return fundESRepository.search(fundSearchContract); } else { return fundJdbcRepository.search(domain); } } }
FundRepository { public Pagination<Fund> search(FundSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { FundSearchContract fundSearchContract = new FundSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, fundSearchContract); return fundESRepository.search(fundSearchContract); } else { return fundJdbcRepository.search(domain); } } @Autowired  FundRepository(FundJdbcRepository fundJdbcRepository, MastersQueueRepository fundQueueRepository,
			FinancialConfigurationService financialConfigurationService, FundESRepository fundESRepository,
			@Value("${persist.through.kafka}") String persistThroughKafka); }
FundRepository { public Pagination<Fund> search(FundSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { FundSearchContract fundSearchContract = new FundSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, fundSearchContract); return fundESRepository.search(fundSearchContract); } else { return fundJdbcRepository.search(domain); } } @Autowired  FundRepository(FundJdbcRepository fundJdbcRepository, MastersQueueRepository fundQueueRepository,
			FinancialConfigurationService financialConfigurationService, FundESRepository fundESRepository,
			@Value("${persist.through.kafka}") String persistThroughKafka); @Transactional List<Fund> save(List<Fund> funds, RequestInfo requestInfo); @Transactional List<Fund> update(List<Fund> funds, RequestInfo requestInfo); String getNextSequence(); Fund findById(Fund fund); @Transactional Fund save(Fund fund); @Transactional Fund update(Fund fund); Pagination<Fund> search(FundSearch domain); boolean uniqueCheck(String fieldName, Fund fund); }
FundRepository { public Pagination<Fund> search(FundSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { FundSearchContract fundSearchContract = new FundSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, fundSearchContract); return fundESRepository.search(fundSearchContract); } else { return fundJdbcRepository.search(domain); } } @Autowired  FundRepository(FundJdbcRepository fundJdbcRepository, MastersQueueRepository fundQueueRepository,
			FinancialConfigurationService financialConfigurationService, FundESRepository fundESRepository,
			@Value("${persist.through.kafka}") String persistThroughKafka); @Transactional List<Fund> save(List<Fund> funds, RequestInfo requestInfo); @Transactional List<Fund> update(List<Fund> funds, RequestInfo requestInfo); String getNextSequence(); Fund findById(Fund fund); @Transactional Fund save(Fund fund); @Transactional Fund update(Fund fund); Pagination<Fund> search(FundSearch domain); boolean uniqueCheck(String fieldName, Fund fund);  }