@Test public void getTransactionsSuccessTest(){ Transaction txn = Transaction.builder().txnId("PT_001") .txnAmount("100") .tenantId("pb") .billId("ORDER0012") .productInfo("Property Tax Payment") .gateway("ABCD123") .build(); TransactionCriteria criteria = TransactionCriteria.builder().tenantId("pb").txnId("PT_001").build(); when(transactionRepository.fetchTransactions(criteria)).thenReturn(Collections.singletonList(txn)); assertEquals(1, transactionService.getTransactions(criteria).size()); when(transactionRepository.fetchTransactions(criteria)).thenReturn(Collections.emptyList()); assertEquals(0, transactionService.getTransactions(criteria).size()); }
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);  }