mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 15:47:01 +00:00
test/Enhance createTransaction method to include isCompleted parameter for improved transaction status handling in tests
This commit is contained in:
parent
1c159413d9
commit
bdd5c72047
@ -100,7 +100,7 @@ trait LocalMappedConnectorTestSetup extends TestConnectorSetupWithStandardPermis
|
||||
Entitlement.entitlement.vend.addEntitlement(bankId, userId, roleName)
|
||||
}
|
||||
|
||||
override protected def createTransaction(account: BankAccount, startDate: Date, finishDate: Date) = {
|
||||
override protected def createTransaction(account: BankAccount, startDate: Date, finishDate: Date, isCompleted: Boolean) = {
|
||||
//ugly
|
||||
val mappedBankAccount = account.asInstanceOf[MappedBankAccount]
|
||||
|
||||
@ -110,6 +110,13 @@ trait LocalMappedConnectorTestSetup extends TestConnectorSetupWithStandardPermis
|
||||
|
||||
mappedBankAccount.accountBalance(accountBalanceAfter).save
|
||||
|
||||
// Determine transaction status based on isCompleted parameter
|
||||
val transactionStatus = if (isCompleted) {
|
||||
TransactionRequestStatus.COMPLETED.toString
|
||||
} else {
|
||||
TransactionRequestStatus.INITIATED.toString
|
||||
}
|
||||
|
||||
MappedTransaction.create
|
||||
.bank(account.bankId.value)
|
||||
.account(account.accountId.value)
|
||||
@ -132,43 +139,9 @@ trait LocalMappedConnectorTestSetup extends TestConnectorSetupWithStandardPermis
|
||||
.CPOtherAccountSecondaryRoutingAddress(randomString(5))
|
||||
.CPOtherBankRoutingScheme(randomString(5))
|
||||
.CPOtherBankRoutingAddress(randomString(5))
|
||||
.status(TransactionRequestStatus.COMPLETED.toString) // 🆕 Add transaction status field
|
||||
.status(transactionStatus) // Use determined transaction status
|
||||
.saveMe
|
||||
.toTransaction.orNull
|
||||
|
||||
{
|
||||
val accountBalanceBefore = mappedBankAccount.accountBalance.get
|
||||
val transactionAmount = Random.nextInt(1000).toLong
|
||||
val accountBalanceAfter = accountBalanceBefore + transactionAmount
|
||||
|
||||
mappedBankAccount.accountBalance(accountBalanceAfter).save
|
||||
|
||||
MappedTransaction.create
|
||||
.bank(account.bankId.value)
|
||||
.account(account.accountId.value)
|
||||
.transactionType(randomString(5))
|
||||
.tStartDate(startDate)
|
||||
.tFinishDate(finishDate)
|
||||
.currency(account.currency)
|
||||
.amount(transactionAmount)
|
||||
.newAccountBalance(accountBalanceAfter)
|
||||
.description(randomString(5))
|
||||
.counterpartyAccountHolder(randomString(5))
|
||||
.counterpartyAccountKind(randomString(5))
|
||||
.counterpartyAccountNumber(randomString(5))
|
||||
.counterpartyBankName(randomString(5))
|
||||
.counterpartyIban(randomString(5))
|
||||
.counterpartyNationalId(randomString(5))
|
||||
.CPOtherAccountRoutingScheme(randomString(5))
|
||||
.CPOtherAccountRoutingAddress(randomString(5))
|
||||
.CPOtherAccountSecondaryRoutingScheme(randomString(5))
|
||||
.CPOtherAccountSecondaryRoutingAddress(randomString(5))
|
||||
.CPOtherBankRoutingScheme(randomString(5))
|
||||
.CPOtherBankRoutingAddress(randomString(5))
|
||||
.status(TransactionRequestStatus.INITIATED.toString) // 🆕 Add transaction status field
|
||||
.saveMe
|
||||
.toTransaction.orNull
|
||||
}
|
||||
}
|
||||
|
||||
override protected def createTransactionRequest(account: BankAccount): List[MappedTransactionRequest] = {
|
||||
|
||||
@ -16,7 +16,7 @@ trait TestConnectorSetup {
|
||||
//TODO: implement these right here using Connector.connector.vend and get rid of specific connector setup files
|
||||
protected def createBank(id : String) : Bank
|
||||
protected def createAccount(bankId: BankId, accountId : AccountId, currency : String) : BankAccount
|
||||
protected def createTransaction(account : BankAccount, startDate : Date, finishDate : Date)
|
||||
protected def createTransaction(account : BankAccount, startDate : Date, finishDate : Date, isCompleted: Boolean) : Transaction
|
||||
protected def createTransactionRequest(account: BankAccount): List[MappedTransactionRequest]
|
||||
protected def updateAccountCurrency(bankId: BankId, accountId : AccountId, currency : String) : BankAccount
|
||||
|
||||
@ -126,7 +126,8 @@ trait TestConnectorSetup {
|
||||
for(i <- 0 until NUM_TRANSACTIONS){
|
||||
val postedDate = InitialDateFactory.date
|
||||
val completedDate = add10Minutes(postedDate)
|
||||
createTransaction(account, postedDate, completedDate)
|
||||
val isCompleted = (i % 2) == 0 // Even indices (0,2,4...) are COMPLETED, odd indices (1,3,5...) are INITIATED
|
||||
createTransaction(account, postedDate, completedDate, isCompleted)
|
||||
}
|
||||
|
||||
//load all transactions for the account to generate the counterparty metadata
|
||||
@ -152,7 +153,7 @@ trait TestConnectorSetup {
|
||||
protected def createPublicView(bankId: BankId, accountId: AccountId) : View
|
||||
protected def createCustomRandomView(bankId: BankId, accountId: AccountId) : View
|
||||
|
||||
protected def setAccountHolder(user: User, bankId : BankId, accountId : AccountId)
|
||||
protected def setAccountHolder(user: User, bankId : BankId, accountId : AccountId) : Unit
|
||||
|
||||
protected def wipeTestData()
|
||||
protected def wipeTestData() : Unit
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user