summaryrefslogtreecommitdiff
path: root/sandbox/src/test/kotlin/DatabaseTest.kt
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/src/test/kotlin/DatabaseTest.kt')
-rw-r--r--sandbox/src/test/kotlin/DatabaseTest.kt48
1 files changed, 44 insertions, 4 deletions
diff --git a/sandbox/src/test/kotlin/DatabaseTest.kt b/sandbox/src/test/kotlin/DatabaseTest.kt
index ead97a33..5c43698c 100644
--- a/sandbox/src/test/kotlin/DatabaseTest.kt
+++ b/sandbox/src/test/kotlin/DatabaseTest.kt
@@ -1,8 +1,5 @@
import org.junit.Test
-import tech.libeufin.sandbox.BankAccount
-import tech.libeufin.sandbox.Customer
-import tech.libeufin.sandbox.Database
-import tech.libeufin.sandbox.TalerAmount
+import tech.libeufin.sandbox.*
import tech.libeufin.util.execCommand
class DatabaseTest {
@@ -15,6 +12,15 @@ class DatabaseTest {
cashoutPayto = "payto://external-IBAN",
cashoutCurrency = "KUDOS"
)
+ private val c1 = Customer(
+ login = "bar",
+ passwordHash = "hash",
+ name = "Bar",
+ phone = "+00",
+ email = "foo@b.ar",
+ cashoutPayto = "payto://external-IBAN",
+ cashoutCurrency = "KUDOS"
+ )
fun initDb(): Database {
execCommand(
listOf(
@@ -27,6 +33,40 @@ class DatabaseTest {
)
return Database("jdbc:postgresql:///libeufincheck")
}
+
+ @Test
+ fun bankTransactionTest() {
+ val db = initDb()
+ // Need accounts first.
+ db.customerCreate(c)
+ db.customerCreate(c1)
+ db.bankAccountCreate(BankAccount(
+ iban = "XYZ",
+ bic = "not used",
+ bankAccountLabel = "foo",
+ lastNexusFetchRowId = 1L,
+ owningCustomerId = 1L
+ ))
+ db.bankAccountCreate(BankAccount(
+ iban = "ABC",
+ bic = "not used",
+ bankAccountLabel = "bar",
+ lastNexusFetchRowId = 1L,
+ owningCustomerId = 2L
+ ))
+ db.bankAccountSetMaxDebt("foo", TalerAmount(100, 0))
+ val res = db.bankTransactionCreate(BankInternalTransaction(
+ creditorAccountId = 2,
+ debtorAccountId = 1,
+ subject = "test",
+ amount = TalerAmount(3, 333),
+ accountServicerReference = "acct-svcr-ref",
+ endToEndId = "end-to-end-id",
+ paymentInformationId = "pmtinfid",
+ transactionDate = 100000L
+ ))
+ assert(res == Database.BankTransactionResult.SUCCESS)
+ }
@Test
fun customerCreationTest() {
val db = initDb()