@Test public void test_search() { Pagination<InstrumentType> expectedResult = new Pagination<>(); expectedResult.setPageSize(500); expectedResult.setOffset(0); when(financialConfigurationContractRepository.fetchDataFrom()).thenReturn("db"); when(instrumentTypeJdbcRepository.search(any(InstrumentTypeSearch.class))).thenReturn(expectedResult); Pagination<InstrumentType> actualResult = instrumentTypeRepositoryWithKafka.search(getInstrumentTypeSearch()); assertEquals(expectedResult, actualResult); }
public Pagination<InstrumentType> search(InstrumentTypeSearch domain) { if (financialConfigurationContractRepository.fetchDataFrom() != null && financialConfigurationContractRepository.fetchDataFrom().equalsIgnoreCase("es")) { InstrumentTypeSearchContract instrumentTypeSearchContract = new InstrumentTypeSearchContract(); InstrumentTypeMapper mapper = new InstrumentTypeMapper(); instrumentTypeSearchContract = mapper.toSearchContract(domain); Pagination<InstrumentType> instrumenttypes = instrumentTypeESRepository .search(instrumentTypeSearchContract); return instrumenttypes; } else return instrumentTypeJdbcRepository.search(domain); }
InstrumentTypeRepository { public Pagination<InstrumentType> search(InstrumentTypeSearch domain) { if (financialConfigurationContractRepository.fetchDataFrom() != null && financialConfigurationContractRepository.fetchDataFrom().equalsIgnoreCase("es")) { InstrumentTypeSearchContract instrumentTypeSearchContract = new InstrumentTypeSearchContract(); InstrumentTypeMapper mapper = new InstrumentTypeMapper(); instrumentTypeSearchContract = mapper.toSearchContract(domain); Pagination<InstrumentType> instrumenttypes = instrumentTypeESRepository .search(instrumentTypeSearchContract); return instrumenttypes; } else return instrumentTypeJdbcRepository.search(domain); } }
InstrumentTypeRepository { public Pagination<InstrumentType> search(InstrumentTypeSearch domain) { if (financialConfigurationContractRepository.fetchDataFrom() != null && financialConfigurationContractRepository.fetchDataFrom().equalsIgnoreCase("es")) { InstrumentTypeSearchContract instrumentTypeSearchContract = new InstrumentTypeSearchContract(); InstrumentTypeMapper mapper = new InstrumentTypeMapper(); instrumentTypeSearchContract = mapper.toSearchContract(domain); Pagination<InstrumentType> instrumenttypes = instrumentTypeESRepository .search(instrumentTypeSearchContract); return instrumenttypes; } else return instrumentTypeJdbcRepository.search(domain); } @Autowired  InstrumentTypeRepository(InstrumentTypeJdbcRepository instrumentTypeJdbcRepository,
            InstrumentTypeQueueRepository instrumentTypeQueueRepository,
            @Value("${persist.through.kafka}") String persistThroughKafka,
            FinancialConfigurationContractRepository financialConfigurationContractRepository,
            InstrumentTypeESRepository instrumentTypeESRepository); }
InstrumentTypeRepository { public Pagination<InstrumentType> search(InstrumentTypeSearch domain) { if (financialConfigurationContractRepository.fetchDataFrom() != null && financialConfigurationContractRepository.fetchDataFrom().equalsIgnoreCase("es")) { InstrumentTypeSearchContract instrumentTypeSearchContract = new InstrumentTypeSearchContract(); InstrumentTypeMapper mapper = new InstrumentTypeMapper(); instrumentTypeSearchContract = mapper.toSearchContract(domain); Pagination<InstrumentType> instrumenttypes = instrumentTypeESRepository .search(instrumentTypeSearchContract); return instrumenttypes; } else return instrumentTypeJdbcRepository.search(domain); } @Autowired  InstrumentTypeRepository(InstrumentTypeJdbcRepository instrumentTypeJdbcRepository,
            InstrumentTypeQueueRepository instrumentTypeQueueRepository,
            @Value("${persist.through.kafka}") String persistThroughKafka,
            FinancialConfigurationContractRepository financialConfigurationContractRepository,
            InstrumentTypeESRepository instrumentTypeESRepository); InstrumentType findById(InstrumentType instrumentType); @Transactional List<InstrumentType> save(List<InstrumentType> instrumentTypes, RequestInfo requestInfo); @Transactional List<InstrumentType> update(List<InstrumentType> instrumentTypes, RequestInfo requestInfo); @Transactional List<InstrumentType> delete(List<InstrumentType> instrumentTypes, RequestInfo requestInfo); @Transactional InstrumentType save(InstrumentType instrumentType); @Transactional InstrumentType update(InstrumentType instrumentType); @Transactional InstrumentType delete(InstrumentType instrumentType); Pagination<InstrumentType> search(InstrumentTypeSearch domain); boolean uniqueCheck(String fieldName, InstrumentType instrumentType); }
InstrumentTypeRepository { public Pagination<InstrumentType> search(InstrumentTypeSearch domain) { if (financialConfigurationContractRepository.fetchDataFrom() != null && financialConfigurationContractRepository.fetchDataFrom().equalsIgnoreCase("es")) { InstrumentTypeSearchContract instrumentTypeSearchContract = new InstrumentTypeSearchContract(); InstrumentTypeMapper mapper = new InstrumentTypeMapper(); instrumentTypeSearchContract = mapper.toSearchContract(domain); Pagination<InstrumentType> instrumenttypes = instrumentTypeESRepository .search(instrumentTypeSearchContract); return instrumenttypes; } else return instrumentTypeJdbcRepository.search(domain); } @Autowired  InstrumentTypeRepository(InstrumentTypeJdbcRepository instrumentTypeJdbcRepository,
            InstrumentTypeQueueRepository instrumentTypeQueueRepository,
            @Value("${persist.through.kafka}") String persistThroughKafka,
            FinancialConfigurationContractRepository financialConfigurationContractRepository,
            InstrumentTypeESRepository instrumentTypeESRepository); InstrumentType findById(InstrumentType instrumentType); @Transactional List<InstrumentType> save(List<InstrumentType> instrumentTypes, RequestInfo requestInfo); @Transactional List<InstrumentType> update(List<InstrumentType> instrumentTypes, RequestInfo requestInfo); @Transactional List<InstrumentType> delete(List<InstrumentType> instrumentTypes, RequestInfo requestInfo); @Transactional InstrumentType save(InstrumentType instrumentType); @Transactional InstrumentType update(InstrumentType instrumentType); @Transactional InstrumentType delete(InstrumentType instrumentType); Pagination<InstrumentType> search(InstrumentTypeSearch domain); boolean uniqueCheck(String fieldName, InstrumentType instrumentType);  }