@Test public void testSearch() { Pagination<Function> expectedResult = new Pagination<>(); expectedResult.setPageSize(500); expectedResult.setOffset(0); when(financialConfigurationService.fetchDataFrom()).thenReturn("db"); when(functionJdbcRepository.search(any(FunctionSearch.class))).thenReturn(expectedResult); Pagination<Function> actualResult = functionRepository.search(getFunctionSearch()); assertEquals(expectedResult, actualResult); }
public Pagination<Function> search(FunctionSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { FunctionSearchContract functionSearchContract = new FunctionSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, functionSearchContract); return functionESRepository.search(functionSearchContract); } else { return functionJdbcRepository.search(domain); } }
FunctionRepository { public Pagination<Function> search(FunctionSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { FunctionSearchContract functionSearchContract = new FunctionSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, functionSearchContract); return functionESRepository.search(functionSearchContract); } else { return functionJdbcRepository.search(domain); } } }
FunctionRepository { public Pagination<Function> search(FunctionSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { FunctionSearchContract functionSearchContract = new FunctionSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, functionSearchContract); return functionESRepository.search(functionSearchContract); } else { return functionJdbcRepository.search(domain); } } @Autowired  FunctionRepository(FunctionJdbcRepository functionJdbcRepository,
			MastersQueueRepository functionQueueRepository, FinancialConfigurationService financialConfigurationService,
			FunctionESRepository functionESRepository, @Value("${persist.through.kafka}") String persistThroughKafka); }
FunctionRepository { public Pagination<Function> search(FunctionSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { FunctionSearchContract functionSearchContract = new FunctionSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, functionSearchContract); return functionESRepository.search(functionSearchContract); } else { return functionJdbcRepository.search(domain); } } @Autowired  FunctionRepository(FunctionJdbcRepository functionJdbcRepository,
			MastersQueueRepository functionQueueRepository, FinancialConfigurationService financialConfigurationService,
			FunctionESRepository functionESRepository, @Value("${persist.through.kafka}") String persistThroughKafka); @Transactional List<Function> save(List<Function> functions, RequestInfo requestInfo); @Transactional List<Function> update(List<Function> functions, RequestInfo requestInfo); String getNextSequence(); Function findById(Function function); @Transactional Function save(Function function); @Transactional Function update(Function function); void addToQue(FunctionRequest request); void addToSearchQueue(FunctionRequest request); Pagination<Function> search(FunctionSearch domain); boolean uniqueCheck(String fieldName, Function function); }
FunctionRepository { public Pagination<Function> search(FunctionSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { FunctionSearchContract functionSearchContract = new FunctionSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, functionSearchContract); return functionESRepository.search(functionSearchContract); } else { return functionJdbcRepository.search(domain); } } @Autowired  FunctionRepository(FunctionJdbcRepository functionJdbcRepository,
			MastersQueueRepository functionQueueRepository, FinancialConfigurationService financialConfigurationService,
			FunctionESRepository functionESRepository, @Value("${persist.through.kafka}") String persistThroughKafka); @Transactional List<Function> save(List<Function> functions, RequestInfo requestInfo); @Transactional List<Function> update(List<Function> functions, RequestInfo requestInfo); String getNextSequence(); Function findById(Function function); @Transactional Function save(Function function); @Transactional Function update(Function function); void addToQue(FunctionRequest request); void addToSearchQueue(FunctionRequest request); Pagination<Function> search(FunctionSearch domain); boolean uniqueCheck(String fieldName, Function function);  }