@Test public void testSearch() { Pagination<AccountEntity> expectedResult = new Pagination<>(); expectedResult.setPageSize(500); expectedResult.setOffset(0); when(financialConfigurationService.fetchDataFrom()).thenReturn("db"); when(accountEntityJdbcRepository.search(any(AccountEntitySearch.class))).thenReturn(expectedResult); Pagination<AccountEntity> actualResult = accountEntityRepository.search(getAccountEntitySearch()); assertEquals(expectedResult, actualResult); }
public Pagination<AccountEntity> search(AccountEntitySearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { AccountEntitySearchContract accountEntitySearchContract = new AccountEntitySearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, accountEntitySearchContract); return accountEntityESRepository.search(accountEntitySearchContract); } else { return accountEntityJdbcRepository.search(domain); } }
AccountEntityRepository { public Pagination<AccountEntity> search(AccountEntitySearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { AccountEntitySearchContract accountEntitySearchContract = new AccountEntitySearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, accountEntitySearchContract); return accountEntityESRepository.search(accountEntitySearchContract); } else { return accountEntityJdbcRepository.search(domain); } } }
AccountEntityRepository { public Pagination<AccountEntity> search(AccountEntitySearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { AccountEntitySearchContract accountEntitySearchContract = new AccountEntitySearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, accountEntitySearchContract); return accountEntityESRepository.search(accountEntitySearchContract); } else { return accountEntityJdbcRepository.search(domain); } } @Autowired  AccountEntityRepository(AccountEntityJdbcRepository accountEntityJdbcRepository,
                                   MastersQueueRepository accountEntityQueueRepository, FinancialConfigurationService financialConfigurationService,
                                   AccountEntityESRepository accountEntityESRepository, @Value("${persist.through.kafka}") String persistThroughKafka); }
AccountEntityRepository { public Pagination<AccountEntity> search(AccountEntitySearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { AccountEntitySearchContract accountEntitySearchContract = new AccountEntitySearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, accountEntitySearchContract); return accountEntityESRepository.search(accountEntitySearchContract); } else { return accountEntityJdbcRepository.search(domain); } } @Autowired  AccountEntityRepository(AccountEntityJdbcRepository accountEntityJdbcRepository,
                                   MastersQueueRepository accountEntityQueueRepository, FinancialConfigurationService financialConfigurationService,
                                   AccountEntityESRepository accountEntityESRepository, @Value("${persist.through.kafka}") String persistThroughKafka); @Transactional List<AccountEntity> save(List<AccountEntity> accountEntities, RequestInfo requestInfo); @Transactional List<AccountEntity> update(List<AccountEntity> accountEntities, RequestInfo requestInfo); void addToQue(AccountEntityRequest request); void addToSearchQueue(AccountEntityRequest request); AccountEntity findById(AccountEntity accountEntity); String getNextSequence(); @Transactional AccountEntity save(AccountEntity accountEntity); @Transactional AccountEntity update(AccountEntity accountEntity); void add(AccountEntityRequest request); Pagination<AccountEntity> search(AccountEntitySearch domain); boolean uniqueCheck(String fieldName, AccountEntity accountEntity); }
AccountEntityRepository { public Pagination<AccountEntity> search(AccountEntitySearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { AccountEntitySearchContract accountEntitySearchContract = new AccountEntitySearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, accountEntitySearchContract); return accountEntityESRepository.search(accountEntitySearchContract); } else { return accountEntityJdbcRepository.search(domain); } } @Autowired  AccountEntityRepository(AccountEntityJdbcRepository accountEntityJdbcRepository,
                                   MastersQueueRepository accountEntityQueueRepository, FinancialConfigurationService financialConfigurationService,
                                   AccountEntityESRepository accountEntityESRepository, @Value("${persist.through.kafka}") String persistThroughKafka); @Transactional List<AccountEntity> save(List<AccountEntity> accountEntities, RequestInfo requestInfo); @Transactional List<AccountEntity> update(List<AccountEntity> accountEntities, RequestInfo requestInfo); void addToQue(AccountEntityRequest request); void addToSearchQueue(AccountEntityRequest request); AccountEntity findById(AccountEntity accountEntity); String getNextSequence(); @Transactional AccountEntity save(AccountEntity accountEntity); @Transactional AccountEntity update(AccountEntity accountEntity); void add(AccountEntityRequest request); Pagination<AccountEntity> search(AccountEntitySearch domain); boolean uniqueCheck(String fieldName, AccountEntity accountEntity);  }