commit d40f0c42e8bb2a4654a50346e16b9ea946d66865 parent fd8b6fa526c0d16eb3758282083598acfa0abfb6 Author: MS <ms@taler.net> Date: Mon, 18 May 2020 15:52:13 +0200 sandbox db test Diffstat:
| A | sandbox/src/test/kotlin/DBTest.kt | | | 49 | +++++++++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 49 insertions(+), 0 deletions(-)
diff --git a/sandbox/src/test/kotlin/DBTest.kt b/sandbox/src/test/kotlin/DBTest.kt @@ -0,0 +1,48 @@ +import org.jetbrains.exposed.sql.Database +import org.jetbrains.exposed.sql.SchemaUtils +import org.jetbrains.exposed.sql.StdOutSqlLogger +import org.jetbrains.exposed.sql.addLogger +import org.jetbrains.exposed.sql.transactions.TransactionManager +import org.jetbrains.exposed.sql.transactions.transaction +import org.joda.time.DateTime +import org.junit.Test +import tech.libeufin.sandbox.PaymentEntity +import tech.libeufin.sandbox.PaymentsTable +import tech.libeufin.util.parseDashedDate +import java.sql.Connection + + +class DBTest { + @Test + fun exist() { + println("x") + } + + @Test + fun betweenDates() { + Database.connect("jdbc:sqlite:sandbox-test.sqlite3", "org.sqlite.JDBC") + TransactionManager.manager.defaultIsolationLevel = Connection.TRANSACTION_SERIALIZABLE + transaction { + SchemaUtils.create(PaymentsTable) + PaymentEntity.new { + creditorIban = "earns" + debitorIban = "spends" + subject = "deal" + amount = "EUR:1" + date = DateTime.now().millis + } + } + val result = transaction { + addLogger(StdOutSqlLogger) + PaymentEntity.find { + PaymentsTable.date.between( + parseDashedDate( + "1970-01-01" + ).millis, + DateTime.now().millis + ) + }.firstOrNull() + } + assert(result != null) + } +} +\ No newline at end of file