[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] 03/03: Testing PAIN.001 generation.
From: |
gnunet |
Subject: |
[libeufin] 03/03: Testing PAIN.001 generation. |
Date: |
Wed, 26 Feb 2020 15:58:08 +0100 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a commit to branch master
in repository libeufin.
commit 51d103762d3c19ad087b1c8191cfd0f0b652db6b
Author: Marcello Stanisci <address@hidden>
AuthorDate: Wed Feb 26 13:34:20 2020 +0100
Testing PAIN.001 generation.
---
nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 11 +++++-
nexus/src/test/kotlin/DbTest.kt | 6 +--
.../test/kotlin/{DbTest.kt => PainGeneration.kt} | 44 ++++++++++++----------
3 files changed, 36 insertions(+), 25 deletions(-)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
index 742e1be..85b60fc 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -46,6 +46,7 @@ import org.jetbrains.exposed.exceptions.ExposedSQLException
import org.jetbrains.exposed.sql.StdOutSqlLogger
import org.jetbrains.exposed.sql.addLogger
import org.jetbrains.exposed.sql.transactions.transaction
+import org.joda.time.DateTime
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.slf4j.event.Level
@@ -194,7 +195,10 @@ fun createPain001document(pain001Entity: Pain001Entity):
String {
text(pain001Entity.id.value.toString())
}
element("CreDtTm") {
- text("DATE")
+ val dateMillis = transaction {
+ pain001Entity.date
+ }
+ text(DateTime(dateMillis).toString("Y-M-d"))
}
element("NbOfTxs") {
text("1")
@@ -226,7 +230,10 @@ fun createPain001document(pain001Entity: Pain001Entity):
String {
text("SEPA")
}
element("ReqdExctnDt") {
- text("date (YYYY-MM-DD) when the clearing agent should
process the payment")
+ val dateMillis = transaction {
+ pain001Entity.date
+ }
+ text(DateTime(dateMillis).toString("Y-M-d"))
}
element("Dbtr/Nm") {
text(pain001Entity.debtorAccount)
diff --git a/nexus/src/test/kotlin/DbTest.kt b/nexus/src/test/kotlin/DbTest.kt
index e79b783..c442889 100644
--- a/nexus/src/test/kotlin/DbTest.kt
+++ b/nexus/src/test/kotlin/DbTest.kt
@@ -43,14 +43,14 @@ class DbTest {
@Test
fun testPain001() {
createPain001entry(
- Pain001Entry(
- debtorAccountId = "da",
+ Pain001Data(
creditorBic = "cb",
creditorIban = "ci",
creditorName = "cn",
sum = Amount(2),
subject = "s"
- )
+ ),
+ "debtor acctid"
)
}
}
\ No newline at end of file
diff --git a/nexus/src/test/kotlin/DbTest.kt
b/nexus/src/test/kotlin/PainGeneration.kt
similarity index 57%
copy from nexus/src/test/kotlin/DbTest.kt
copy to nexus/src/test/kotlin/PainGeneration.kt
index e79b783..05db5bb 100644
--- a/nexus/src/test/kotlin/DbTest.kt
+++ b/nexus/src/test/kotlin/PainGeneration.kt
@@ -12,21 +12,18 @@ import tech.libeufin.util.Amount
import javax.sql.rowset.serial.SerialBlob
-class DbTest {
+
+class PainTest {
@Before
- fun connectAndMakeTables() {
+ fun prepare() {
Database.connect("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", driver =
"org.h2.Driver")
transaction {
SchemaUtils.create(EbicsSubscribersTable)
+ SchemaUtils.create(EbicsAccountsInfoTable)
SchemaUtils.create(Pain001Table)
- }
- }
- @Test
- fun makeCustomer() {
- transaction {
- EbicsSubscriberEntity.new(id = "123asdf") {
+ val subscriberEntity = EbicsSubscriberEntity.new(id = "123asdf") {
ebicsURL = "ebics url"
hostID = "host"
partnerID = "partner"
@@ -36,21 +33,28 @@ class DbTest {
authenticationPrivateKey =
SerialBlob("authenticationPrivateKey".toByteArray())
encryptionPrivateKey =
SerialBlob("encryptionPrivateKey".toByteArray())
}
- assert(EbicsSubscriberEntity.findById("123asdf") != null)
+ EbicsAccountInfoEntity.new(id = "acctid") {
+ subscriber = subscriberEntity
+ accountHolder = "Account Holder"
+ iban = "IBAN"
+ bankCode = "BIC"
+ }
}
}
@Test
- fun testPain001() {
- createPain001entry(
- Pain001Entry(
- debtorAccountId = "da",
- creditorBic = "cb",
- creditorIban = "ci",
- creditorName = "cn",
- sum = Amount(2),
- subject = "s"
- )
- )
+ fun testPain001document() {
+ transaction {
+ val pain001Entity = Pain001Entity.new {
+ sum = Amount(1)
+ debtorAccount = "acctid"
+ subject = "subject line"
+ creditorIban = "CREDIT IBAN"
+ creditorBic = "CREDIT BIC"
+ creditorName = "CREDIT NAME"
+ }
+ val s = createPain001document(pain001Entity)
+ println(s)
+ }
}
}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
address@hidden.