@Test public void testSearch1() { Pagination<AccountDetailType> expectedResult = new Pagination<>(); expectedResult.setPageSize(500); expectedResult.setOffset(0); when(financialConfigurationService.fetchDataFrom()).thenReturn("es"); when(accountDetailTypeESRepository.search(any(AccountDetailTypeSearchContract.class))) .thenReturn(expectedResult); Pagination<AccountDetailType> actualResult = accountDetailTypeRepository.search(getAccountDetailTypeSearch()); assertEquals(expectedResult, actualResult); }
public Pagination<AccountDetailType> search(AccountDetailTypeSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { AccountDetailTypeSearchContract accountCodeTypeSearchContract = new AccountDetailTypeSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, accountCodeTypeSearchContract); return accountDetailTypeESRepository.search(accountCodeTypeSearchContract); } else { return accountDetailTypeJdbcRepository.search(domain); } }
AccountDetailTypeRepository { public Pagination<AccountDetailType> search(AccountDetailTypeSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { AccountDetailTypeSearchContract accountCodeTypeSearchContract = new AccountDetailTypeSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, accountCodeTypeSearchContract); return accountDetailTypeESRepository.search(accountCodeTypeSearchContract); } else { return accountDetailTypeJdbcRepository.search(domain); } } }
AccountDetailTypeRepository { public Pagination<AccountDetailType> search(AccountDetailTypeSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { AccountDetailTypeSearchContract accountCodeTypeSearchContract = new AccountDetailTypeSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, accountCodeTypeSearchContract); return accountDetailTypeESRepository.search(accountCodeTypeSearchContract); } else { return accountDetailTypeJdbcRepository.search(domain); } } @Autowired  AccountDetailTypeRepository(AccountDetailTypeJdbcRepository accountDetailTypeJdbcRepository,
			MastersQueueRepository accountDetailTypeQueueRepository,
			FinancialConfigurationService financialConfigurationService,
			AccountDetailTypeESRepository accountDetailTypeESRepository,
			@Value("${persist.through.kafka}") String persistThroughKafka); }
AccountDetailTypeRepository { public Pagination<AccountDetailType> search(AccountDetailTypeSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { AccountDetailTypeSearchContract accountCodeTypeSearchContract = new AccountDetailTypeSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, accountCodeTypeSearchContract); return accountDetailTypeESRepository.search(accountCodeTypeSearchContract); } else { return accountDetailTypeJdbcRepository.search(domain); } } @Autowired  AccountDetailTypeRepository(AccountDetailTypeJdbcRepository accountDetailTypeJdbcRepository,
			MastersQueueRepository accountDetailTypeQueueRepository,
			FinancialConfigurationService financialConfigurationService,
			AccountDetailTypeESRepository accountDetailTypeESRepository,
			@Value("${persist.through.kafka}") String persistThroughKafka); @Transactional List<AccountDetailType> save(List<AccountDetailType> accountDetailTypes, RequestInfo requestInfo); @Transactional List<AccountDetailType> update(List<AccountDetailType> accountDetailTypes, RequestInfo requestInfo); AccountDetailType findById(AccountDetailType accountDetailType); String getNextSequence(); @Transactional AccountDetailType save(AccountDetailType accountDetailType); @Transactional AccountDetailType update(AccountDetailType accountDetailType); void add(AccountDetailTypeRequest request); Pagination<AccountDetailType> search(AccountDetailTypeSearch domain); void addToQue(AccountDetailTypeRequest request); void addToSearchQueue(AccountDetailTypeRequest request); boolean uniqueCheck(String fieldName, AccountDetailType accountDetailType); }
AccountDetailTypeRepository { public Pagination<AccountDetailType> search(AccountDetailTypeSearch domain) { if (!financialConfigurationService.fetchDataFrom().isEmpty() && financialConfigurationService.fetchDataFrom().equalsIgnoreCase("es")) { AccountDetailTypeSearchContract accountCodeTypeSearchContract = new AccountDetailTypeSearchContract(); ModelMapper mapper = new ModelMapper(); mapper.map(domain, accountCodeTypeSearchContract); return accountDetailTypeESRepository.search(accountCodeTypeSearchContract); } else { return accountDetailTypeJdbcRepository.search(domain); } } @Autowired  AccountDetailTypeRepository(AccountDetailTypeJdbcRepository accountDetailTypeJdbcRepository,
			MastersQueueRepository accountDetailTypeQueueRepository,
			FinancialConfigurationService financialConfigurationService,
			AccountDetailTypeESRepository accountDetailTypeESRepository,
			@Value("${persist.through.kafka}") String persistThroughKafka); @Transactional List<AccountDetailType> save(List<AccountDetailType> accountDetailTypes, RequestInfo requestInfo); @Transactional List<AccountDetailType> update(List<AccountDetailType> accountDetailTypes, RequestInfo requestInfo); AccountDetailType findById(AccountDetailType accountDetailType); String getNextSequence(); @Transactional AccountDetailType save(AccountDetailType accountDetailType); @Transactional AccountDetailType update(AccountDetailType accountDetailType); void add(AccountDetailTypeRequest request); Pagination<AccountDetailType> search(AccountDetailTypeSearch domain); void addToQue(AccountDetailTypeRequest request); void addToSearchQueue(AccountDetailTypeRequest request); boolean uniqueCheck(String fieldName, AccountDetailType accountDetailType);  }