@Test(expected = CustomException.class) public void getTransactionsFailTest(){ TransactionCriteria criteria = TransactionCriteria.builder().tenantId("pb").txnId("PT_001").build(); when(transactionRepository.fetchTransactions(criteria)).thenThrow(new TransientDataAccessResourceException("test")); transactionService.getTransactions(criteria); }
public List<Transaction> getTransactions(TransactionCriteria transactionCriteria) { log.info(transactionCriteria.toString()); try { return transactionRepository.fetchTransactions(transactionCriteria); } catch (DataAccessException e) { log.error("Unable to fetch data from the database for criteria: " + transactionCriteria.toString(), e); throw new CustomException("FETCH_TXNS_FAILED", "Unable to fetch transactions from store"); } }
TransactionService { public List<Transaction> getTransactions(TransactionCriteria transactionCriteria) { log.info(transactionCriteria.toString()); try { return transactionRepository.fetchTransactions(transactionCriteria); } catch (DataAccessException e) { log.error("Unable to fetch data from the database for criteria: " + transactionCriteria.toString(), e); throw new CustomException("FETCH_TXNS_FAILED", "Unable to fetch transactions from store"); } } }
TransactionService { public List<Transaction> getTransactions(TransactionCriteria transactionCriteria) { log.info(transactionCriteria.toString()); try { return transactionRepository.fetchTransactions(transactionCriteria); } catch (DataAccessException e) { log.error("Unable to fetch data from the database for criteria: " + transactionCriteria.toString(), e); throw new CustomException("FETCH_TXNS_FAILED", "Unable to fetch transactions from store"); } } @Autowired  TransactionService(TransactionValidator validator, GatewayService gatewayService, Producer producer,
                       TransactionRepository
                               transactionRepository, CollectionService collectionService,
                       EnrichmentService enrichmentService,
                       AppProperties appProperties); }
TransactionService { public List<Transaction> getTransactions(TransactionCriteria transactionCriteria) { log.info(transactionCriteria.toString()); try { return transactionRepository.fetchTransactions(transactionCriteria); } catch (DataAccessException e) { log.error("Unable to fetch data from the database for criteria: " + transactionCriteria.toString(), e); throw new CustomException("FETCH_TXNS_FAILED", "Unable to fetch transactions from store"); } } @Autowired  TransactionService(TransactionValidator validator, GatewayService gatewayService, Producer producer,
                       TransactionRepository
                               transactionRepository, CollectionService collectionService,
                       EnrichmentService enrichmentService,
                       AppProperties appProperties); Transaction initiateTransaction(TransactionRequest transactionRequest); List<Transaction> getTransactions(TransactionCriteria transactionCriteria); List<Transaction> updateTransaction(RequestInfo requestInfo, Map<String, String> requestParams); }
TransactionService { public List<Transaction> getTransactions(TransactionCriteria transactionCriteria) { log.info(transactionCriteria.toString()); try { return transactionRepository.fetchTransactions(transactionCriteria); } catch (DataAccessException e) { log.error("Unable to fetch data from the database for criteria: " + transactionCriteria.toString(), e); throw new CustomException("FETCH_TXNS_FAILED", "Unable to fetch transactions from store"); } } @Autowired  TransactionService(TransactionValidator validator, GatewayService gatewayService, Producer producer,
                       TransactionRepository
                               transactionRepository, CollectionService collectionService,
                       EnrichmentService enrichmentService,
                       AppProperties appProperties); Transaction initiateTransaction(TransactionRequest transactionRequest); List<Transaction> getTransactions(TransactionCriteria transactionCriteria); List<Transaction> updateTransaction(RequestInfo requestInfo, Map<String, String> requestParams);  }