@Test(expected = CustomException.class) public void updateTransactionInvalidTxnIdTest() { when(validator.validateUpdateTxn(any(Map.class))).thenThrow(new CustomException("TXN_NOT_FOUND", "Transaction not found")); transactionService.updateTransaction(requestInfo, Collections.singletonMap("abc", "PT_001")); }
public List<Transaction> updateTransaction(RequestInfo requestInfo, Map<String, String> requestParams) { Transaction currentTxnStatus = validator.validateUpdateTxn(requestParams); log.debug(currentTxnStatus.toString()); log.debug(requestParams.toString()); Transaction newTxn = null; if(validator.skipGateway(currentTxnStatus)) { newTxn = currentTxnStatus; } else{ newTxn = gatewayService.getLiveStatus(currentTxnStatus, requestParams); enrichmentService.enrichUpdateTransaction(new TransactionRequest(requestInfo, currentTxnStatus), newTxn); } if (validator.shouldGenerateReceipt(currentTxnStatus, newTxn)) { generateReceipt(requestInfo, newTxn); } TransactionDump dump = TransactionDump.builder() .txnId(currentTxnStatus.getTxnId()) .txnResponse(newTxn.getResponseJson()) .auditDetails(newTxn.getAuditDetails()) .build(); producer.push(appProperties.getUpdateTxnTopic(), new org.egov.pg.models.TransactionRequest(requestInfo, newTxn)); producer.push(appProperties.getUpdateTxnDumpTopic(), new TransactionDumpRequest(requestInfo, dump)); return Collections.singletonList(newTxn); }
TransactionService { public List<Transaction> updateTransaction(RequestInfo requestInfo, Map<String, String> requestParams) { Transaction currentTxnStatus = validator.validateUpdateTxn(requestParams); log.debug(currentTxnStatus.toString()); log.debug(requestParams.toString()); Transaction newTxn = null; if(validator.skipGateway(currentTxnStatus)) { newTxn = currentTxnStatus; } else{ newTxn = gatewayService.getLiveStatus(currentTxnStatus, requestParams); enrichmentService.enrichUpdateTransaction(new TransactionRequest(requestInfo, currentTxnStatus), newTxn); } if (validator.shouldGenerateReceipt(currentTxnStatus, newTxn)) { generateReceipt(requestInfo, newTxn); } TransactionDump dump = TransactionDump.builder() .txnId(currentTxnStatus.getTxnId()) .txnResponse(newTxn.getResponseJson()) .auditDetails(newTxn.getAuditDetails()) .build(); producer.push(appProperties.getUpdateTxnTopic(), new org.egov.pg.models.TransactionRequest(requestInfo, newTxn)); producer.push(appProperties.getUpdateTxnDumpTopic(), new TransactionDumpRequest(requestInfo, dump)); return Collections.singletonList(newTxn); } }
TransactionService { public List<Transaction> updateTransaction(RequestInfo requestInfo, Map<String, String> requestParams) { Transaction currentTxnStatus = validator.validateUpdateTxn(requestParams); log.debug(currentTxnStatus.toString()); log.debug(requestParams.toString()); Transaction newTxn = null; if(validator.skipGateway(currentTxnStatus)) { newTxn = currentTxnStatus; } else{ newTxn = gatewayService.getLiveStatus(currentTxnStatus, requestParams); enrichmentService.enrichUpdateTransaction(new TransactionRequest(requestInfo, currentTxnStatus), newTxn); } if (validator.shouldGenerateReceipt(currentTxnStatus, newTxn)) { generateReceipt(requestInfo, newTxn); } TransactionDump dump = TransactionDump.builder() .txnId(currentTxnStatus.getTxnId()) .txnResponse(newTxn.getResponseJson()) .auditDetails(newTxn.getAuditDetails()) .build(); producer.push(appProperties.getUpdateTxnTopic(), new org.egov.pg.models.TransactionRequest(requestInfo, newTxn)); producer.push(appProperties.getUpdateTxnDumpTopic(), new TransactionDumpRequest(requestInfo, dump)); return Collections.singletonList(newTxn); } @Autowired  TransactionService(TransactionValidator validator, GatewayService gatewayService, Producer producer,
                       TransactionRepository
                               transactionRepository, CollectionService collectionService,
                       EnrichmentService enrichmentService,
                       AppProperties appProperties); }
TransactionService { public List<Transaction> updateTransaction(RequestInfo requestInfo, Map<String, String> requestParams) { Transaction currentTxnStatus = validator.validateUpdateTxn(requestParams); log.debug(currentTxnStatus.toString()); log.debug(requestParams.toString()); Transaction newTxn = null; if(validator.skipGateway(currentTxnStatus)) { newTxn = currentTxnStatus; } else{ newTxn = gatewayService.getLiveStatus(currentTxnStatus, requestParams); enrichmentService.enrichUpdateTransaction(new TransactionRequest(requestInfo, currentTxnStatus), newTxn); } if (validator.shouldGenerateReceipt(currentTxnStatus, newTxn)) { generateReceipt(requestInfo, newTxn); } TransactionDump dump = TransactionDump.builder() .txnId(currentTxnStatus.getTxnId()) .txnResponse(newTxn.getResponseJson()) .auditDetails(newTxn.getAuditDetails()) .build(); producer.push(appProperties.getUpdateTxnTopic(), new org.egov.pg.models.TransactionRequest(requestInfo, newTxn)); producer.push(appProperties.getUpdateTxnDumpTopic(), new TransactionDumpRequest(requestInfo, dump)); return Collections.singletonList(newTxn); } @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> updateTransaction(RequestInfo requestInfo, Map<String, String> requestParams) { Transaction currentTxnStatus = validator.validateUpdateTxn(requestParams); log.debug(currentTxnStatus.toString()); log.debug(requestParams.toString()); Transaction newTxn = null; if(validator.skipGateway(currentTxnStatus)) { newTxn = currentTxnStatus; } else{ newTxn = gatewayService.getLiveStatus(currentTxnStatus, requestParams); enrichmentService.enrichUpdateTransaction(new TransactionRequest(requestInfo, currentTxnStatus), newTxn); } if (validator.shouldGenerateReceipt(currentTxnStatus, newTxn)) { generateReceipt(requestInfo, newTxn); } TransactionDump dump = TransactionDump.builder() .txnId(currentTxnStatus.getTxnId()) .txnResponse(newTxn.getResponseJson()) .auditDetails(newTxn.getAuditDetails()) .build(); producer.push(appProperties.getUpdateTxnTopic(), new org.egov.pg.models.TransactionRequest(requestInfo, newTxn)); producer.push(appProperties.getUpdateTxnDumpTopic(), new TransactionDumpRequest(requestInfo, dump)); return Collections.singletonList(newTxn); } @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);  }