@Test public void test_search() { Pagination<VoucherSubType> expectedResult = new Pagination<>(); expectedResult.setPageSize(500); expectedResult.setOffset(0); when(financialConfigurationContractRepository.fetchDataFrom()).thenReturn("db"); when(voucherSubTypeJdbcRepository.search(any(VoucherSubTypeSearch.class))).thenReturn(expectedResult); Pagination<VoucherSubType> actualResult = voucherSubTypeRepositoryWithKafka.search(getVoucherSubTypeSearch()); assertEquals(expectedResult, actualResult); }
public Pagination<VoucherSubType> search(VoucherSubTypeSearch domain) { if (!financialConfigurationContractRepository.fetchDataFrom().isEmpty() && financialConfigurationContractRepository.fetchDataFrom() .equalsIgnoreCase("es")) { VoucherSubTypeSearchContract voucherSubTypeSearchContract = new VoucherSubTypeSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, voucherSubTypeSearchContract); return voucherSubTypeESRepository .search(voucherSubTypeSearchContract); } return voucherSubTypeJdbcRepository.search(domain); }
VoucherSubTypeRepository { public Pagination<VoucherSubType> search(VoucherSubTypeSearch domain) { if (!financialConfigurationContractRepository.fetchDataFrom().isEmpty() && financialConfigurationContractRepository.fetchDataFrom() .equalsIgnoreCase("es")) { VoucherSubTypeSearchContract voucherSubTypeSearchContract = new VoucherSubTypeSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, voucherSubTypeSearchContract); return voucherSubTypeESRepository .search(voucherSubTypeSearchContract); } return voucherSubTypeJdbcRepository.search(domain); } }
VoucherSubTypeRepository { public Pagination<VoucherSubType> search(VoucherSubTypeSearch domain) { if (!financialConfigurationContractRepository.fetchDataFrom().isEmpty() && financialConfigurationContractRepository.fetchDataFrom() .equalsIgnoreCase("es")) { VoucherSubTypeSearchContract voucherSubTypeSearchContract = new VoucherSubTypeSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, voucherSubTypeSearchContract); return voucherSubTypeESRepository .search(voucherSubTypeSearchContract); } return voucherSubTypeJdbcRepository.search(domain); } @Autowired  VoucherSubTypeRepository(
            VoucherSubTypeJdbcRepository voucherSubTypeJdbcRepository,
            FinancialConfigurationContractRepository financialConfigurationContractRepository,
            VoucherSubTypeESRepository voucherSubTypeESRepository,
            VoucherSubTypeQueueRepository voucherSubTypeQueueRepository,
            @Value("${persist.through.kafka}") String persistThroughKafka); }
VoucherSubTypeRepository { public Pagination<VoucherSubType> search(VoucherSubTypeSearch domain) { if (!financialConfigurationContractRepository.fetchDataFrom().isEmpty() && financialConfigurationContractRepository.fetchDataFrom() .equalsIgnoreCase("es")) { VoucherSubTypeSearchContract voucherSubTypeSearchContract = new VoucherSubTypeSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, voucherSubTypeSearchContract); return voucherSubTypeESRepository .search(voucherSubTypeSearchContract); } return voucherSubTypeJdbcRepository.search(domain); } @Autowired  VoucherSubTypeRepository(
            VoucherSubTypeJdbcRepository voucherSubTypeJdbcRepository,
            FinancialConfigurationContractRepository financialConfigurationContractRepository,
            VoucherSubTypeESRepository voucherSubTypeESRepository,
            VoucherSubTypeQueueRepository voucherSubTypeQueueRepository,
            @Value("${persist.through.kafka}") String persistThroughKafka); @Transactional List<VoucherSubType> save(List<VoucherSubType> voucherSubTypes,
            RequestInfo requestInfo); @Transactional List<VoucherSubType> update(List<VoucherSubType> voucherSubTypes,
            RequestInfo requestInfo); @Transactional VoucherSubType save(VoucherSubType voucherSubType); @Transactional VoucherSubType update(VoucherSubType voucherSubType); void addToQue(VoucherSubTypeRequest request); void addToSearchQueue(VoucherSubTypeRequest request); Pagination<VoucherSubType> search(VoucherSubTypeSearch domain); }
VoucherSubTypeRepository { public Pagination<VoucherSubType> search(VoucherSubTypeSearch domain) { if (!financialConfigurationContractRepository.fetchDataFrom().isEmpty() && financialConfigurationContractRepository.fetchDataFrom() .equalsIgnoreCase("es")) { VoucherSubTypeSearchContract voucherSubTypeSearchContract = new VoucherSubTypeSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, voucherSubTypeSearchContract); return voucherSubTypeESRepository .search(voucherSubTypeSearchContract); } return voucherSubTypeJdbcRepository.search(domain); } @Autowired  VoucherSubTypeRepository(
            VoucherSubTypeJdbcRepository voucherSubTypeJdbcRepository,
            FinancialConfigurationContractRepository financialConfigurationContractRepository,
            VoucherSubTypeESRepository voucherSubTypeESRepository,
            VoucherSubTypeQueueRepository voucherSubTypeQueueRepository,
            @Value("${persist.through.kafka}") String persistThroughKafka); @Transactional List<VoucherSubType> save(List<VoucherSubType> voucherSubTypes,
            RequestInfo requestInfo); @Transactional List<VoucherSubType> update(List<VoucherSubType> voucherSubTypes,
            RequestInfo requestInfo); @Transactional VoucherSubType save(VoucherSubType voucherSubType); @Transactional VoucherSubType update(VoucherSubType voucherSubType); void addToQue(VoucherSubTypeRequest request); void addToSearchQueue(VoucherSubTypeRequest request); Pagination<VoucherSubType> search(VoucherSubTypeSearch domain);  }