@Test public void test_search() { Pagination<Recovery> expectedResult = new Pagination<>(); expectedResult.setPageSize(500); expectedResult.setOffset(0); when(financialConfigurationService.fetchDataFrom()).thenReturn("db"); when(recoveryJdbcRepository.search(any(RecoverySearch.class))).thenReturn(expectedResult); Pagination<Recovery> actualResult = recoveryRepository.search(getRecoverySearch()); assertEquals(expectedResult, actualResult); }
public Pagination<Recovery> search(RecoverySearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { RecoverySearchContract recoverySearchContract = new RecoverySearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, recoverySearchContract); return recoveryESRepository.search(recoverySearchContract); } else { return recoveryJdbcRepository.search(domain); } }
RecoveryRepository { public Pagination<Recovery> search(RecoverySearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { RecoverySearchContract recoverySearchContract = new RecoverySearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, recoverySearchContract); return recoveryESRepository.search(recoverySearchContract); } else { return recoveryJdbcRepository.search(domain); } } }
RecoveryRepository { public Pagination<Recovery> search(RecoverySearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { RecoverySearchContract recoverySearchContract = new RecoverySearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, recoverySearchContract); return recoveryESRepository.search(recoverySearchContract); } else { return recoveryJdbcRepository.search(domain); } } @Autowired  RecoveryRepository(MastersQueueRepository recoveryQueueRepository, FinancialConfigurationService financialConfigurationService,
                              @Value("${persist.through.kafka}") String persistThroughKafka,
                              RecoveryJdbcRepository recoveryJdbcRepository,
                              RecoveryESRepository recoveryESRepository); }
RecoveryRepository { public Pagination<Recovery> search(RecoverySearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { RecoverySearchContract recoverySearchContract = new RecoverySearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, recoverySearchContract); return recoveryESRepository.search(recoverySearchContract); } else { return recoveryJdbcRepository.search(domain); } } @Autowired  RecoveryRepository(MastersQueueRepository recoveryQueueRepository, FinancialConfigurationService financialConfigurationService,
                              @Value("${persist.through.kafka}") String persistThroughKafka,
                              RecoveryJdbcRepository recoveryJdbcRepository,
                              RecoveryESRepository recoveryESRepository); @Transactional List<Recovery> save(List<Recovery> recoveries,
                               RequestInfo requestInfo); @Transactional List<Recovery> update(List<Recovery> recoveries,
                                 RequestInfo requestInfo); String getNextSequence(); Recovery findById(Recovery recovery); @Transactional Recovery save(Recovery recovery); @Transactional Recovery update(Recovery recovery); void addToQue(RecoveryRequest request); void addToSearchQueue(RecoveryRequest request); Pagination<Recovery> search(RecoverySearch domain); boolean uniqueCheck(String fieldName, Recovery recovery); }
RecoveryRepository { public Pagination<Recovery> search(RecoverySearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { RecoverySearchContract recoverySearchContract = new RecoverySearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, recoverySearchContract); return recoveryESRepository.search(recoverySearchContract); } else { return recoveryJdbcRepository.search(domain); } } @Autowired  RecoveryRepository(MastersQueueRepository recoveryQueueRepository, FinancialConfigurationService financialConfigurationService,
                              @Value("${persist.through.kafka}") String persistThroughKafka,
                              RecoveryJdbcRepository recoveryJdbcRepository,
                              RecoveryESRepository recoveryESRepository); @Transactional List<Recovery> save(List<Recovery> recoveries,
                               RequestInfo requestInfo); @Transactional List<Recovery> update(List<Recovery> recoveries,
                                 RequestInfo requestInfo); String getNextSequence(); Recovery findById(Recovery recovery); @Transactional Recovery save(Recovery recovery); @Transactional Recovery update(Recovery recovery); void addToQue(RecoveryRequest request); void addToSearchQueue(RecoveryRequest request); Pagination<Recovery> search(RecoverySearch domain); boolean uniqueCheck(String fieldName, Recovery recovery);  }