@Test public void test_search() { Pagination<InstrumentAccountCode> expectedResult = new Pagination<>(); expectedResult.setPageSize(500); expectedResult.setOffset(0); when(financialConfigurationContractRepository.fetchDataFrom()).thenReturn("db"); when(instrumentAccountCodeJdbcRepository.search(any(InstrumentAccountCodeSearch.class))) .thenReturn(expectedResult); Pagination<InstrumentAccountCode> actualResult = instrumentAccountCodeRepositoryWithKafka .search(getInstrumentAccountCodeSearch()); assertEquals(expectedResult, actualResult); }
public Pagination<InstrumentAccountCode> search(InstrumentAccountCodeSearch domain) { if (financialConfigurationContractRepository.fetchDataFrom() != null && financialConfigurationContractRepository.fetchDataFrom().equalsIgnoreCase("es")) { InstrumentAccountCodeMapper mapper = new InstrumentAccountCodeMapper(); InstrumentAccountCodeSearchContract instrumentAccountCodeSearchContract = new InstrumentAccountCodeSearchContract(); instrumentAccountCodeSearchContract = mapper.toSearchContract(domain); return instrumentAccountCodeESRepository.search(instrumentAccountCodeSearchContract); } else return instrumentAccountCodeJdbcRepository.search(domain); }
InstrumentAccountCodeRepository { public Pagination<InstrumentAccountCode> search(InstrumentAccountCodeSearch domain) { if (financialConfigurationContractRepository.fetchDataFrom() != null && financialConfigurationContractRepository.fetchDataFrom().equalsIgnoreCase("es")) { InstrumentAccountCodeMapper mapper = new InstrumentAccountCodeMapper(); InstrumentAccountCodeSearchContract instrumentAccountCodeSearchContract = new InstrumentAccountCodeSearchContract(); instrumentAccountCodeSearchContract = mapper.toSearchContract(domain); return instrumentAccountCodeESRepository.search(instrumentAccountCodeSearchContract); } else return instrumentAccountCodeJdbcRepository.search(domain); } }
InstrumentAccountCodeRepository { public Pagination<InstrumentAccountCode> search(InstrumentAccountCodeSearch domain) { if (financialConfigurationContractRepository.fetchDataFrom() != null && financialConfigurationContractRepository.fetchDataFrom().equalsIgnoreCase("es")) { InstrumentAccountCodeMapper mapper = new InstrumentAccountCodeMapper(); InstrumentAccountCodeSearchContract instrumentAccountCodeSearchContract = new InstrumentAccountCodeSearchContract(); instrumentAccountCodeSearchContract = mapper.toSearchContract(domain); return instrumentAccountCodeESRepository.search(instrumentAccountCodeSearchContract); } else return instrumentAccountCodeJdbcRepository.search(domain); } @Autowired  InstrumentAccountCodeRepository(InstrumentAccountCodeJdbcRepository instrumentAccountCodeJdbcRepository,
            InstrumentAccountCodeQueueRepository instrumentAccountCodeQueueRepository,
            @Value("${persist.through.kafka}") String persistThroughKafka,
            InstrumentAccountCodeESRepository instrumentAccountCodeESRepository,
            FinancialConfigurationContractRepository financialConfigurationContractRepository); }
InstrumentAccountCodeRepository { public Pagination<InstrumentAccountCode> search(InstrumentAccountCodeSearch domain) { if (financialConfigurationContractRepository.fetchDataFrom() != null && financialConfigurationContractRepository.fetchDataFrom().equalsIgnoreCase("es")) { InstrumentAccountCodeMapper mapper = new InstrumentAccountCodeMapper(); InstrumentAccountCodeSearchContract instrumentAccountCodeSearchContract = new InstrumentAccountCodeSearchContract(); instrumentAccountCodeSearchContract = mapper.toSearchContract(domain); return instrumentAccountCodeESRepository.search(instrumentAccountCodeSearchContract); } else return instrumentAccountCodeJdbcRepository.search(domain); } @Autowired  InstrumentAccountCodeRepository(InstrumentAccountCodeJdbcRepository instrumentAccountCodeJdbcRepository,
            InstrumentAccountCodeQueueRepository instrumentAccountCodeQueueRepository,
            @Value("${persist.through.kafka}") String persistThroughKafka,
            InstrumentAccountCodeESRepository instrumentAccountCodeESRepository,
            FinancialConfigurationContractRepository financialConfigurationContractRepository); InstrumentAccountCode findById(InstrumentAccountCode instrumentAccountCode); @Transactional List<InstrumentAccountCode> save(List<InstrumentAccountCode> instrumentAccountCodes,
            RequestInfo requestInfo); @Transactional List<InstrumentAccountCode> update(List<InstrumentAccountCode> instrumentAccountCodes,
            RequestInfo requestInfo); @Transactional List<InstrumentAccountCode> delete(List<InstrumentAccountCode> instrumentAccountCodes,
            RequestInfo requestInfo); @Transactional InstrumentAccountCode save(InstrumentAccountCode instrumentAccountCode); @Transactional InstrumentAccountCode update(InstrumentAccountCode instrumentAccountCode); @Transactional InstrumentAccountCode delete(InstrumentAccountCode instrumentAccountCode); Pagination<InstrumentAccountCode> search(InstrumentAccountCodeSearch domain); boolean uniqueCheck(String fieldName, InstrumentAccountCode instrumentAccountCode); }
InstrumentAccountCodeRepository { public Pagination<InstrumentAccountCode> search(InstrumentAccountCodeSearch domain) { if (financialConfigurationContractRepository.fetchDataFrom() != null && financialConfigurationContractRepository.fetchDataFrom().equalsIgnoreCase("es")) { InstrumentAccountCodeMapper mapper = new InstrumentAccountCodeMapper(); InstrumentAccountCodeSearchContract instrumentAccountCodeSearchContract = new InstrumentAccountCodeSearchContract(); instrumentAccountCodeSearchContract = mapper.toSearchContract(domain); return instrumentAccountCodeESRepository.search(instrumentAccountCodeSearchContract); } else return instrumentAccountCodeJdbcRepository.search(domain); } @Autowired  InstrumentAccountCodeRepository(InstrumentAccountCodeJdbcRepository instrumentAccountCodeJdbcRepository,
            InstrumentAccountCodeQueueRepository instrumentAccountCodeQueueRepository,
            @Value("${persist.through.kafka}") String persistThroughKafka,
            InstrumentAccountCodeESRepository instrumentAccountCodeESRepository,
            FinancialConfigurationContractRepository financialConfigurationContractRepository); InstrumentAccountCode findById(InstrumentAccountCode instrumentAccountCode); @Transactional List<InstrumentAccountCode> save(List<InstrumentAccountCode> instrumentAccountCodes,
            RequestInfo requestInfo); @Transactional List<InstrumentAccountCode> update(List<InstrumentAccountCode> instrumentAccountCodes,
            RequestInfo requestInfo); @Transactional List<InstrumentAccountCode> delete(List<InstrumentAccountCode> instrumentAccountCodes,
            RequestInfo requestInfo); @Transactional InstrumentAccountCode save(InstrumentAccountCode instrumentAccountCode); @Transactional InstrumentAccountCode update(InstrumentAccountCode instrumentAccountCode); @Transactional InstrumentAccountCode delete(InstrumentAccountCode instrumentAccountCode); Pagination<InstrumentAccountCode> search(InstrumentAccountCodeSearch domain); boolean uniqueCheck(String fieldName, InstrumentAccountCode instrumentAccountCode);  }