diff options
Diffstat (limited to 'sandbox/src/test/kotlin/BalanceTest.kt')
-rw-r--r-- | sandbox/src/test/kotlin/BalanceTest.kt | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/sandbox/src/test/kotlin/BalanceTest.kt b/sandbox/src/test/kotlin/BalanceTest.kt new file mode 100644 index 00000000..a8c4d9e9 --- /dev/null +++ b/sandbox/src/test/kotlin/BalanceTest.kt @@ -0,0 +1,72 @@ +import org.jetbrains.exposed.dao.id.EntityID +import org.jetbrains.exposed.sql.SchemaUtils +import org.jetbrains.exposed.sql.insert +import org.jetbrains.exposed.sql.transactions.transaction +import org.junit.Test +import tech.libeufin.sandbox.BankAccountTransactionsTable +import tech.libeufin.sandbox.BankAccountsTable +import tech.libeufin.sandbox.balanceForAccount +import tech.libeufin.util.millis +import java.math.BigInteger +import java.time.LocalDateTime + +class BalanceTest { + + @Test + fun balanceTest() { + withTestDatabase { + transaction { + SchemaUtils.create(BankAccountTransactionsTable) + BankAccountTransactionsTable.insert { + it[account] = EntityID(0, BankAccountsTable) + it[creditorIban] = "earns" + it[creditorBic] = "BIC" + it[creditorName] = "Creditor Name" + it[debtorIban] = "spends" + it[debtorBic] = "BIC" + it[debtorName] = "Debitor Name" + it[subject] = "deal" + it[amount] = "1" + it[date] = LocalDateTime.now().millis() + it[currency] = "EUR" + it[pmtInfId] = "0" + it[direction] = "DBIT" + it[accountServicerReference] = "test-account-servicer-reference" + } + BankAccountTransactionsTable.insert { + it[account] = EntityID(0, BankAccountsTable) + it[creditorIban] = "earns" + it[creditorBic] = "BIC" + it[creditorName] = "Creditor Name" + it[debtorIban] = "spends" + it[debtorBic] = "BIC" + it[debtorName] = "Debitor Name" + it[subject] = "deal" + it[amount] = "1" + it[date] = LocalDateTime.now().millis() + it[currency] = "EUR" + it[pmtInfId] = "0" + it[direction] = "DBIT" + it[accountServicerReference] = "test-account-servicer-reference" + } + BankAccountTransactionsTable.insert { + it[account] = EntityID(0, BankAccountsTable) + it[creditorIban] = "other" + it[creditorBic] = "BIC" + it[creditorName] = "Creditor Name" + it[debtorIban] = "earns" + it[debtorBic] = "BIC" + it[debtorName] = "Debitor Name" + it[subject] = "deal" + it[amount] = "1" + it[date] = LocalDateTime.now().millis() + it[currency] = "EUR" + it[pmtInfId] = "0" + it[direction] = "DBIT" + it[accountServicerReference] = "test-account-servicer-reference" + } + assert(BigInteger.ONE == balanceForAccount("earns")) + } + } + } +}
\ No newline at end of file |