@Test public void test_search() { Pagination<SurrenderReason> expectedResult = new Pagination<>(); expectedResult.setPageSize(500); expectedResult.setOffset(0); when(financialConfigurationContractRepository.fetchDataFrom()).thenReturn("db"); when(surrenderReasonJdbcRepository.search(any(SurrenderReasonSearch.class))).thenReturn(expectedResult); Pagination<SurrenderReason> actualResult = surrenderReasonRepositoryWithKafka .search(getSurrenderReasonSearch()); assertEquals(expectedResult, actualResult); }
public Pagination<SurrenderReason> search(SurrenderReasonSearch domain) { if (financialConfigurationContractRepository.fetchDataFrom() != null && financialConfigurationContractRepository.fetchDataFrom().equalsIgnoreCase("es")) { SurrenderReasonMapper mapper = new SurrenderReasonMapper(); SurrenderReasonSearchContract surrenderReasonSearchContract = new SurrenderReasonSearchContract(); surrenderReasonSearchContract = mapper.toSearchContract(domain); return surrenderReasonESRepository.search(surrenderReasonSearchContract); } else return surrenderReasonJdbcRepository.search(domain); }
SurrenderReasonRepository { public Pagination<SurrenderReason> search(SurrenderReasonSearch domain) { if (financialConfigurationContractRepository.fetchDataFrom() != null && financialConfigurationContractRepository.fetchDataFrom().equalsIgnoreCase("es")) { SurrenderReasonMapper mapper = new SurrenderReasonMapper(); SurrenderReasonSearchContract surrenderReasonSearchContract = new SurrenderReasonSearchContract(); surrenderReasonSearchContract = mapper.toSearchContract(domain); return surrenderReasonESRepository.search(surrenderReasonSearchContract); } else return surrenderReasonJdbcRepository.search(domain); } }
SurrenderReasonRepository { public Pagination<SurrenderReason> search(SurrenderReasonSearch domain) { if (financialConfigurationContractRepository.fetchDataFrom() != null && financialConfigurationContractRepository.fetchDataFrom().equalsIgnoreCase("es")) { SurrenderReasonMapper mapper = new SurrenderReasonMapper(); SurrenderReasonSearchContract surrenderReasonSearchContract = new SurrenderReasonSearchContract(); surrenderReasonSearchContract = mapper.toSearchContract(domain); return surrenderReasonESRepository.search(surrenderReasonSearchContract); } else return surrenderReasonJdbcRepository.search(domain); } @Autowired  SurrenderReasonRepository(SurrenderReasonJdbcRepository surrenderReasonJdbcRepository,
            SurrenderReasonQueueRepository surrenderReasonQueueRepository,
            @Value("${persist.through.kafka}") String persistThroughKafka,
            FinancialConfigurationContractRepository financialConfigurationContractRepository,
            SurrenderReasonESRepository surrenderReasonESRepository); }
SurrenderReasonRepository { public Pagination<SurrenderReason> search(SurrenderReasonSearch domain) { if (financialConfigurationContractRepository.fetchDataFrom() != null && financialConfigurationContractRepository.fetchDataFrom().equalsIgnoreCase("es")) { SurrenderReasonMapper mapper = new SurrenderReasonMapper(); SurrenderReasonSearchContract surrenderReasonSearchContract = new SurrenderReasonSearchContract(); surrenderReasonSearchContract = mapper.toSearchContract(domain); return surrenderReasonESRepository.search(surrenderReasonSearchContract); } else return surrenderReasonJdbcRepository.search(domain); } @Autowired  SurrenderReasonRepository(SurrenderReasonJdbcRepository surrenderReasonJdbcRepository,
            SurrenderReasonQueueRepository surrenderReasonQueueRepository,
            @Value("${persist.through.kafka}") String persistThroughKafka,
            FinancialConfigurationContractRepository financialConfigurationContractRepository,
            SurrenderReasonESRepository surrenderReasonESRepository); SurrenderReason findById(SurrenderReason surrenderReason); @Transactional List<SurrenderReason> save(List<SurrenderReason> surrenderReasons, RequestInfo requestInfo); @Transactional List<SurrenderReason> update(List<SurrenderReason> surrenderReasons, RequestInfo requestInfo); @Transactional List<SurrenderReason> delete(List<SurrenderReason> surrenderReasons, RequestInfo requestInfo); @Transactional SurrenderReason save(SurrenderReason surrenderReason); @Transactional SurrenderReason update(SurrenderReason surrenderReason); @Transactional SurrenderReason delete(SurrenderReason surrenderReason); Pagination<SurrenderReason> search(SurrenderReasonSearch domain); boolean uniqueCheck(String fieldName, SurrenderReason surrenderReason); }
SurrenderReasonRepository { public Pagination<SurrenderReason> search(SurrenderReasonSearch domain) { if (financialConfigurationContractRepository.fetchDataFrom() != null && financialConfigurationContractRepository.fetchDataFrom().equalsIgnoreCase("es")) { SurrenderReasonMapper mapper = new SurrenderReasonMapper(); SurrenderReasonSearchContract surrenderReasonSearchContract = new SurrenderReasonSearchContract(); surrenderReasonSearchContract = mapper.toSearchContract(domain); return surrenderReasonESRepository.search(surrenderReasonSearchContract); } else return surrenderReasonJdbcRepository.search(domain); } @Autowired  SurrenderReasonRepository(SurrenderReasonJdbcRepository surrenderReasonJdbcRepository,
            SurrenderReasonQueueRepository surrenderReasonQueueRepository,
            @Value("${persist.through.kafka}") String persistThroughKafka,
            FinancialConfigurationContractRepository financialConfigurationContractRepository,
            SurrenderReasonESRepository surrenderReasonESRepository); SurrenderReason findById(SurrenderReason surrenderReason); @Transactional List<SurrenderReason> save(List<SurrenderReason> surrenderReasons, RequestInfo requestInfo); @Transactional List<SurrenderReason> update(List<SurrenderReason> surrenderReasons, RequestInfo requestInfo); @Transactional List<SurrenderReason> delete(List<SurrenderReason> surrenderReasons, RequestInfo requestInfo); @Transactional SurrenderReason save(SurrenderReason surrenderReason); @Transactional SurrenderReason update(SurrenderReason surrenderReason); @Transactional SurrenderReason delete(SurrenderReason surrenderReason); Pagination<SurrenderReason> search(SurrenderReasonSearch domain); boolean uniqueCheck(String fieldName, SurrenderReason surrenderReason);  }