@Test public void test_search() { Pagination<Instrument> expectedResult = new Pagination<>(); expectedResult.setPageSize(500); expectedResult.setOffset(0); when(financialConfigurationContractRepository.fetchDataFrom()).thenReturn("db"); when(instrumentJdbcRepository.search(any(InstrumentSearch.class))).thenReturn(expectedResult); Pagination<Instrument> actualResult = instrumentRepositoryWithKafka.search(getInstrumentSearch()); assertEquals(expectedResult, actualResult); }
public Pagination<Instrument> search(InstrumentSearch domain) { if (financialConfigurationContractRepository.fetchDataFrom() != null && financialConfigurationContractRepository.fetchDataFrom().equalsIgnoreCase("es")) { InstrumentMapper mapper = new InstrumentMapper(); InstrumentSearchContract instrumentSearchContract = new InstrumentSearchContract(); instrumentSearchContract = mapper.toSearchContract(domain); Pagination<Instrument> instruments = instrumentESRepository.search(instrumentSearchContract); return instruments; } else return instrumentJdbcRepository.search(domain); }
InstrumentRepository { public Pagination<Instrument> search(InstrumentSearch domain) { if (financialConfigurationContractRepository.fetchDataFrom() != null && financialConfigurationContractRepository.fetchDataFrom().equalsIgnoreCase("es")) { InstrumentMapper mapper = new InstrumentMapper(); InstrumentSearchContract instrumentSearchContract = new InstrumentSearchContract(); instrumentSearchContract = mapper.toSearchContract(domain); Pagination<Instrument> instruments = instrumentESRepository.search(instrumentSearchContract); return instruments; } else return instrumentJdbcRepository.search(domain); } }
InstrumentRepository { public Pagination<Instrument> search(InstrumentSearch domain) { if (financialConfigurationContractRepository.fetchDataFrom() != null && financialConfigurationContractRepository.fetchDataFrom().equalsIgnoreCase("es")) { InstrumentMapper mapper = new InstrumentMapper(); InstrumentSearchContract instrumentSearchContract = new InstrumentSearchContract(); instrumentSearchContract = mapper.toSearchContract(domain); Pagination<Instrument> instruments = instrumentESRepository.search(instrumentSearchContract); return instruments; } else return instrumentJdbcRepository.search(domain); } @Autowired  InstrumentRepository(InstrumentJdbcRepository instrumentJdbcRepository,
            InstrumentQueueRepository instrumentQueueRepository,
            @Value("${persist.through.kafka}") String persistThroughKafka,
            InstrumentESRepository instrumentESRepository,
            FinancialConfigurationContractRepository financialConfigurationContractRepository,
            InstrumentVoucherJdbcRepository instrumentVoucherJdbcRepository); }
InstrumentRepository { public Pagination<Instrument> search(InstrumentSearch domain) { if (financialConfigurationContractRepository.fetchDataFrom() != null && financialConfigurationContractRepository.fetchDataFrom().equalsIgnoreCase("es")) { InstrumentMapper mapper = new InstrumentMapper(); InstrumentSearchContract instrumentSearchContract = new InstrumentSearchContract(); instrumentSearchContract = mapper.toSearchContract(domain); Pagination<Instrument> instruments = instrumentESRepository.search(instrumentSearchContract); return instruments; } else return instrumentJdbcRepository.search(domain); } @Autowired  InstrumentRepository(InstrumentJdbcRepository instrumentJdbcRepository,
            InstrumentQueueRepository instrumentQueueRepository,
            @Value("${persist.through.kafka}") String persistThroughKafka,
            InstrumentESRepository instrumentESRepository,
            FinancialConfigurationContractRepository financialConfigurationContractRepository,
            InstrumentVoucherJdbcRepository instrumentVoucherJdbcRepository); Instrument findById(Instrument instrument); @Transactional List<Instrument> save(List<Instrument> instruments, RequestInfo requestInfo); @Transactional List<Instrument> update(List<Instrument> instruments, RequestInfo requestInfo); @Transactional List<Instrument> delete(List<Instrument> instruments, RequestInfo requestInfo); @Transactional Instrument save(Instrument instrument); @Transactional Instrument update(Instrument instrument); @Transactional Instrument delete(Instrument instrument); Pagination<Instrument> search(InstrumentSearch domain); boolean uniqueCheck(String fieldName, Instrument instrument); }
InstrumentRepository { public Pagination<Instrument> search(InstrumentSearch domain) { if (financialConfigurationContractRepository.fetchDataFrom() != null && financialConfigurationContractRepository.fetchDataFrom().equalsIgnoreCase("es")) { InstrumentMapper mapper = new InstrumentMapper(); InstrumentSearchContract instrumentSearchContract = new InstrumentSearchContract(); instrumentSearchContract = mapper.toSearchContract(domain); Pagination<Instrument> instruments = instrumentESRepository.search(instrumentSearchContract); return instruments; } else return instrumentJdbcRepository.search(domain); } @Autowired  InstrumentRepository(InstrumentJdbcRepository instrumentJdbcRepository,
            InstrumentQueueRepository instrumentQueueRepository,
            @Value("${persist.through.kafka}") String persistThroughKafka,
            InstrumentESRepository instrumentESRepository,
            FinancialConfigurationContractRepository financialConfigurationContractRepository,
            InstrumentVoucherJdbcRepository instrumentVoucherJdbcRepository); Instrument findById(Instrument instrument); @Transactional List<Instrument> save(List<Instrument> instruments, RequestInfo requestInfo); @Transactional List<Instrument> update(List<Instrument> instruments, RequestInfo requestInfo); @Transactional List<Instrument> delete(List<Instrument> instruments, RequestInfo requestInfo); @Transactional Instrument save(Instrument instrument); @Transactional Instrument update(Instrument instrument); @Transactional Instrument delete(Instrument instrument); Pagination<Instrument> search(InstrumentSearch domain); boolean uniqueCheck(String fieldName, Instrument instrument);  }