@Test public void testSearch1() { Pagination<AccountCodePurpose> expectedResult = new Pagination<>(); expectedResult.setPageSize(500); expectedResult.setOffset(0); when(financialConfigurationService.fetchDataFrom()).thenReturn("es"); when(accountCodePurposeESRepository.search(any(AccountCodePurposeSearchContract.class))) .thenReturn(expectedResult); Pagination<AccountCodePurpose> actualResult = accountCodePurposeRepository .search(getAccountCodePurposeSearch()); assertEquals(expectedResult, actualResult); }
public Pagination<AccountCodePurpose> search(AccountCodePurposeSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { AccountCodePurposeSearchContract accountCodePurposeSearchContract = new AccountCodePurposeSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, accountCodePurposeSearchContract); return accountCodePurposeESRepository.search(accountCodePurposeSearchContract); } else { return accountCodePurposeJdbcRepository.search(domain); } }
AccountCodePurposeRepository { public Pagination<AccountCodePurpose> search(AccountCodePurposeSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { AccountCodePurposeSearchContract accountCodePurposeSearchContract = new AccountCodePurposeSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, accountCodePurposeSearchContract); return accountCodePurposeESRepository.search(accountCodePurposeSearchContract); } else { return accountCodePurposeJdbcRepository.search(domain); } } }
AccountCodePurposeRepository { public Pagination<AccountCodePurpose> search(AccountCodePurposeSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { AccountCodePurposeSearchContract accountCodePurposeSearchContract = new AccountCodePurposeSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, accountCodePurposeSearchContract); return accountCodePurposeESRepository.search(accountCodePurposeSearchContract); } else { return accountCodePurposeJdbcRepository.search(domain); } } @Autowired  AccountCodePurposeRepository(AccountCodePurposeJdbcRepository accountCodePurposeJdbcRepository,
			MastersQueueRepository accountCodePurposeQueueRepository,
			FinancialConfigurationService financialConfigurationService,
			AccountCodePurposeESRepository accountCodePurposeESRepository,
			@Value("${persist.through.kafka}") String persistThroughKafka); }
AccountCodePurposeRepository { public Pagination<AccountCodePurpose> search(AccountCodePurposeSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { AccountCodePurposeSearchContract accountCodePurposeSearchContract = new AccountCodePurposeSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, accountCodePurposeSearchContract); return accountCodePurposeESRepository.search(accountCodePurposeSearchContract); } else { return accountCodePurposeJdbcRepository.search(domain); } } @Autowired  AccountCodePurposeRepository(AccountCodePurposeJdbcRepository accountCodePurposeJdbcRepository,
			MastersQueueRepository accountCodePurposeQueueRepository,
			FinancialConfigurationService financialConfigurationService,
			AccountCodePurposeESRepository accountCodePurposeESRepository,
			@Value("${persist.through.kafka}") String persistThroughKafka); AccountCodePurpose findById(AccountCodePurpose accountCodePurpose); String getNextSequence(); @Transactional AccountCodePurpose save(AccountCodePurpose accountCodePurpose); @Transactional AccountCodePurpose update(AccountCodePurpose accountCodePurpose); @Transactional List<AccountCodePurpose> save(List<AccountCodePurpose> accountCodePurposes, RequestInfo requestInfo); @Transactional List<AccountCodePurpose> update(List<AccountCodePurpose> accountCodePurposes, RequestInfo requestInfo); void add(AccountCodePurposeRequest request); Pagination<AccountCodePurpose> search(AccountCodePurposeSearch domain); void uniqueCheck(AccountCodePurpose accountCodePurpose); Boolean uniqueCheck(String fieldName, AccountCodePurpose accountCodePurpose); void addToQue(AccountCodePurposeRequest request); void addToSearchQueue(AccountCodePurposeRequest request); }
AccountCodePurposeRepository { public Pagination<AccountCodePurpose> search(AccountCodePurposeSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { AccountCodePurposeSearchContract accountCodePurposeSearchContract = new AccountCodePurposeSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, accountCodePurposeSearchContract); return accountCodePurposeESRepository.search(accountCodePurposeSearchContract); } else { return accountCodePurposeJdbcRepository.search(domain); } } @Autowired  AccountCodePurposeRepository(AccountCodePurposeJdbcRepository accountCodePurposeJdbcRepository,
			MastersQueueRepository accountCodePurposeQueueRepository,
			FinancialConfigurationService financialConfigurationService,
			AccountCodePurposeESRepository accountCodePurposeESRepository,
			@Value("${persist.through.kafka}") String persistThroughKafka); AccountCodePurpose findById(AccountCodePurpose accountCodePurpose); String getNextSequence(); @Transactional AccountCodePurpose save(AccountCodePurpose accountCodePurpose); @Transactional AccountCodePurpose update(AccountCodePurpose accountCodePurpose); @Transactional List<AccountCodePurpose> save(List<AccountCodePurpose> accountCodePurposes, RequestInfo requestInfo); @Transactional List<AccountCodePurpose> update(List<AccountCodePurpose> accountCodePurposes, RequestInfo requestInfo); void add(AccountCodePurposeRequest request); Pagination<AccountCodePurpose> search(AccountCodePurposeSearch domain); void uniqueCheck(AccountCodePurpose accountCodePurpose); Boolean uniqueCheck(String fieldName, AccountCodePurpose accountCodePurpose); void addToQue(AccountCodePurposeRequest request); void addToSearchQueue(AccountCodePurposeRequest request);  }