2019-10-05 00:27:24 +00:00
|
|
|
package net.dankito.fints
|
|
|
|
|
2019-10-12 22:49:49 +00:00
|
|
|
import net.dankito.fints.messages.datenelemente.abgeleiteteformate.Datum
|
2019-10-05 00:27:24 +00:00
|
|
|
import net.dankito.fints.messages.datenelemente.abgeleiteteformate.Laenderkennzeichen
|
|
|
|
import net.dankito.fints.messages.datenelemente.implementierte.Dialogsprache
|
2020-01-26 11:02:09 +00:00
|
|
|
import net.dankito.fints.messages.datenelemente.implementierte.signatur.Sicherheitsfunktion
|
2019-10-05 00:27:24 +00:00
|
|
|
import net.dankito.fints.model.*
|
2020-01-20 23:54:06 +00:00
|
|
|
import net.dankito.fints.response.segments.AccountType
|
2019-12-30 21:30:53 +00:00
|
|
|
import net.dankito.fints.response.segments.ChangeTanMediaParameters
|
|
|
|
import net.dankito.fints.response.segments.JobParameters
|
2020-05-16 15:55:01 +00:00
|
|
|
import java.io.File
|
2019-10-12 22:49:49 +00:00
|
|
|
import java.math.BigDecimal
|
2020-05-16 15:55:01 +00:00
|
|
|
import java.nio.charset.Charset
|
2019-10-05 15:20:49 +00:00
|
|
|
import java.util.*
|
2019-10-05 00:27:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
abstract class FinTsTestBase {
|
|
|
|
|
|
|
|
companion object {
|
2020-05-16 15:55:01 +00:00
|
|
|
|
|
|
|
const val TestFilesFolderName = "test_files/"
|
|
|
|
|
|
|
|
const val TransactionsMt940Filename = "TransactionsMt940.txt"
|
|
|
|
|
|
|
|
|
2019-10-05 00:27:24 +00:00
|
|
|
const val BankCode = "12345678"
|
|
|
|
|
2019-10-17 13:13:02 +00:00
|
|
|
const val BankCountryCode = Laenderkennzeichen.Germany
|
2019-10-16 14:47:00 +00:00
|
|
|
|
2019-10-17 13:13:02 +00:00
|
|
|
const val BankFinTsServerAddress = "banking.supi-dupi-bank.de/fints30"
|
2019-10-16 14:47:00 +00:00
|
|
|
|
2019-10-20 22:56:44 +00:00
|
|
|
val Bank = BankData(BankCode, BankCountryCode, "", "")
|
2019-10-05 00:27:24 +00:00
|
|
|
|
|
|
|
const val CustomerId = "0987654321"
|
|
|
|
|
|
|
|
const val Pin = "12345"
|
|
|
|
|
2019-10-17 13:13:02 +00:00
|
|
|
const val Iban = "DE11$BankCode$CustomerId"
|
|
|
|
|
|
|
|
const val Bic = "ABCDDEMM123"
|
|
|
|
|
2019-10-05 00:27:24 +00:00
|
|
|
val Language = Dialogsprache.German
|
|
|
|
|
2020-01-26 11:02:09 +00:00
|
|
|
val SecurityFunction = Sicherheitsfunktion.PIN_TAN_910
|
2019-10-05 00:27:24 +00:00
|
|
|
|
2019-10-12 23:34:24 +00:00
|
|
|
const val ControlReference = "4477"
|
2019-10-05 00:27:24 +00:00
|
|
|
|
2020-04-30 15:16:55 +00:00
|
|
|
val Customer = CustomerData(CustomerId, Pin, selectedTanProcedure = TanProcedure("chipTAN-optisch", SecurityFunction, TanProcedureType.ChipTanFlickercode), selectedLanguage = Language)
|
2019-10-05 00:27:24 +00:00
|
|
|
|
2020-01-20 23:54:06 +00:00
|
|
|
val Currency = "EUR"
|
|
|
|
|
|
|
|
val AccountHolderName = "Martina Musterfrau"
|
|
|
|
|
|
|
|
val Account = AccountData(CustomerId, null, BankCountryCode, BankCode, Iban, CustomerId, AccountType.Girokonto, Currency, AccountHolderName, null, null, listOf(), listOf())
|
|
|
|
|
2019-10-05 00:27:24 +00:00
|
|
|
const val ProductName = "FinTS-TestClient25Stellen"
|
|
|
|
|
|
|
|
const val ProductVersion = "1"
|
|
|
|
|
|
|
|
val Product = ProductData(ProductName, ProductVersion)
|
|
|
|
|
|
|
|
const val Date = 19880327
|
|
|
|
|
|
|
|
const val Time = 182752
|
2019-12-30 21:30:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
init {
|
|
|
|
Bank.changeTanMediumParameters = ChangeTanMediaParameters(JobParameters("", 1, 1, 1, ":0:0"), false, false, false, false, false, listOf())
|
|
|
|
}
|
2019-10-05 00:27:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-10-05 15:20:49 +00:00
|
|
|
protected open fun createDialogId(): String {
|
|
|
|
return UUID.randomUUID().toString().replace("-", "")
|
|
|
|
}
|
|
|
|
|
2019-10-12 22:49:49 +00:00
|
|
|
protected open fun convertAmount(amount: BigDecimal): String {
|
|
|
|
return amount.toString().replace('.', ',')
|
|
|
|
}
|
|
|
|
|
|
|
|
protected open fun convertDate(date: Date): String {
|
|
|
|
return Datum.HbciDateFormat.format(date)
|
|
|
|
}
|
|
|
|
|
2019-10-13 00:43:28 +00:00
|
|
|
protected open fun unmaskString(string: String): String {
|
|
|
|
return string.replace("?'", "'").replace("?+", "+").replace("?:", ":")
|
|
|
|
}
|
|
|
|
|
2019-10-05 00:27:24 +00:00
|
|
|
protected open fun normalizeBinaryData(message: String): String {
|
|
|
|
return message.replace(0.toChar(), ' ')
|
|
|
|
}
|
|
|
|
|
2019-12-30 21:30:53 +00:00
|
|
|
|
|
|
|
protected open fun createEmptyJobParameters(): JobParameters {
|
|
|
|
return JobParameters("", 1, 1, 1, ":0:0")
|
|
|
|
}
|
|
|
|
|
2020-05-16 15:55:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* testFilename has to be a file in src/test/resources/test_files/ folder
|
|
|
|
*/
|
|
|
|
protected open fun loadTestFile(testFilename: String, charset: Charset = Charsets.UTF_8): String {
|
|
|
|
val fileStream = FinTsTestBase::class.java.classLoader.getResourceAsStream(File(TestFilesFolderName, testFilename).path)
|
|
|
|
|
|
|
|
return fileStream.reader(charset).readText()
|
|
|
|
}
|
|
|
|
|
2019-10-05 00:27:24 +00:00
|
|
|
}
|