commit fbbe514d84fedfc99c1c2069839199d93cae4661
parent 855350fdc3ee3156a1110182fb004c63657ef1c1
Author: Marcello Stanisci <stanisci.m@gmail.com>
Date: Tue, 17 Mar 2020 18:46:02 +0100
Including CAMT-generation test.
Diffstat:
2 files changed, 47 insertions(+), 1 deletion(-)
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
@@ -139,7 +139,7 @@ private suspend fun ApplicationCall.respondEbicsKeyManagement(
respondText(text, ContentType.Application.Xml, HttpStatusCode.OK)
}
-private fun buildCamtString(history: SizedIterable<BankTransactionEntity>, type: Int): String {
+fun buildCamtString(history: SizedIterable<BankTransactionEntity>, type: Int): String {
return constructXml(indent = true) {
root("Document") {
diff --git a/sandbox/src/test/kotlin/CamtGeneration.kt b/sandbox/src/test/kotlin/CamtGeneration.kt
@@ -0,0 +1,45 @@
+package tech.libeufin.sandbox
+
+import org.jetbrains.exposed.sql.transactions.transaction
+import org.joda.time.DateTime
+import org.junit.Test
+import org.junit.Before
+import tech.libeufin.util.Amount
+import org.jetbrains.exposed.sql.SchemaUtils
+import org.jetbrains.exposed.sql.Database
+
+class CamtGeneration {
+
+ @Before
+ fun connectAndMakeTables() {
+ Database.connect("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", driver = "org.h2.Driver")
+ transaction {
+ SchemaUtils.create(BankCustomersTable)
+ SchemaUtils.create(BankTransactionsTable)
+ }
+ }
+
+ @Test
+ fun generateCamt() {
+ transaction {
+ val customer = BankCustomerEntity.new {
+ customerName = "payer"
+ }
+ for (iter in 1..5) {
+ BankTransactionEntity.new {
+ localCustomer = customer
+ counterpart = "IBAN${iter}"
+ subject = "subject #${iter}"
+ operationDate = DateTime.parse("3000-01-01").millis
+ valueDate = DateTime.parse("3000-01-02").millis
+ amount = Amount("${iter}.0")
+ }
+ }
+ val string = buildCamtString(
+ BankTransactionEntity.all(),
+ 52
+ )
+ println(string)
+ }
+ }
+}
+\ No newline at end of file