commit 574db786cd75b055df6e633aaac58dbd6355dadb
parent f801adf2769c29b65a67d6a9f626617c597bd611
Author: MS <ms@taler.net>
Date: Tue, 7 Jul 2020 17:48:54 +0200
Get CAMT.053 validation test to pass.
Diffstat:
4 files changed, 50 insertions(+), 13 deletions(-)
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
@@ -212,9 +212,6 @@ fun buildCamtString(type: Int, subscriberIban: String, history: MutableList<RawP
text("Debitor/Owner Name")
}
element("Svcr/FinInstnId") {
- element("BIC") {
- text("Owner Bic")
- }
element("Nm") {
text("Libeufin Bank")
}
@@ -242,7 +239,9 @@ fun buildCamtString(type: Int, subscriberIban: String, history: MutableList<RawP
text(Amount(0).toPlainString())
}
element("CdtDbtInd") {
- text("UNUSED")
+ // a temporary value to get the camt to validate.
+ // Should be fixed along #6269
+ text("CRDT")
}
element("Dt/Dt") {
// date of this balance
@@ -261,8 +260,9 @@ fun buildCamtString(type: Int, subscriberIban: String, history: MutableList<RawP
text(Amount(0).toPlainString())
}
element("CdtDbtInd") {
- // CRDT or DBIT here
- text("UNUSED")
+ // a temporary value to get the camt to validate.
+ // Should be fixed along #6269
+ text("DBIT")
}
element("Dt/Dt") {
text(dashedDate)
@@ -396,9 +396,6 @@ fun buildCamtString(type: Int, subscriberIban: String, history: MutableList<RawP
element("RmtInf/Ustrd") {
text(it.subject)
}
- element("AddtlNtryInf") {
- text("additional information not given")
- }
}
}
}
diff --git a/sandbox/src/test/kotlin/CamtTest.kt b/sandbox/src/test/kotlin/CamtTest.kt
@@ -0,0 +1,33 @@
+import org.junit.Test
+import tech.libeufin.sandbox.buildCamtString
+import tech.libeufin.util.RawPayment
+import tech.libeufin.util.XMLUtil
+import kotlin.test.assertTrue
+
+class CamtTest {
+
+ @Test
+ fun camtTest() {
+ val payment = RawPayment(
+ creditorIban = "GB33BUKB20201222222222",
+ creditorName = "Oliver Smith",
+ creditorBic = "BUKBGB33",
+ debitorIban = "GB33BUKB20201333333333",
+ debitorName = "John Doe",
+ debitorBic = "BUKBGB33",
+ amount = "2",
+ currency = "EUR",
+ subject = "reimbursement",
+ date = "1000-02-02",
+ uid = 0
+ )
+ val xml = buildCamtString(
+ 53,
+ "GB33BUKB20201222222222",
+ mutableListOf(payment)
+ )
+ assertTrue {
+ XMLUtil.validateFromString(xml.get(0))
+ }
+ }
+}
+\ No newline at end of file
diff --git a/util/src/main/kotlin/JSON.kt b/util/src/main/kotlin/JSON.kt
@@ -26,14 +26,14 @@ package tech.libeufin.util
*/
data class RawPayment(
val creditorIban: String,
- val creditorBic: String?,
+ val creditorBic: String? = null,
val creditorName: String,
val debitorIban: String,
- val debitorBic: String?,
+ val debitorBic: String? = null,
val debitorName: String,
val amount: String,
val currency: String,
val subject: String,
- val date: String?,
+ val date: String? = null,
val uid: Int? = null
)
\ No newline at end of file
diff --git a/util/src/main/kotlin/XMLUtil.kt b/util/src/main/kotlin/XMLUtil.kt
@@ -153,7 +153,13 @@ class XMLUtil private constructor() {
return DOMInputImpl(publicId, systemId, baseUri, res, "UTF-8")
}
}
- val schemaInputs: Array<Source> = listOf("xsd/ebics_H004.xsd", "xsd/ebics_hev.xsd").map {
+ val schemaInputs: Array<Source> = listOf(
+ "xsd/ebics_H004.xsd",
+ "xsd/ebics_hev.xsd",
+ "xsd/camt.052.001.02.xsd",
+ "xsd/camt.053.001.02.xsd",
+ "xsd/camt.054.001.02.xsd"
+ ).map {
val stream =
classLoader.getResourceAsStream(it) ?: throw FileNotFoundException("Schema file $it not found.")
StreamSource(stream)