diff --git a/build.gradle b/build.gradle index 7fa8a987..20ba19ab 100644 --- a/build.gradle +++ b/build.gradle @@ -4,9 +4,24 @@ ext { appVersionCode = 3 + + /* MPP / basic dependencies */ + kotlinVersion = '1.3.72' kotlinCoroutinesVersion = "1.3.5" + serializationVersion = "0.20.0" + + + ktorVersion = "1.3.1" + + klockVersion = "1.8.4" + + bigNumVersion = "0.1.5" + + uuidVersion = "0.1.0" + + javaUtilsVersion = '1.0.16' luceneUtilsVersion = "0.5.1-SNAPSHOT" @@ -17,6 +32,15 @@ ext { /* Android */ + androidCompileSdkVersion = 28 + + androidBuildToolsVersion = "29.0.3" + + androidMinSdkVersion = 16 + + androidTargetSdkVersion = 28 + + androidUtilsVersion = '1.1.1-SNAPSHOT' materialDrawerVersion = "8.0.1" @@ -44,6 +68,10 @@ ext { /* Test */ junitVersion = '4.12' + junit5Version = '5.5.2' + + atriumVersion = "0.12.0" + assertJVersion = '3.12.2' mockitoVersion = '2.22.0' @@ -54,15 +82,16 @@ ext { } buildscript { - ext.kotlin_version = '1.3.61' + ext.kotlin_version = '1.3.72' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.5.1' + classpath 'com.android.tools.build:gradle:4.0.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" // Nexus staging plugin has to be downgraded to 0.10.0 to be applicable to sub projects, see https://github.com/UweTrottmann/SeriesGuide/commit/ca33e8ad2fa6cc5c426450c8aef3417ba073ca7f classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.10.0" diff --git a/fints4k-jvm/build.gradle b/fints4k-jvm/build.gradle new file mode 100644 index 00000000..23bfc960 --- /dev/null +++ b/fints4k-jvm/build.gradle @@ -0,0 +1,10 @@ +apply plugin: 'java-library' +apply plugin: 'kotlin' + +sourceCompatibility = "8" +targetCompatibility = "8" + + +dependencies { + api project(":fints4k") +} \ No newline at end of file diff --git a/fints4k/build.gradle b/fints4k/build.gradle index f731f053..e3d5932d 100644 --- a/fints4k/build.gradle +++ b/fints4k/build.gradle @@ -1,36 +1,144 @@ -apply plugin: 'java-library' -apply plugin: 'kotlin' +buildscript { + repositories { + jcenter() + } +} -sourceCompatibility = "1.7" -targetCompatibility = "1.7" - -compileKotlin.kotlinOptions.jvmTarget = "1.6" - -compileTestKotlin.kotlinOptions.jvmTarget = "1.8" +plugins { + id "org.jetbrains.kotlin.multiplatform" + id "org.jetbrains.kotlin.plugin.serialization" + id "com.android.library" +} -dependencies { - api "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion" - - api "net.dankito.utils:java-utils:$javaUtilsVersion" - - implementation "net.dankito.search:lucene-4-utils:$luceneUtilsVersion" - - - testImplementation "junit:junit:$junitVersion" - testImplementation "org.assertj:assertj-core:$assertJVersion" - - testImplementation "org.mockito:mockito-core:$mockitoVersion" - testImplementation "com.nhaarman:mockito-kotlin:$mockitoKotlinVersion" // so that Mockito.any() doesn't return null which null-safe Kotlin parameter don't like - // for how to enable mocking final class (which is standard in Kotlin) with Mockito see https://github.com/mockito/mockito/wiki/What's-new-in-Mockito-2#mock-the-unmockable-opt-in-mocking-of-final-classesmethods - - testImplementation "ch.qos.logback:logback-classic:$logbackVersion" - - testImplementation("net.dankito.utils:java-fx-utils:$javaFxUtilsVersion") { - exclude group: "org.controlsfx" +kotlin { + jvm("jvm6") { + compilations.main.kotlinOptions { + jvmTarget = "1.6" + } + } + + android() + + + sourceSets { + commonMain { + dependencies { + implementation kotlin("stdlib-common") + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$kotlinCoroutinesVersion" + + implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$serializationVersion" + + implementation "io.ktor:ktor-client-core:$ktorVersion" +// +// implementation("io.ktor:ktor-client-serialization:$ktor_version") + + api "com.soywiz.korlibs.klock:klock:$klockVersion" + + api("com.ionspin.kotlin:bignum:$bigNumVersion") + + implementation "com.benasher44:uuid:$uuidVersion" + } + } + + commonTest { + dependencies { + implementation kotlin("test-common") + implementation kotlin("test-annotations-common") + + + implementation project(":BankingUiCommon") + implementation project(":BankFinder") + implementation project(":fints4kBankingClient") + + implementation "ch.tutteli.atrium:atrium-fluent-en_GB:$atriumVersion" + } + } + + + jvm6Main { + dependencies { +// implementation "io.ktor:ktor-client-cio:$ktorVersion" + implementation "io.ktor:ktor-client-okhttp:$ktorVersion" + + implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serializationVersion" + + api "com.soywiz.korlibs.klock:klock-jvm:$klockVersion" + + implementation "org.slf4j:slf4j-api:$slf4jVersion" + } + } + + jvm6Test { + dependencies { + implementation kotlin("test-junit") + + implementation "org.junit.jupiter:junit-jupiter:$junit5Version" + runtimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit5Version" + + implementation "org.assertj:assertj-core:$assertJVersion" + implementation "org.mockito:mockito-core:$mockitoVersion" + + + implementation "org.apache.commons:commons-csv:1.8" + + implementation "org.slf4j:slf4j-simple:$slf4jVersion" + } + + } + + + androidMain { + dependsOn jvm6Main + + dependencies { + implementation "io.ktor:ktor-client-android:$ktorVersion" + } + } + + } +} + + +android { + compileSdkVersion androidCompileSdkVersion + + + defaultConfig { + minSdkVersion androidMinSdkVersion + targetSdkVersion androidTargetSdkVersion + + versionName version + versionCode appVersionCode + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + packagingOptions { + pickFirst 'META-INF/ktor-http.kotlin_module' + pickFirst 'META-INF/kotlinx-io.kotlin_module' + pickFirst 'META-INF/atomicfu.kotlin_module' + pickFirst 'META-INF/ktor-utils.kotlin_module' + pickFirst 'META-INF/kotlinx-coroutines-io.kotlin_module' + pickFirst 'META-INF/ktor-client-core.kotlin_module' + pickFirst 'META-INF/DEPENDENCIES' + pickFirst 'META-INF/NOTICE' + pickFirst 'META-INF/LICENSE' + pickFirst 'META-INF/LICENSE.txt' + pickFirst 'META-INF/NOTICE.txt' + } + + lintOptions { + abortOnError false } - testImplementation "org.apache.commons:commons-csv:1.8" } \ No newline at end of file diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/FinTsClient.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/FinTsClient.kt similarity index 96% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/FinTsClient.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/FinTsClient.kt index e59e48ea..a8c6a9ba 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/FinTsClient.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/FinTsClient.kt @@ -1,5 +1,8 @@ package net.dankito.banking.fints +import com.soywiz.klock.DateTime +import com.soywiz.klock.DateTimeSpan +import com.soywiz.klock.DateTimeTz import net.dankito.banking.fints.callback.FinTsClientCallback import net.dankito.banking.fints.messages.MessageBuilder import net.dankito.banking.fints.messages.MessageBuilderResult @@ -25,43 +28,37 @@ import net.dankito.banking.fints.tan.TanImageDecoder import net.dankito.banking.fints.transactions.IAccountTransactionsParser import net.dankito.banking.fints.transactions.Mt940AccountTransactionsParser import net.dankito.banking.fints.util.IBase64Service -import net.dankito.utils.IThreadPool -import net.dankito.utils.ThreadPool -import net.dankito.utils.web.client.IWebClient -import net.dankito.utils.web.client.OkHttpWebClient -import net.dankito.utils.web.client.RequestParameters -import net.dankito.utils.web.client.WebClientResponse -import org.slf4j.LoggerFactory -import java.math.BigDecimal -import java.util.* -import java.util.concurrent.CopyOnWriteArrayList +import net.dankito.banking.fints.util.IThreadPool +import net.dankito.banking.fints.util.PureKotlinBase64Service +import net.dankito.banking.fints.util.log.LoggerFactory +import net.dankito.banking.fints.webclient.IWebClient +import net.dankito.banking.fints.webclient.KtorWebClient +import net.dankito.banking.fints.webclient.WebClientResponse -open class FinTsClient @JvmOverloads constructor( +open class FinTsClient( protected val callback: FinTsClientCallback, - protected val base64Service: IBase64Service, - protected val webClient: IWebClient = OkHttpWebClient(), + protected val webClient: IWebClient = KtorWebClient(), + protected val base64Service: IBase64Service = PureKotlinBase64Service(), + protected val threadPool: IThreadPool, protected val messageBuilder: MessageBuilder = MessageBuilder(), protected val responseParser: ResponseParser = ResponseParser(), protected val mt940Parser: IAccountTransactionsParser = Mt940AccountTransactionsParser(), - protected val threadPool: IThreadPool = ThreadPool(), protected val product: ProductData = ProductData("15E53C26816138699C7B6A3E8", "1.0.0") // TODO: get version dynamically ) { companion object { - const val NinetyDaysAgoMilliseconds = 90 * 24 * 60 * 60 * 1000L - val FindAccountTransactionsStartRegex = Regex("^HIKAZ:\\d:\\d:\\d\\+@\\d+@", RegexOption.MULTILINE) val FindAccountTransactionsEndRegex = Regex("^-'", RegexOption.MULTILINE) - private val log = LoggerFactory.getLogger(FinTsClient::class.java) + private val log = LoggerFactory.getLogger(FinTsClient::class) } open var areWeThatGentleToCloseDialogs: Boolean = true - protected val messageLogField = CopyOnWriteArrayList() + protected val messageLogField = ArrayList() // TODO: make thread safe like with CopyOnWriteArrayList // in either case remove sensitive data after response is parsed as otherwise some information like account holder name and accounts may is not set yet on CustomerData open val messageLogWithoutSensitiveData: List @@ -215,7 +212,7 @@ open class FinTsClient @JvmOverloads constructor( // also check if retrieving account transactions of last 90 days without tan is supported (and thereby may retrieve first account transactions) val transactionsOfLast90DaysResponses = mutableListOf() - val balances = mutableMapOf() + val balances = mutableMapOf() customer.accounts.forEach { account -> if (account.supportsFeature(AccountFeature.RetrieveAccountTransactions)) { val response = tryGetTransactionsOfLast90DaysWithoutTan(bank, customer, account, false) @@ -252,10 +249,10 @@ open class FinTsClient @JvmOverloads constructor( protected open fun tryGetTransactionsOfLast90DaysWithoutTan(bank: BankData, customer: CustomerData, account: AccountData, hasRetrievedTransactionsWithTanJustBefore: Boolean): GetTransactionsResponse { - val now = Date() - val ninetyDaysAgo = Date(now.time - NinetyDaysAgoMilliseconds - now.timezoneOffset * 60 * 1000) // map to UTC + val now = DateTimeTz.nowLocal() + val ninetyDaysAgo = now.minus(DateTimeSpan(days = 90)) - val response = getTransactions(GetTransactionsParameter(account.supportsFeature(AccountFeature.RetrieveBalance), ninetyDaysAgo, abortIfTanIsRequired = true), bank, customer, account) + val response = getTransactions(GetTransactionsParameter(account.supportsFeature(AccountFeature.RetrieveBalance), ninetyDaysAgo.local.date, abortIfTanIsRequired = true), bank, customer, account) account.triedToRetrieveTransactionsOfLast90DaysWithoutTan = true @@ -290,7 +287,7 @@ open class FinTsClient @JvmOverloads constructor( } - var balance: BigDecimal? = null + var balance: Money? = null if (parameter.alsoRetrieveBalance && account.supportsFeature(AccountFeature.RetrieveBalance)) { val balanceResponse = getBalanceAfterDialogInit(account, dialogContext) @@ -301,7 +298,7 @@ open class FinTsClient @JvmOverloads constructor( } balanceResponse.getFirstSegmentById(InstituteSegmentId.Balance)?.let { - balance = it.balance + balance = Money(it.balance, it.currency) } } @@ -576,9 +573,7 @@ open class FinTsClient @JvmOverloads constructor( protected open fun getResponseForMessage(requestBody: String, finTs3ServerAddress: String): WebClientResponse { val encodedRequestBody = base64Service.encode(requestBody) - return webClient.post( - RequestParameters(finTs3ServerAddress, encodedRequestBody, "application/octet-stream") - ) + return webClient.post(finTs3ServerAddress, encodedRequestBody, "application/octet-stream") } protected open fun fireAndForgetMessage(message: MessageBuilderResult, dialogContext: DialogContext) { @@ -594,7 +589,7 @@ open class FinTsClient @JvmOverloads constructor( protected open fun handleResponse(webResponse: WebClientResponse, dialogContext: DialogContext): Response { val responseBody = webResponse.body - if (webResponse.isSuccessful && responseBody != null) { + if (webResponse.successful && responseBody != null) { try { val decodedResponse = decodeBase64Response(responseBody) @@ -603,14 +598,14 @@ open class FinTsClient @JvmOverloads constructor( return responseParser.parse(decodedResponse) } catch (e: Exception) { - log.error("Could not decode responseBody:\r\n'$responseBody'", e) + log.error(e) { "Could not decode responseBody:\r\n'$responseBody'" } return Response(false, exception = e) } } else { val bank = dialogContext.bank - log.error("Request to $bank (${bank.finTs3ServerAddress}) failed", webResponse.error) + log.error { "Request to $bank (${bank.finTs3ServerAddress}) failed" } // TODO: add webResponse.error } return Response(false, exception = webResponse.error) @@ -633,14 +628,12 @@ open class FinTsClient @JvmOverloads constructor( protected open fun addMessageLog(message: String, type: MessageLogEntryType, dialogContext: DialogContext) { - val timeStamp = Date() + val timeStamp = DateTime.now() val messagePrefix = "${if (type == MessageLogEntryType.Sent) "Sending" else "Received"} message:\r\n" // currently no need to translate val prettyPrintMessage = prettyPrintHbciMessage(message) val prettyPrintMessageWithPrefix = "$messagePrefix$prettyPrintMessage" - if (log.isDebugEnabled) { - log.debug(prettyPrintMessageWithPrefix) - } + log.debug { prettyPrintMessageWithPrefix } messageLogField.add(MessageLogEntry(prettyPrintMessageWithPrefix, timeStamp, dialogContext.customer)) } diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/FinTsClientForCustomer.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/FinTsClientForCustomer.kt similarity index 76% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/FinTsClientForCustomer.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/FinTsClientForCustomer.kt index 734db0d1..1095a360 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/FinTsClientForCustomer.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/FinTsClientForCustomer.kt @@ -10,26 +10,26 @@ import net.dankito.banking.fints.response.client.GetTransactionsResponse import net.dankito.banking.fints.transactions.IAccountTransactionsParser import net.dankito.banking.fints.transactions.Mt940AccountTransactionsParser import net.dankito.banking.fints.util.IBase64Service -import net.dankito.utils.IThreadPool -import net.dankito.utils.ThreadPool -import net.dankito.utils.web.client.IWebClient -import net.dankito.utils.web.client.OkHttpWebClient +import net.dankito.banking.fints.util.IThreadPool +import net.dankito.banking.fints.util.PureKotlinBase64Service +import net.dankito.banking.fints.webclient.IWebClient +import net.dankito.banking.fints.webclient.KtorWebClient -open class FinTsClientForCustomer @JvmOverloads constructor( +open class FinTsClientForCustomer( val bank: BankData, val customer: CustomerData, - webClient: IWebClient = OkHttpWebClient(), - base64Service: IBase64Service, - threadPool: IThreadPool = ThreadPool(), callback: FinTsClientCallback, + webClient: IWebClient = KtorWebClient(), + base64Service: IBase64Service = PureKotlinBase64Service(), + threadPool: IThreadPool, messageBuilder: MessageBuilder = MessageBuilder(), responseParser: ResponseParser = ResponseParser(), mt940Parser: IAccountTransactionsParser = Mt940AccountTransactionsParser(), product: ProductData = ProductData("15E53C26816138699C7B6A3E8", "1.0.0") // TODO: get version dynamically ) { - protected val client = FinTsClient(callback, base64Service, webClient, messageBuilder, responseParser, mt940Parser, threadPool, product) + protected val client = FinTsClient(callback, webClient, base64Service, threadPool, messageBuilder, responseParser, mt940Parser, product) open val messageLogWithoutSensitiveData: List diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/callback/FinTsClientCallback.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/callback/FinTsClientCallback.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/callback/FinTsClientCallback.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/callback/FinTsClientCallback.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/callback/NoOpFinTsClientCallback.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/callback/NoOpFinTsClientCallback.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/callback/NoOpFinTsClientCallback.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/callback/NoOpFinTsClientCallback.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/callback/SimpleFinTsClientCallback.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/callback/SimpleFinTsClientCallback.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/callback/SimpleFinTsClientCallback.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/callback/SimpleFinTsClientCallback.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/Existenzstatus.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/Existenzstatus.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/Existenzstatus.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/Existenzstatus.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/HbciCharset.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/HbciCharset.kt similarity index 96% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/HbciCharset.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/HbciCharset.kt index 0106b80a..05c210ae 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/HbciCharset.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/HbciCharset.kt @@ -1,5 +1,7 @@ package net.dankito.banking.fints.messages +import io.ktor.utils.io.charsets.Charsets + /** * Der HBCI-Basiszeichensatz baut auf dem international normierten Zeichensatz ISO 8859 auf. diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/MessageBuilder.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/MessageBuilder.kt similarity index 97% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/MessageBuilder.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/MessageBuilder.kt index d02df6e0..3898f9db 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/MessageBuilder.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/MessageBuilder.kt @@ -1,5 +1,6 @@ package net.dankito.banking.fints.messages +import com.soywiz.klock.DateTime import net.dankito.banking.fints.messages.datenelemente.implementierte.Aufsetzpunkt import net.dankito.banking.fints.messages.datenelemente.implementierte.KundensystemID import net.dankito.banking.fints.messages.datenelemente.implementierte.Synchronisierungsmodus @@ -22,7 +23,7 @@ import net.dankito.banking.fints.response.segments.JobParameters import net.dankito.banking.fints.response.segments.SepaAccountInfoParameters import net.dankito.banking.fints.response.segments.TanResponse import net.dankito.banking.fints.util.FinTsUtils -import net.dankito.utils.extensions.containsAny +import kotlin.math.absoluteValue import kotlin.random.Random @@ -356,7 +357,7 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg } protected open fun createControlReference(): String { - return Math.abs(Random(System.nanoTime()).nextInt()).toString() + return Random(DateTime.nowUnixLong()).nextInt().absoluteValue.toString() } @@ -442,4 +443,16 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg } } + + // TODO: move to a library + fun Collection.containsAny(otherCollection: Collection): Boolean { + for (otherItem in otherCollection) { + if (this.contains(otherItem)) { + return true + } + } + + return false + } + } \ No newline at end of file diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/MessageBuilderResult.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/MessageBuilderResult.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/MessageBuilderResult.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/MessageBuilderResult.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/Nachrichtenteil.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/Nachrichtenteil.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/Nachrichtenteil.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/Nachrichtenteil.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/Separators.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/Separators.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/Separators.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/Separators.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/Datenelement.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/Datenelement.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/Datenelement.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/Datenelement.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/DatenelementBase.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/DatenelementBase.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/DatenelementBase.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/DatenelementBase.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/abgeleiteteformate/Code.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/abgeleiteteformate/Code.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/abgeleiteteformate/Code.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/abgeleiteteformate/Code.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/abgeleiteteformate/Datum.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/abgeleiteteformate/Datum.kt similarity index 52% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/abgeleiteteformate/Datum.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/abgeleiteteformate/Datum.kt index 540de203..c29a6842 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/abgeleiteteformate/Datum.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/abgeleiteteformate/Datum.kt @@ -1,9 +1,10 @@ package net.dankito.banking.fints.messages.datenelemente.abgeleiteteformate +import com.soywiz.klock.Date +import com.soywiz.klock.DateFormat +import com.soywiz.klock.parse import net.dankito.banking.fints.messages.Existenzstatus import net.dankito.banking.fints.messages.datenelemente.basisformate.NumerischesDatenelement -import java.text.SimpleDateFormat -import java.util.* /** @@ -16,11 +17,20 @@ open class Datum(date: Int?, existenzstatus: Existenzstatus) : NumerischesDatene companion object { const val HbciDateFormatString = "yyyyMMdd" - val HbciDateFormat = SimpleDateFormat(HbciDateFormatString) + val HbciDateFormat = DateFormat(HbciDateFormatString) + + + fun format(date: Date): String { + return HbciDateFormat.format(date.dateTimeDayStart.localUnadjusted) // TODO: is this correct? + } + + fun parse(dateString: String): Date { + return HbciDateFormat.parse(dateString).utc.date // TODO: really use UTC? + } } constructor(date: Date?, existenzstatus: Existenzstatus) - : this(date?.let { HbciDateFormat.format(it).toInt() }, existenzstatus) + : this(date?.let { format(it).toInt() }, existenzstatus) } \ No newline at end of file diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/abgeleiteteformate/Identifikation.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/abgeleiteteformate/Identifikation.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/abgeleiteteformate/Identifikation.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/abgeleiteteformate/Identifikation.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/abgeleiteteformate/JaNein.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/abgeleiteteformate/JaNein.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/abgeleiteteformate/JaNein.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/abgeleiteteformate/JaNein.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/abgeleiteteformate/Laenderkennzeichen.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/abgeleiteteformate/Laenderkennzeichen.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/abgeleiteteformate/Laenderkennzeichen.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/abgeleiteteformate/Laenderkennzeichen.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/abgeleiteteformate/Uhrzeit.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/abgeleiteteformate/Uhrzeit.kt similarity index 52% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/abgeleiteteformate/Uhrzeit.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/abgeleiteteformate/Uhrzeit.kt index 10ba572f..2dfea695 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/abgeleiteteformate/Uhrzeit.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/abgeleiteteformate/Uhrzeit.kt @@ -1,9 +1,8 @@ package net.dankito.banking.fints.messages.datenelemente.abgeleiteteformate +import com.soywiz.klock.* import net.dankito.banking.fints.messages.Existenzstatus import net.dankito.banking.fints.messages.datenelemente.basisformate.ZiffernDatenelement -import java.text.SimpleDateFormat -import java.util.* /** @@ -17,11 +16,20 @@ open class Uhrzeit(time: Int?, existenzstatus: Existenzstatus) : ZiffernDatenele companion object { const val HbciTimeFormatString = "HHmmss" - val HbciTimeFormat = SimpleDateFormat(HbciTimeFormatString) + val HbciTimeFormat = DateFormat(HbciTimeFormatString) + + + fun format(time: Time): String { + return HbciTimeFormat.format(DateTimeTz.Companion.fromUnixLocal(time.encoded.milliseconds)) // TODO: is this correct? + } + + fun parse(dateString: String): Time { + return HbciTimeFormat.parse(dateString).utc.time // TODO: is this correct? + } } - constructor(time: Date?, existenzstatus: Existenzstatus) - : this(time?.let { HbciTimeFormat.format(it).toInt() }, existenzstatus) + constructor(time: Time?, existenzstatus: Existenzstatus) + : this(time?.let { format(time).toInt() }, existenzstatus) } \ No newline at end of file diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/basisformate/AlphanumerischesDatenelement.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/basisformate/AlphanumerischesDatenelement.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/basisformate/AlphanumerischesDatenelement.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/basisformate/AlphanumerischesDatenelement.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/basisformate/BinaerDatenelement.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/basisformate/BinaerDatenelement.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/basisformate/BinaerDatenelement.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/basisformate/BinaerDatenelement.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/basisformate/NumerischesDatenelement.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/basisformate/NumerischesDatenelement.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/basisformate/NumerischesDatenelement.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/basisformate/NumerischesDatenelement.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/basisformate/TextDatenelement.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/basisformate/TextDatenelement.kt similarity index 76% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/basisformate/TextDatenelement.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/basisformate/TextDatenelement.kt index 8dd75f43..b943304d 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/basisformate/TextDatenelement.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/basisformate/TextDatenelement.kt @@ -1,5 +1,7 @@ package net.dankito.banking.fints.messages.datenelemente.basisformate +import io.ktor.utils.io.charsets.encode +import io.ktor.utils.io.charsets.name import net.dankito.banking.fints.messages.Existenzstatus import net.dankito.banking.fints.messages.HbciCharset import net.dankito.banking.fints.messages.Separators @@ -35,8 +37,10 @@ abstract class TextDatenelement(var value: String?, existenzstatus: Existenzstat checkIfMandatoryValueIsSet() try { - if (HbciCharset.DefaultCharset.newEncoder().canEncode(value) == false) { - throwInvalidCharacterException() + value?.let { // at this time value is != null otherwise checkIfMandatoryValueIsSet() would fail + if (HbciCharset.DefaultCharset.newEncoder().encode(it).canRead() == false) { + throwInvalidCharacterException() + } } } catch (e: Exception) { throwInvalidCharacterException() @@ -46,14 +50,14 @@ abstract class TextDatenelement(var value: String?, existenzstatus: Existenzstat protected open fun checkIfMandatoryValueIsSet() { if (existenzstatus == Existenzstatus.Mandatory && value == null) { - throwValidationException("Wert ist auf dem Pflichtfeld ${javaClass.simpleName} not set") + throwValidationException("Wert ist auf dem Pflichtfeld ${this::class.simpleName} not set") } } protected open fun throwInvalidCharacterException() { throwValidationException( "Wert '$value' enthält Zeichen die gemäß des Zeichensatzes " + - "${HbciCharset.DefaultCharset.displayName()} nicht erlaubt sind." + "${HbciCharset.DefaultCharset.name} nicht erlaubt sind." ) } diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/basisformate/ZiffernDatenelement.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/basisformate/ZiffernDatenelement.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/basisformate/ZiffernDatenelement.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/basisformate/ZiffernDatenelement.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Aufsetzpunkt.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Aufsetzpunkt.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Aufsetzpunkt.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Aufsetzpunkt.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/BPDVersion.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/BPDVersion.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/BPDVersion.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/BPDVersion.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Benutzerkennung.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Benutzerkennung.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Benutzerkennung.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Benutzerkennung.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Bezugssegment.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Bezugssegment.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Bezugssegment.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Bezugssegment.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/BezugssegmentInKreditinstitutsnachricht.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/BezugssegmentInKreditinstitutsnachricht.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/BezugssegmentInKreditinstitutsnachricht.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/BezugssegmentInKreditinstitutsnachricht.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/BezugssegmentInKundennachricht.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/BezugssegmentInKundennachricht.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/BezugssegmentInKundennachricht.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/BezugssegmentInKundennachricht.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/DialogId.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/DialogId.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/DialogId.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/DialogId.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Dialogsprache.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Dialogsprache.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Dialogsprache.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Dialogsprache.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/DialogspracheDatenelement.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/DialogspracheDatenelement.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/DialogspracheDatenelement.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/DialogspracheDatenelement.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/DoNotPrintDatenelement.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/DoNotPrintDatenelement.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/DoNotPrintDatenelement.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/DoNotPrintDatenelement.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/HbciVersion.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/HbciVersion.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/HbciVersion.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/HbciVersion.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/HbciVersionDatenelement.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/HbciVersionDatenelement.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/HbciVersionDatenelement.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/HbciVersionDatenelement.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/ICodeEnum.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/ICodeEnum.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/ICodeEnum.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/ICodeEnum.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Kreditinstitutscode.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Kreditinstitutscode.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Kreditinstitutscode.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Kreditinstitutscode.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/KundenID.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/KundenID.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/KundenID.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/KundenID.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/KundensystemID.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/KundensystemID.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/KundensystemID.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/KundensystemID.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/KundensystemStatus.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/KundensystemStatus.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/KundensystemStatus.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/KundensystemStatus.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/KundensystemStatusWerte.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/KundensystemStatusWerte.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/KundensystemStatusWerte.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/KundensystemStatusWerte.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Nachrichtengroesse.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Nachrichtengroesse.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Nachrichtengroesse.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Nachrichtengroesse.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Nachrichtennummer.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Nachrichtennummer.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Nachrichtennummer.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Nachrichtennummer.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/NotAllowedDatenelement.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/NotAllowedDatenelement.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/NotAllowedDatenelement.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/NotAllowedDatenelement.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Produktbezeichnung.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Produktbezeichnung.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Produktbezeichnung.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Produktbezeichnung.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Produktversion.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Produktversion.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Produktversion.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Produktversion.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Segmentkennung.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Segmentkennung.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Segmentkennung.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Segmentkennung.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Segmentnummer.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Segmentnummer.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Segmentnummer.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Segmentnummer.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Segmentversion.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Segmentversion.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Segmentversion.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Segmentversion.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Synchronisierungsmodus.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Synchronisierungsmodus.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Synchronisierungsmodus.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/Synchronisierungsmodus.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/SynchronisierungsmodusDatenelement.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/SynchronisierungsmodusDatenelement.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/SynchronisierungsmodusDatenelement.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/SynchronisierungsmodusDatenelement.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/UPDVersion.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/UPDVersion.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/UPDVersion.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/UPDVersion.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/account/AlleKonten.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/account/AlleKonten.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/account/AlleKonten.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/account/AlleKonten.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/account/BIC.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/account/BIC.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/account/BIC.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/account/BIC.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/account/IBAN.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/account/IBAN.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/account/IBAN.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/account/IBAN.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/account/KontoDepotnummer.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/account/KontoDepotnummer.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/account/KontoDepotnummer.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/account/KontoDepotnummer.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/account/MaximaleAnzahlEintraege.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/account/MaximaleAnzahlEintraege.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/account/MaximaleAnzahlEintraege.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/account/MaximaleAnzahlEintraege.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/account/Unterkontomerkmal.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/account/Unterkontomerkmal.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/account/Unterkontomerkmal.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/account/Unterkontomerkmal.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/BezeichnerFuerAlgorithmusparameterIV.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/BezeichnerFuerAlgorithmusparameterIV.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/BezeichnerFuerAlgorithmusparameterIV.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/BezeichnerFuerAlgorithmusparameterIV.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/BezeichnerFuerAlgorithmusparameterIVDatenelement.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/BezeichnerFuerAlgorithmusparameterIVDatenelement.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/BezeichnerFuerAlgorithmusparameterIVDatenelement.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/BezeichnerFuerAlgorithmusparameterIVDatenelement.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/BezeichnerFuerAlgorithmusparameterSchluessel.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/BezeichnerFuerAlgorithmusparameterSchluessel.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/BezeichnerFuerAlgorithmusparameterSchluessel.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/BezeichnerFuerAlgorithmusparameterSchluessel.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/BezeichnerFuerAlgorithmusparameterSchluesselDatenelement.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/BezeichnerFuerAlgorithmusparameterSchluesselDatenelement.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/BezeichnerFuerAlgorithmusparameterSchluesselDatenelement.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/BezeichnerFuerAlgorithmusparameterSchluesselDatenelement.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/Komprimierungsfunktion.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/Komprimierungsfunktion.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/Komprimierungsfunktion.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/Komprimierungsfunktion.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/KomprimierungsfunktionDatenelement.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/KomprimierungsfunktionDatenelement.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/KomprimierungsfunktionDatenelement.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/KomprimierungsfunktionDatenelement.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/PinTanVerschluesselteDatenDatenelement.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/PinTanVerschluesselteDatenDatenelement.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/PinTanVerschluesselteDatenDatenelement.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/PinTanVerschluesselteDatenDatenelement.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/Verschluesselungsalgorithmus.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/Verschluesselungsalgorithmus.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/Verschluesselungsalgorithmus.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/Verschluesselungsalgorithmus.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/VerschluesselungsalgorithmusKodiert.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/VerschluesselungsalgorithmusKodiert.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/VerschluesselungsalgorithmusKodiert.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/VerschluesselungsalgorithmusKodiert.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/VerwendungDesVerschluesselungsalgorithmus.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/VerwendungDesVerschluesselungsalgorithmus.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/VerwendungDesVerschluesselungsalgorithmus.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/VerwendungDesVerschluesselungsalgorithmus.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/VerwendungDesVerschluesselungsalgorithmusKodiert.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/VerwendungDesVerschluesselungsalgorithmusKodiert.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/VerwendungDesVerschluesselungsalgorithmusKodiert.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/VerwendungDesVerschluesselungsalgorithmusKodiert.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/WertDesAlgorithmusparametersSchluessel.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/WertDesAlgorithmusparametersSchluessel.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/WertDesAlgorithmusparametersSchluessel.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/encryption/WertDesAlgorithmusparametersSchluessel.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/sepa/SepaMessage.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/sepa/SepaMessage.kt similarity index 61% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/sepa/SepaMessage.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/sepa/SepaMessage.kt index d1e41886..5c0c511c 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/sepa/SepaMessage.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/sepa/SepaMessage.kt @@ -3,14 +3,15 @@ package net.dankito.banking.fints.messages.datenelemente.implementierte.sepa import net.dankito.banking.fints.messages.Existenzstatus import net.dankito.banking.fints.messages.datenelemente.basisformate.BinaerDatenelement import net.dankito.banking.fints.messages.segmente.implementierte.sepa.ISepaMessageCreator +import net.dankito.banking.fints.messages.segmente.implementierte.sepa.PaymentInformationMessages open class SepaMessage( - filename: String, + messageTemplate: PaymentInformationMessages, replacementStrings: Map, messageCreator: ISepaMessageCreator ) - : BinaerDatenelement(messageCreator.createXmlFile(filename, replacementStrings), Existenzstatus.Mandatory) { + : BinaerDatenelement(messageCreator.createXmlFile(messageTemplate, replacementStrings), Existenzstatus.Mandatory) { } diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/BereichDerSicherheitsapplikation.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/BereichDerSicherheitsapplikation.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/BereichDerSicherheitsapplikation.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/BereichDerSicherheitsapplikation.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/BereichDerSicherheitsapplikationKodiert.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/BereichDerSicherheitsapplikationKodiert.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/BereichDerSicherheitsapplikationKodiert.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/BereichDerSicherheitsapplikationKodiert.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/BezeichnerFuerHashalgorithmusparameter.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/BezeichnerFuerHashalgorithmusparameter.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/BezeichnerFuerHashalgorithmusparameter.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/BezeichnerFuerHashalgorithmusparameter.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/BezeichnerFuerSicherheitspartei.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/BezeichnerFuerSicherheitspartei.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/BezeichnerFuerSicherheitspartei.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/BezeichnerFuerSicherheitspartei.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/DatumUndZeitbezeichner.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/DatumUndZeitbezeichner.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/DatumUndZeitbezeichner.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/DatumUndZeitbezeichner.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/DatumUndZeitbezeichnerKodiert.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/DatumUndZeitbezeichnerKodiert.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/DatumUndZeitbezeichnerKodiert.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/DatumUndZeitbezeichnerKodiert.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Hashalgorithmus.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Hashalgorithmus.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Hashalgorithmus.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Hashalgorithmus.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/HashalgorithmusKodiert.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/HashalgorithmusKodiert.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/HashalgorithmusKodiert.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/HashalgorithmusKodiert.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/IdentifizierungDerPartei.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/IdentifizierungDerPartei.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/IdentifizierungDerPartei.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/IdentifizierungDerPartei.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Operationsmodus.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Operationsmodus.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Operationsmodus.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Operationsmodus.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/OperationsmodusKodiert.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/OperationsmodusKodiert.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/OperationsmodusKodiert.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/OperationsmodusKodiert.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/PinOrTan.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/PinOrTan.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/PinOrTan.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/PinOrTan.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/RolleDesSicherheitslieferantenKodiert.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/RolleDesSicherheitslieferantenKodiert.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/RolleDesSicherheitslieferantenKodiert.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/RolleDesSicherheitslieferantenKodiert.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Schluesselart.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Schluesselart.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Schluesselart.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Schluesselart.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/SchluesselartDatenelement.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/SchluesselartDatenelement.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/SchluesselartDatenelement.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/SchluesselartDatenelement.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Schluesselnummer.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Schluesselnummer.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Schluesselnummer.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Schluesselnummer.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Schluesselversion.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Schluesselversion.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Schluesselversion.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Schluesselversion.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Sicherheitsfunktion.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Sicherheitsfunktion.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Sicherheitsfunktion.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Sicherheitsfunktion.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/SicherheitsfunktionKodiert.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/SicherheitsfunktionKodiert.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/SicherheitsfunktionKodiert.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/SicherheitsfunktionKodiert.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/SicherheitsfunktionWhatIsThisShit.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/SicherheitsfunktionWhatIsThisShit.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/SicherheitsfunktionWhatIsThisShit.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/SicherheitsfunktionWhatIsThisShit.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Sicherheitskontrollreferenz.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Sicherheitskontrollreferenz.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Sicherheitskontrollreferenz.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Sicherheitskontrollreferenz.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Sicherheitsreferenznummer.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Sicherheitsreferenznummer.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Sicherheitsreferenznummer.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Sicherheitsreferenznummer.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Sicherheitsverfahren.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Sicherheitsverfahren.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Sicherheitsverfahren.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Sicherheitsverfahren.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/SicherheitsverfahrenCode.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/SicherheitsverfahrenCode.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/SicherheitsverfahrenCode.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/SicherheitsverfahrenCode.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Signaturalgorithmus.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Signaturalgorithmus.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Signaturalgorithmus.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/Signaturalgorithmus.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/SignaturalgorithmusKodiert.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/SignaturalgorithmusKodiert.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/SignaturalgorithmusKodiert.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/SignaturalgorithmusKodiert.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/VersionDesSicherheitsverfahrens.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/VersionDesSicherheitsverfahrens.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/VersionDesSicherheitsverfahrens.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/VersionDesSicherheitsverfahrens.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/VersionDesSicherheitsverfahrensDatenelement.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/VersionDesSicherheitsverfahrensDatenelement.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/VersionDesSicherheitsverfahrensDatenelement.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/VersionDesSicherheitsverfahrensDatenelement.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/VerwendungDesHashalgorithmusKodiert.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/VerwendungDesHashalgorithmusKodiert.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/VerwendungDesHashalgorithmusKodiert.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/VerwendungDesHashalgorithmusKodiert.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/VerwendungDesSignaturalgorithmusKodiert.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/VerwendungDesSignaturalgorithmusKodiert.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/VerwendungDesSignaturalgorithmusKodiert.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/signatur/VerwendungDesSignaturalgorithmusKodiert.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/AllowedTanFormat.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/AllowedTanFormat.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/AllowedTanFormat.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/AllowedTanFormat.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/AuftraggeberkontoErforderlich.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/AuftraggeberkontoErforderlich.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/AuftraggeberkontoErforderlich.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/AuftraggeberkontoErforderlich.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/AuftragsHashwert.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/AuftragsHashwert.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/AuftragsHashwert.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/AuftragsHashwert.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/Auftragsreferenz.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/Auftragsreferenz.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/Auftragsreferenz.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/Auftragsreferenz.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/BezeichnungDesTANMediums.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/BezeichnungDesTANMediums.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/BezeichnungDesTANMediums.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/BezeichnungDesTANMediums.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/BezeichnungDesTanMediumsErforderlich.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/BezeichnungDesTanMediumsErforderlich.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/BezeichnungDesTanMediumsErforderlich.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/BezeichnungDesTanMediumsErforderlich.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/Initialisierungsmodus.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/Initialisierungsmodus.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/Initialisierungsmodus.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/Initialisierungsmodus.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/JobTanConfiguration.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/JobTanConfiguration.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/JobTanConfiguration.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/JobTanConfiguration.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/MobilePhoneTanMedium.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/MobilePhoneTanMedium.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/MobilePhoneTanMedium.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/MobilePhoneTanMedium.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/SmsAbbuchungskontoErforderlich.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/SmsAbbuchungskontoErforderlich.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/SmsAbbuchungskontoErforderlich.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/SmsAbbuchungskontoErforderlich.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TANProzessDatenelement.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TANProzessDatenelement.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TANProzessDatenelement.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TANProzessDatenelement.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanEinsatzOption.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanEinsatzOption.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanEinsatzOption.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanEinsatzOption.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanGeneratorTanMedium.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanGeneratorTanMedium.kt similarity index 93% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanGeneratorTanMedium.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanGeneratorTanMedium.kt index ba158cd3..e7c2f71c 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanGeneratorTanMedium.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanGeneratorTanMedium.kt @@ -1,6 +1,6 @@ package net.dankito.banking.fints.messages.datenelemente.implementierte.tan -import java.util.* +import com.soywiz.klock.Date open class TanGeneratorTanMedium( @@ -17,7 +17,7 @@ open class TanGeneratorTanMedium( override fun equals(other: Any?): Boolean { if (this === other) return true - if (javaClass != other?.javaClass) return false + if (other == null || this::class != other::class) return false if (!super.equals(other)) return false other as TanGeneratorTanMedium diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanMedienArtVersion.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanMedienArtVersion.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanMedienArtVersion.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanMedienArtVersion.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanMedium.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanMedium.kt similarity index 94% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanMedium.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanMedium.kt index 45fadaf7..74cebb69 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanMedium.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanMedium.kt @@ -19,7 +19,7 @@ open class TanMedium( override fun equals(other: Any?): Boolean { if (this === other) return true - if (javaClass != other?.javaClass) return false + if (other == null || this::class != other::class) return false other as TanMedium diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanMediumKlasse.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanMediumKlasse.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanMediumKlasse.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanMediumKlasse.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanMediumStatus.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanMediumStatus.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanMediumStatus.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanMediumStatus.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanProcess.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanProcess.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanProcess.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanProcess.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanZeitUndDialogbezug.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanZeitUndDialogbezug.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanZeitUndDialogbezug.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/TanZeitUndDialogbezug.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/ZkaTanProcedure.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/ZkaTanProcedure.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/ZkaTanProcedure.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/tan/ZkaTanProcedure.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/Datenelementgruppe.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/Datenelementgruppe.kt similarity index 79% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/Datenelementgruppe.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/Datenelementgruppe.kt index 620357f0..489d809c 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/Datenelementgruppe.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/Datenelementgruppe.kt @@ -3,15 +3,13 @@ package net.dankito.banking.fints.messages.datenelementgruppen import net.dankito.banking.fints.messages.Existenzstatus import net.dankito.banking.fints.messages.Separators import net.dankito.banking.fints.messages.datenelemente.DatenelementBase -import java.util.regex.Pattern abstract class Datenelementgruppe(val dataElements: List, existenzstatus: Existenzstatus) : DatenelementBase(existenzstatus) { companion object { - val ReplaceEmptyDataElementsSeparatorsAtEndPattern = - Pattern.compile("${Separators.DataElementsSeparator}*\$") + val ReplaceEmptyDataElementsSeparatorsAtEndPattern = Regex("${Separators.DataElementsSeparator}*\$") } @@ -30,9 +28,7 @@ abstract class Datenelementgruppe(val dataElements: List, exis * Es gelten analog die Ausführungen zur Auslassung von Datenelementen. */ protected open fun cutEmptyDataElementGroupsAtEndOfSegment(formattedDataElementGroup: String): String { - val matcher = ReplaceEmptyDataElementsSeparatorsAtEndPattern.matcher(formattedDataElementGroup) - - return matcher.replaceFirst("") + return ReplaceEmptyDataElementsSeparatorsAtEndPattern.replaceFirst(formattedDataElementGroup, "") } } \ No newline at end of file diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/Kreditinstitutskennung.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/Kreditinstitutskennung.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/Kreditinstitutskennung.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/Kreditinstitutskennung.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/Segmentkopf.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/Segmentkopf.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/Segmentkopf.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/Segmentkopf.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/account/Kontoverbindung.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/account/Kontoverbindung.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/account/Kontoverbindung.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/account/Kontoverbindung.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/account/KontoverbindungInternational.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/account/KontoverbindungInternational.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/account/KontoverbindungInternational.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/account/KontoverbindungInternational.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/encryption/VerschluesselungsalgorithmusDatenelementgruppe.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/encryption/VerschluesselungsalgorithmusDatenelementgruppe.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/encryption/VerschluesselungsalgorithmusDatenelementgruppe.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/encryption/VerschluesselungsalgorithmusDatenelementgruppe.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/signatur/BenutzerdefinierteSignatur.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/signatur/BenutzerdefinierteSignatur.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/signatur/BenutzerdefinierteSignatur.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/signatur/BenutzerdefinierteSignatur.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/signatur/HashalgorithmusDatenelementgruppe.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/signatur/HashalgorithmusDatenelementgruppe.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/signatur/HashalgorithmusDatenelementgruppe.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/signatur/HashalgorithmusDatenelementgruppe.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/signatur/Schluesselname.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/signatur/Schluesselname.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/signatur/Schluesselname.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/signatur/Schluesselname.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/signatur/SicherheitsdatumUndUhrzeit.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/signatur/SicherheitsdatumUndUhrzeit.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/signatur/SicherheitsdatumUndUhrzeit.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/signatur/SicherheitsdatumUndUhrzeit.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/signatur/SicherheitsidentifikationDetails.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/signatur/SicherheitsidentifikationDetails.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/signatur/SicherheitsidentifikationDetails.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/signatur/SicherheitsidentifikationDetails.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/signatur/Sicherheitsprofil.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/signatur/Sicherheitsprofil.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/signatur/Sicherheitsprofil.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/signatur/Sicherheitsprofil.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/signatur/SignaturalgorithmusDatenelementgruppe.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/signatur/SignaturalgorithmusDatenelementgruppe.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/signatur/SignaturalgorithmusDatenelementgruppe.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/signatur/SignaturalgorithmusDatenelementgruppe.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/tan/GueltigkeitsdatumUndUhrzeitFuerChallenge.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/tan/GueltigkeitsdatumUndUhrzeitFuerChallenge.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/tan/GueltigkeitsdatumUndUhrzeitFuerChallenge.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/implementierte/tan/GueltigkeitsdatumUndUhrzeitFuerChallenge.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/ISegmentNumberGenerator.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/ISegmentNumberGenerator.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/ISegmentNumberGenerator.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/ISegmentNumberGenerator.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/Segment.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/Segment.kt similarity index 82% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/Segment.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/Segment.kt index c8626746..8a95751e 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/Segment.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/Segment.kt @@ -4,14 +4,12 @@ import net.dankito.banking.fints.messages.Nachrichtenteil import net.dankito.banking.fints.messages.Separators import net.dankito.banking.fints.messages.datenelemente.DatenelementBase import net.dankito.banking.fints.messages.datenelemente.implementierte.DoNotPrintDatenelement -import java.util.regex.Pattern abstract class Segment(val dataElementsAndGroups: List) : Nachrichtenteil() { companion object { - val ReplaceEmptyDataElementGroupSeparatorsAtEndPattern = - Pattern.compile("\\${Separators.DataElementGroupsSeparator}*\$") + val ReplaceEmptyDataElementGroupSeparatorsAtEndPattern = Regex("\\${Separators.DataElementGroupsSeparator}*\$") } @@ -27,9 +25,7 @@ abstract class Segment(val dataElementsAndGroups: List) : Nach * In diesem Fall wird das Segmentende-Zeichen unmittelbar nach dem letzten mit Inhalt belegten DE angegeben. */ protected open fun cutEmptyDataElementGroupsAtEndOfSegment(formattedSegment: String): String { - val matcher = ReplaceEmptyDataElementGroupSeparatorsAtEndPattern.matcher(formattedSegment) - - return matcher.replaceFirst("") + return ReplaceEmptyDataElementGroupSeparatorsAtEndPattern.replaceFirst(formattedSegment, "") } } \ No newline at end of file diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/SegmentNumberGenerator.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/SegmentNumberGenerator.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/SegmentNumberGenerator.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/SegmentNumberGenerator.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/Synchronisierung.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/Synchronisierung.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/Synchronisierung.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/Synchronisierung.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/id/CustomerSegmentId.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/id/CustomerSegmentId.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/id/CustomerSegmentId.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/id/CustomerSegmentId.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/id/ISegmentId.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/id/ISegmentId.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/id/ISegmentId.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/id/ISegmentId.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/id/MessageSegmentId.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/id/MessageSegmentId.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/id/MessageSegmentId.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/id/MessageSegmentId.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/Dialogende.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/Dialogende.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/Dialogende.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/Dialogende.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/IdentifikationsSegment.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/IdentifikationsSegment.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/IdentifikationsSegment.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/IdentifikationsSegment.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/Nachrichtenabschluss.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/Nachrichtenabschluss.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/Nachrichtenabschluss.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/Nachrichtenabschluss.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/Nachrichtenkopf.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/Nachrichtenkopf.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/Nachrichtenkopf.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/Nachrichtenkopf.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/PinTanSignaturkopf.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/PinTanSignaturkopf.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/PinTanSignaturkopf.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/PinTanSignaturkopf.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/PinTanVerschluesselungskopf.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/PinTanVerschluesselungskopf.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/PinTanVerschluesselungskopf.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/PinTanVerschluesselungskopf.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/Signaturabschluss.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/Signaturabschluss.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/Signaturabschluss.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/Signaturabschluss.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/Signaturkopf.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/Signaturkopf.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/Signaturkopf.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/Signaturkopf.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/Verarbeitungsvorbereitung.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/Verarbeitungsvorbereitung.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/Verarbeitungsvorbereitung.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/Verarbeitungsvorbereitung.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/VerschluesselteDaten.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/VerschluesselteDaten.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/VerschluesselteDaten.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/VerschluesselteDaten.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/Verschluesselungskopf.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/Verschluesselungskopf.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/Verschluesselungskopf.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/Verschluesselungskopf.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/ZweiSchrittTanEinreichung.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/ZweiSchrittTanEinreichung.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/ZweiSchrittTanEinreichung.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/ZweiSchrittTanEinreichung.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/ISepaMessageCreator.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/ISepaMessageCreator.kt similarity index 81% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/ISepaMessageCreator.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/ISepaMessageCreator.kt index 6755cbae..353a2402 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/ISepaMessageCreator.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/ISepaMessageCreator.kt @@ -3,7 +3,7 @@ package net.dankito.banking.fints.messages.segmente.implementierte.sepa interface ISepaMessageCreator { - fun createXmlFile(filename: String, replacementStrings: Map): String + fun createXmlFile(messageTemplate: PaymentInformationMessages, replacementStrings: Map): String fun convertDiacriticsAndReservedXmlCharactersAndCheckIfContainsOnlyAllowedCharacters(stringToTest: String): Boolean { val convertedString = convertDiacriticsAndReservedXmlCharacters(stringToTest) diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/PaymentInformationMessages.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/PaymentInformationMessages.kt new file mode 100644 index 00000000..8dfdec84 --- /dev/null +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/PaymentInformationMessages.kt @@ -0,0 +1,10 @@ +package net.dankito.banking.fints.messages.segmente.implementierte.sepa + + +enum class PaymentInformationMessages(val xmlTemplate: String) { + + Pain_001_001_03("\$MessageId\$\$CreationDateTime\$\$NumberOfTransactions\$\$Amount\$\$DebitorName\$\$PaymentInformationId\$TRF\$NumberOfTransactions\$\$Amount\$SEPA\$RequestedExecutionDate\$\$DebitorName\$\$DebitorIban\$\$DebitorBic\$SLEVNOTPROVIDED\$Amount\$\$CreditorBic\$\$CreditorName\$\$CreditorIban\$\$Usage\$"), + + Pain_001_003_03("\$MessageId\$\$CreationDateTime\$\$NumberOfTransactions\$\$DebitorName\$\$PaymentInformationId\$TRFtrue\$NumberOfTransactions\$\$Amount\$SEPA\$RequestedExecutionDate\$\$DebitorName\$\$DebitorIban\$\$DebitorBic\$SLEVNOTPROVIDED\$Amount\$\$CreditorBic\$\$CreditorName\$\$CreditorIban\$\$Usage\$") + +} \ No newline at end of file diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/SepaBankTransferBase.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/SepaBankTransferBase.kt similarity index 86% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/SepaBankTransferBase.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/SepaBankTransferBase.kt index 94be8f9a..3625e14b 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/SepaBankTransferBase.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/SepaBankTransferBase.kt @@ -21,7 +21,7 @@ open class SepaBankTransferBase( segmentId, 1, sepaDescriptorUrn, - if (sepaDescriptorUrn.contains("pain.001.003.03", true)) "pain.001.003.03.xml" else "pain.001.001.03.xml", + if (sepaDescriptorUrn.contains("pain.001.003.03", true)) PaymentInformationMessages.Pain_001_003_03 else PaymentInformationMessages.Pain_001_001_03, account, debitorBic, mapOf( @@ -32,7 +32,7 @@ open class SepaBankTransferBase( "CreditorName" to messageCreator.convertDiacriticsAndReservedXmlCharacters(data.creditorName), "CreditorIban" to data.creditorIban.replace(" ", ""), "CreditorBic" to data.creditorBic.replace(" ", ""), - "Amount" to data.amount.toString(), // TODO: check if ',' or '.' should be used as decimal separator + "Amount" to data.amount.toStringExpanded(), // TODO: check if ',' or '.' should be used as decimal separator "Usage" to if (data.usage.isEmpty()) " " else messageCreator.convertDiacriticsAndReservedXmlCharacters(data.usage), "RequestedExecutionDate" to RequestedExecutionDateValueForNotScheduledTransfers ), diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/SepaMessageCreator.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/SepaMessageCreator.kt similarity index 73% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/SepaMessageCreator.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/SepaMessageCreator.kt index 0e2ca4f4..95817052 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/SepaMessageCreator.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/SepaMessageCreator.kt @@ -1,11 +1,8 @@ package net.dankito.banking.fints.messages.segmente.implementierte.sepa -import net.dankito.banking.fints.messages.datenelemente.implementierte.sepa.SepaMessage -import org.slf4j.LoggerFactory -import java.io.File -import java.text.SimpleDateFormat -import java.util.* -import java.util.regex.Pattern +import com.soywiz.klock.DateFormat +import com.soywiz.klock.DateTime +import net.dankito.banking.fints.util.log.LoggerFactory /** @@ -22,7 +19,7 @@ open class SepaMessageCreator : ISepaMessageCreator { companion object { const val AllowedSepaCharacters = "A-Za-z0-9\\?,\\-\\+\\.,:/\\(\\)\'\" (&\\w{2,4};)" - val AllowedSepaCharactersPattern: Pattern = Pattern.compile("^[$AllowedSepaCharacters]*$") + val AllowedSepaCharactersPattern = Regex("^[$AllowedSepaCharacters]*$") const val MessageIdKey = "MessageId" @@ -32,14 +29,12 @@ open class SepaMessageCreator : ISepaMessageCreator { const val NumberOfTransactionsKey = "NumberOfTransactions" - val IsoDateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS") - - private val log = LoggerFactory.getLogger(SepaMessageCreator::class.java) + val IsoDateFormat = DateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS") } override fun containsOnlyAllowedCharacters(stringToTest: String): Boolean { - return AllowedSepaCharactersPattern.matcher(stringToTest).matches() + return AllowedSepaCharactersPattern.matches(stringToTest) } override fun convertDiacriticsAndReservedXmlCharacters(input: String): String { @@ -88,11 +83,11 @@ open class SepaMessageCreator : ISepaMessageCreator { } - override fun createXmlFile(filename: String, replacementStrings: Map): String { - var xmlFile = loadXmlFile(filename) + override fun createXmlFile(messageTemplate: PaymentInformationMessages, replacementStrings: Map): String { + var xmlFile = messageTemplate.xmlTemplate - val now = Date() - val nowInIsoDate = IsoDateFormat.format(now) + val now = DateTime.now() + val nowInIsoDate = IsoDateFormat.format(now.localUnadjusted) if (replacementStrings.containsKey(MessageIdKey) == false) { xmlFile = replacePlaceholderWithValue(xmlFile, MessageIdKey, nowInIsoDate) @@ -111,18 +106,6 @@ open class SepaMessageCreator : ISepaMessageCreator { return xmlFile } - protected open fun loadXmlFile(filename: String): String { - val filePath = "sepa/" + filename - - SepaMessage::class.java.classLoader.getResourceAsStream(filePath)?.use { inputStream -> - return inputStream.bufferedReader().readText() - } - - log.error("Could not load SEPA file from path ${File(filePath).absolutePath}") // TODO: how to inform user? - - return "" - } - protected open fun replacePlaceholderWithValue(xmlFile: String, key: String, value: String): String { return xmlFile.replace("$$key$", value) } diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/SepaSegment.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/SepaSegment.kt similarity index 90% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/SepaSegment.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/SepaSegment.kt index ab1f6e79..130aaedc 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/SepaSegment.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/SepaSegment.kt @@ -15,7 +15,7 @@ open class SepaSegment( segmentId: ISegmentId, segmentVersion: Int, sepaDescriptorUrn: String, - sepaFileName: String, + messageTemplate: PaymentInformationMessages, account: AccountData, bic: String, replacementStrings: Map, @@ -25,5 +25,5 @@ open class SepaSegment( Segmentkopf(segmentId, segmentVersion, segmentNumber), KontoverbindungInternational(account, bic), object : AlphanumerischesDatenelement(sepaDescriptorUrn, Existenzstatus.Mandatory, 256) { }, - SepaMessage(sepaFileName, replacementStrings, messageCreator) + SepaMessage(messageTemplate, replacementStrings, messageCreator) )) \ No newline at end of file diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/tan/TanGeneratorListeAnzeigen.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/tan/TanGeneratorListeAnzeigen.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/tan/TanGeneratorListeAnzeigen.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/tan/TanGeneratorListeAnzeigen.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/tan/TanGeneratorTanMediumAnOderUmmelden.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/tan/TanGeneratorTanMediumAnOderUmmelden.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/tan/TanGeneratorTanMediumAnOderUmmelden.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/tan/TanGeneratorTanMediumAnOderUmmelden.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/KontoumsaetzeZeitraumMt940Base.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/KontoumsaetzeZeitraumMt940Base.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/KontoumsaetzeZeitraumMt940Base.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/KontoumsaetzeZeitraumMt940Base.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/KontoumsaetzeZeitraumMt940Version5.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/KontoumsaetzeZeitraumMt940Version5.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/KontoumsaetzeZeitraumMt940Version5.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/KontoumsaetzeZeitraumMt940Version5.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/KontoumsaetzeZeitraumMt940Version6.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/KontoumsaetzeZeitraumMt940Version6.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/KontoumsaetzeZeitraumMt940Version6.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/KontoumsaetzeZeitraumMt940Version6.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/KontoumsaetzeZeitraumMt940Version7.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/KontoumsaetzeZeitraumMt940Version7.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/KontoumsaetzeZeitraumMt940Version7.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/KontoumsaetzeZeitraumMt940Version7.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/SaldenabfrageBase.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/SaldenabfrageBase.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/SaldenabfrageBase.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/SaldenabfrageBase.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/SaldenabfrageVersion5.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/SaldenabfrageVersion5.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/SaldenabfrageVersion5.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/SaldenabfrageVersion5.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/SaldenabfrageVersion7.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/SaldenabfrageVersion7.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/SaldenabfrageVersion7.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/SaldenabfrageVersion7.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/model/AccountData.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/AccountData.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/model/AccountData.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/AccountData.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/model/AccountFeature.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/AccountFeature.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/model/AccountFeature.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/AccountFeature.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/model/AccountTransaction.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/AccountTransaction.kt similarity index 74% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/model/AccountTransaction.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/AccountTransaction.kt index 8ac24cf3..3a2d7785 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/model/AccountTransaction.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/AccountTransaction.kt @@ -1,14 +1,13 @@ package net.dankito.banking.fints.model -import java.math.BigDecimal -import java.text.DateFormat -import java.util.* +import com.ionspin.kotlin.bignum.decimal.BigDecimal +import com.soywiz.klock.Date +import com.soywiz.klock.DateTime open class AccountTransaction( val account: AccountData, - val amount: BigDecimal, - val currency: String, + val amount: Money, val isReversal: Boolean, val unparsedUsage: String, val bookingDate: Date, @@ -19,8 +18,8 @@ open class AccountTransaction( val valueDate: Date, val statementNumber: Int, val sequenceNumber: Int?, - val openingBalance: BigDecimal?, - val closingBalance: BigDecimal?, + val openingBalance: Money?, + val closingBalance: Money?, val endToEndReference: String?, val customerReference: String?, @@ -47,13 +46,13 @@ open class AccountTransaction( ) { // for object deserializers - internal constructor() : this(AccountData(), 0.toBigDecimal(),"", false, "", Date(), null, null, null, null, Date(), 0, null, null, null, + internal constructor() : this(AccountData(), Money(BigDecimal.ZERO, ""), false, "", DateTime.EPOCH.date, null, null, null, null, DateTime.EPOCH.date, 0, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, "", "", null, null, "", null) override fun toString(): String { - return "${DateFormat.getDateInstance(DateFormat.MEDIUM).format(bookingDate)} $amount $otherPartyName: $unparsedUsage" + return "$valueDate $amount $otherPartyName: $unparsedUsage" } } \ No newline at end of file diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/model/BankData.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/BankData.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/model/BankData.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/BankData.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/model/BankTransferData.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/BankTransferData.kt similarity index 60% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/model/BankTransferData.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/BankTransferData.kt index 7a9acd3a..83fc35a0 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/model/BankTransferData.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/BankTransferData.kt @@ -1,13 +1,13 @@ package net.dankito.banking.fints.model -import java.math.BigDecimal +import com.ionspin.kotlin.bignum.decimal.BigDecimal -open class BankTransferData @JvmOverloads constructor( +open class BankTransferData( val creditorName: String, val creditorIban: String, val creditorBic: String, - val amount: BigDecimal, + val amount: BigDecimal, // TODO: use Money val usage: String, val instantPayment: Boolean = false ) \ No newline at end of file diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/Currency.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/Currency.kt new file mode 100644 index 00000000..963b2f65 --- /dev/null +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/Currency.kt @@ -0,0 +1,15 @@ +package net.dankito.banking.fints.model + + +open class Currency( + val code: String +) { + + internal constructor() : this("") // for object deserializers + + + override fun toString(): String { + return code + } + +} \ No newline at end of file diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/model/CustomerData.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/CustomerData.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/model/CustomerData.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/CustomerData.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/model/DialogContext.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/DialogContext.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/model/DialogContext.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/DialogContext.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/model/EnterTanGeneratorAtcResult.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/EnterTanGeneratorAtcResult.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/model/EnterTanGeneratorAtcResult.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/EnterTanGeneratorAtcResult.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/model/EnterTanResult.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/EnterTanResult.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/model/EnterTanResult.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/EnterTanResult.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/model/FlickerCodeTanChallenge.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/FlickerCodeTanChallenge.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/model/FlickerCodeTanChallenge.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/FlickerCodeTanChallenge.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/model/GetTransactionsParameter.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/GetTransactionsParameter.kt similarity index 78% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/model/GetTransactionsParameter.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/GetTransactionsParameter.kt index f1c230c2..1bed95c9 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/model/GetTransactionsParameter.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/GetTransactionsParameter.kt @@ -1,9 +1,9 @@ package net.dankito.banking.fints.model -import java.util.* +import com.soywiz.klock.Date -open class GetTransactionsParameter @JvmOverloads constructor( +open class GetTransactionsParameter( val alsoRetrieveBalance: Boolean = true, val fromDate: Date? = null, val toDate: Date? = null, diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/model/HHDVersion.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/HHDVersion.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/model/HHDVersion.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/HHDVersion.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/model/ImageTanChallenge.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/ImageTanChallenge.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/model/ImageTanChallenge.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/ImageTanChallenge.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/model/MessageBaseData.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/MessageBaseData.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/model/MessageBaseData.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/MessageBaseData.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/model/MessageLogEntry.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/MessageLogEntry.kt similarity index 77% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/model/MessageLogEntry.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/MessageLogEntry.kt index 0520ee48..4b68c48a 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/model/MessageLogEntry.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/MessageLogEntry.kt @@ -1,11 +1,11 @@ package net.dankito.banking.fints.model -import java.util.* +import com.soywiz.klock.DateTime open class MessageLogEntry( val message: String, - val time: Date, + val time: DateTime, val customer: CustomerData ) { diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/model/MessageLogEntryType.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/MessageLogEntryType.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/model/MessageLogEntryType.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/MessageLogEntryType.kt diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/Money.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/Money.kt new file mode 100644 index 00000000..ebed5c3a --- /dev/null +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/Money.kt @@ -0,0 +1,24 @@ +package net.dankito.banking.fints.model + +import com.ionspin.kotlin.bignum.decimal.BigDecimal + + +open class Money( + val amount: BigDecimal, + val currency: Currency +) { + + constructor(amount: BigDecimal, currencyCode: String) : this(amount, Currency(currencyCode)) + + internal constructor() : this(BigDecimal.ZERO, "") // for object deserializers + + + open val displayString: String + get() = "$amount $currency" + + + override fun toString(): String { + return displayString + } + +} \ No newline at end of file diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/model/ProductData.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/ProductData.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/model/ProductData.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/ProductData.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/model/TanChallenge.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/TanChallenge.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/model/TanChallenge.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/TanChallenge.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/model/TanProcedure.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/TanProcedure.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/model/TanProcedure.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/TanProcedure.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/model/TanProcedureType.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/TanProcedureType.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/model/TanProcedureType.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/TanProcedureType.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/GetUserTanProceduresResponse.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/GetUserTanProceduresResponse.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/GetUserTanProceduresResponse.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/GetUserTanProceduresResponse.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/InstituteSegmentId.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/InstituteSegmentId.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/InstituteSegmentId.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/InstituteSegmentId.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/Response.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/Response.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/Response.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/Response.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/ResponseParser.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/ResponseParser.kt similarity index 96% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/ResponseParser.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/ResponseParser.kt index 9096058f..34f8b6b8 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/ResponseParser.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/ResponseParser.kt @@ -1,5 +1,10 @@ package net.dankito.banking.fints.response +import com.ionspin.kotlin.bignum.decimal.BigDecimal +import com.ionspin.kotlin.bignum.decimal.toBigDecimal +import com.soywiz.klock.Date +import com.soywiz.klock.DateTime +import com.soywiz.klock.Time import net.dankito.banking.fints.messages.Separators import net.dankito.banking.fints.messages.datenelemente.abgeleiteteformate.Datum import net.dankito.banking.fints.messages.datenelemente.abgeleiteteformate.Uhrzeit @@ -16,20 +21,17 @@ import net.dankito.banking.fints.messages.datenelementgruppen.implementierte.sig import net.dankito.banking.fints.messages.segmente.id.MessageSegmentId import net.dankito.banking.fints.response.segments.* import net.dankito.banking.fints.util.MessageUtils -import org.slf4j.LoggerFactory -import java.math.BigDecimal -import java.util.* -import java.util.regex.Pattern +import net.dankito.banking.fints.util.log.LoggerFactory -open class ResponseParser @JvmOverloads constructor( +open class ResponseParser( protected val messageUtils: MessageUtils = MessageUtils() ) { companion object { - val EncryptionDataSegmentHeaderPattern: Pattern = Pattern.compile("${MessageSegmentId.EncryptionData.id}:\\d{1,3}:\\d{1,3}\\+") + val EncryptionDataSegmentHeaderRegex = Regex("${MessageSegmentId.EncryptionData.id}:\\d{1,3}:\\d{1,3}\\+") - val JobParametersSegmentPattern: Pattern = Pattern.compile("HI[A-Z]{3}S") + val JobParametersSegmentRegex = Regex("HI[A-Z]{3}S") const val FeedbackParametersSeparator = "; " @@ -37,7 +39,8 @@ open class ResponseParser @JvmOverloads constructor( const val SupportedTanProceduresForUserResponseCode = 3920 - private val log = LoggerFactory.getLogger(ResponseParser::class.java) + + private val log = LoggerFactory.getLogger(ResponseParser::class) } @@ -51,7 +54,7 @@ open class ResponseParser @JvmOverloads constructor( return Response(true, response, parsedSegments) } catch (e: Exception) { - log.error("Could not parse response '$response'", e) + log.error(e) { "Could not parse response '$response'" } return Response(true, response, exception = e) } @@ -83,7 +86,7 @@ open class ResponseParser @JvmOverloads constructor( return parseSegment(segment, segmentId, dataElementGroups) } } catch (e: Exception) { - log.error("Could not parse segment '$segment'", e) // TODO: what to do here, how to inform user? + log.error(e) { "Could not parse segment '$segment'" } // TODO: what to do here, how to inform user? } return null @@ -116,7 +119,7 @@ open class ResponseParser @JvmOverloads constructor( InstituteSegmentId.AccountTransactionsMt940.id -> parseMt940AccountTransactions(segment, dataElementGroups) else -> { - if (JobParametersSegmentPattern.matcher(segmentId).matches()) { + if (JobParametersSegmentRegex.matches(segmentId)) { return parseJobParameters(segment, segmentId, dataElementGroups) } @@ -457,7 +460,7 @@ open class ResponseParser @JvmOverloads constructor( try { return parseCodeEnum(smsAbbuchungskontoErforderlichString, SmsAbbuchungskontoErforderlich.values()) } catch (e: Exception) { - log.error("Could not parse '$smsAbbuchungskontoErforderlichString' to SmsAbbuchungskontoErforderlich", e) + log.error(e) { "Could not parse '$smsAbbuchungskontoErforderlichString' to SmsAbbuchungskontoErforderlich"} } // Bankhaus Neelmeyer and Oldenburgische Landesbank encode SmsAbbuchungskontoErforderlich with boolean values (with is wrong according to FinTS standard) @@ -470,7 +473,7 @@ open class ResponseParser @JvmOverloads constructor( try { return parseCodeEnum(auftraggeberkontoErforderlichString, AuftraggeberkontoErforderlich.values()) } catch (e: Exception) { - log.error("Could not parse '$auftraggeberkontoErforderlichString' to AuftraggeberkontoErforderlich", e) + log.error(e) { "Could not parse '$auftraggeberkontoErforderlichString' to AuftraggeberkontoErforderlich" } } // Bankhaus Neelmeyer and Oldenburgische Landesbank encode AuftraggeberkontoErforderlich with boolean values (with is wrong according to FinTS standard) @@ -743,7 +746,7 @@ open class ResponseParser @JvmOverloads constructor( binaryRanges.forEach { range -> if (range.contains(index)) { part.append(dataString.substring(range)) - index = range.endInclusive + index = range.last } } } @@ -823,7 +826,6 @@ open class ResponseParser @JvmOverloads constructor( return null } - @JvmOverloads protected open fun parseAmount(amountString: String, isPositive: Boolean = true): BigDecimal { val adjustedAmountString = amountString.replace(',', '.') // Hbci amount format uses comma instead dot as decimal separator @@ -836,13 +838,13 @@ open class ResponseParser @JvmOverloads constructor( return amount } - protected open fun parseNullableDateTime(dataElementGroup: String): Date? { + protected open fun parseNullableDateTime(dataElementGroup: String): DateTime? { val dataElements = getDataElements(dataElementGroup) if (dataElements.size >= 2) { parseNullableDate(dataElements[0])?.let { date -> parseNullableTime(dataElements[1])?.let { time -> - return Date(date.time + time.time) + return DateTime.Companion.invoke(date, time) } } } @@ -851,7 +853,7 @@ open class ResponseParser @JvmOverloads constructor( } protected open fun parseDate(dateString: String): Date { - return Datum.HbciDateFormat.parse(dateString) + return Datum.parse(dateString) } protected open fun parseNullableDate(dateString: String): Date? { @@ -862,11 +864,11 @@ open class ResponseParser @JvmOverloads constructor( return null } - protected open fun parseTime(timeString: String): Date { - return Uhrzeit.HbciTimeFormat.parse(timeString) + protected open fun parseTime(timeString: String): Time { + return Uhrzeit.parse(timeString) } - protected open fun parseNullableTime(timeString: String): Date? { + protected open fun parseNullableTime(timeString: String): Time? { try { return parseTime(timeString) } catch (ignored: Exception) { } diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/client/AddAccountResponse.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/client/AddAccountResponse.kt similarity index 55% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/client/AddAccountResponse.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/client/AddAccountResponse.kt index 367a5a9b..fcf74fd4 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/client/AddAccountResponse.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/client/AddAccountResponse.kt @@ -1,11 +1,8 @@ package net.dankito.banking.fints.response.client -import net.dankito.banking.fints.model.AccountData -import net.dankito.banking.fints.model.AccountTransaction -import net.dankito.banking.fints.model.BankData -import net.dankito.banking.fints.model.CustomerData +import com.ionspin.kotlin.bignum.decimal.BigDecimal +import net.dankito.banking.fints.model.* import net.dankito.banking.fints.response.Response -import java.math.BigDecimal open class AddAccountResponse( @@ -15,6 +12,7 @@ open class AddAccountResponse( val supportsRetrievingTransactionsOfLast90DaysWithoutTan: Boolean = false, bookedTransactionsOfLast90Days: List = listOf(), unbookedTransactionsOfLast90Days: List = listOf(), - val balances: Map = mapOf() + val balances: Map = mapOf() ) - : GetTransactionsResponse(response, bookedTransactionsOfLast90Days, unbookedTransactionsOfLast90Days, balances.values.fold(BigDecimal.ZERO) { acc, e -> acc + e }) \ No newline at end of file + : GetTransactionsResponse(response, bookedTransactionsOfLast90Days, unbookedTransactionsOfLast90Days, + Money(balances.values.fold(BigDecimal.ZERO) { acc, e -> acc + e.amount }, balances.values.firstOrNull()?.currency?.code ?: "EUR")) \ No newline at end of file diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/client/FinTsClientResponse.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/client/FinTsClientResponse.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/client/FinTsClientResponse.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/client/FinTsClientResponse.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/client/GetTanMediaListResponse.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/client/GetTanMediaListResponse.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/client/GetTanMediaListResponse.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/client/GetTanMediaListResponse.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/client/GetTransactionsResponse.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/client/GetTransactionsResponse.kt similarity index 75% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/client/GetTransactionsResponse.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/client/GetTransactionsResponse.kt index 1f65085c..a4c40afe 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/client/GetTransactionsResponse.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/client/GetTransactionsResponse.kt @@ -1,14 +1,14 @@ package net.dankito.banking.fints.response.client import net.dankito.banking.fints.model.AccountTransaction +import net.dankito.banking.fints.model.Money import net.dankito.banking.fints.response.Response -import java.math.BigDecimal open class GetTransactionsResponse( response: Response, val bookedTransactions: List = listOf(), val unbookedTransactions: List = listOf(), - val balance: BigDecimal? = null + val balance: Money? = null ) : FinTsClientResponse(response) \ No newline at end of file diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/AccountInfo.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/AccountInfo.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/AccountInfo.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/AccountInfo.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/AccountType.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/AccountType.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/AccountType.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/AccountType.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/AccountTypeCode.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/AccountTypeCode.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/AccountTypeCode.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/AccountTypeCode.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/AufsetzpunktFeedback.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/AufsetzpunktFeedback.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/AufsetzpunktFeedback.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/AufsetzpunktFeedback.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/Balance.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/Balance.kt similarity index 61% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/Balance.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/Balance.kt index 1dc4dec8..b8c7ac36 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/Balance.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/Balance.kt @@ -1,13 +1,14 @@ package net.dankito.banking.fints.response.segments -import java.math.BigDecimal -import java.util.* +import com.ionspin.kotlin.bignum.decimal.BigDecimal +import com.soywiz.klock.Date +import com.soywiz.klock.Time open class Balance( val amount: BigDecimal, val date: Date, - val time: Date? + val time: Time? ) { override fun toString(): String { diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/BalanceSegment.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/BalanceSegment.kt similarity index 70% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/BalanceSegment.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/BalanceSegment.kt index c8ad66ad..d8e6c9fe 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/BalanceSegment.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/BalanceSegment.kt @@ -1,7 +1,7 @@ package net.dankito.banking.fints.response.segments -import java.math.BigDecimal -import java.util.* +import com.ionspin.kotlin.bignum.decimal.BigDecimal +import com.soywiz.klock.Date open class BalanceSegment( diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/BankParameters.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/BankParameters.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/BankParameters.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/BankParameters.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/ChangeTanMediaParameters.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/ChangeTanMediaParameters.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/ChangeTanMediaParameters.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/ChangeTanMediaParameters.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/CommunicationInfo.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/CommunicationInfo.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/CommunicationInfo.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/CommunicationInfo.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/CommunicationParameter.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/CommunicationParameter.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/CommunicationParameter.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/CommunicationParameter.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/Feedback.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/Feedback.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/Feedback.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/Feedback.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/JobParameters.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/JobParameters.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/JobParameters.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/JobParameters.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/Kommunikationsdienst.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/Kommunikationsdienst.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/Kommunikationsdienst.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/Kommunikationsdienst.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/KontoverbindungZvInternational.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/KontoverbindungZvInternational.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/KontoverbindungZvInternational.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/KontoverbindungZvInternational.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/MessageFeedback.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/MessageFeedback.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/MessageFeedback.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/MessageFeedback.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/PinInfo.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/PinInfo.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/PinInfo.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/PinInfo.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/ReceivedAccountTransactions.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/ReceivedAccountTransactions.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/ReceivedAccountTransactions.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/ReceivedAccountTransactions.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/ReceivedMessageHeader.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/ReceivedMessageHeader.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/ReceivedMessageHeader.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/ReceivedMessageHeader.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/ReceivedSegment.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/ReceivedSegment.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/ReceivedSegment.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/ReceivedSegment.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/ReceivedSynchronization.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/ReceivedSynchronization.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/ReceivedSynchronization.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/ReceivedSynchronization.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/SecurityMethods.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/SecurityMethods.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/SecurityMethods.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/SecurityMethods.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/SegmentFeedback.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/SegmentFeedback.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/SegmentFeedback.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/SegmentFeedback.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/SepaAccountInfo.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/SepaAccountInfo.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/SepaAccountInfo.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/SepaAccountInfo.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/SepaAccountInfoParameters.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/SepaAccountInfoParameters.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/SepaAccountInfoParameters.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/SepaAccountInfoParameters.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/SupportedTanProceduresForUserFeedback.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/SupportedTanProceduresForUserFeedback.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/SupportedTanProceduresForUserFeedback.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/SupportedTanProceduresForUserFeedback.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/TanInfo.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/TanInfo.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/TanInfo.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/TanInfo.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/TanMediaList.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/TanMediaList.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/TanMediaList.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/TanMediaList.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/TanProcedureParameters.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/TanProcedureParameters.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/TanProcedureParameters.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/TanProcedureParameters.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/TanResponse.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/TanResponse.kt similarity index 95% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/TanResponse.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/TanResponse.kt index 0455db29..2a7d7161 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/TanResponse.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/TanResponse.kt @@ -1,7 +1,7 @@ package net.dankito.banking.fints.response.segments +import com.soywiz.klock.DateTime import net.dankito.banking.fints.messages.datenelemente.implementierte.tan.TanProcess -import java.util.* open class TanResponse( @@ -31,7 +31,7 @@ open class TanResponse( val challenge: String?, // M: bei TAN-Prozess=1, 3, 4. O: bei TAN-Prozess=2 val challengeHHD_UC: String?, - val validityDateTimeForChallenge: Date?, + val validityDateTimeForChallenge: DateTime?, val tanMediaIdentifier: String? = null, // M: bei TAN-Prozess=1, 3, 4 und „Anzahl unterstützter aktiver TAN-Medien“ nicht vorhanden. O: sonst segmentString: String diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/TwoStepTanProcedureParameters.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/TwoStepTanProcedureParameters.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/TwoStepTanProcedureParameters.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/TwoStepTanProcedureParameters.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/UnparsedSegment.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/UnparsedSegment.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/UnparsedSegment.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/UnparsedSegment.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/UserParameters.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/UserParameters.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/response/segments/UserParameters.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/segments/UserParameters.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/tan/Bit.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/tan/Bit.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/tan/Bit.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/tan/Bit.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/tan/FlickerCanvas.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/tan/FlickerCanvas.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/tan/FlickerCanvas.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/tan/FlickerCanvas.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/tan/FlickerCode.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/tan/FlickerCode.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/tan/FlickerCode.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/tan/FlickerCode.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/tan/FlickerCodeDatenelement.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/tan/FlickerCodeDatenelement.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/tan/FlickerCodeDatenelement.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/tan/FlickerCodeDatenelement.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/tan/FlickerCodeDecoder.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/tan/FlickerCodeDecoder.kt similarity index 95% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/tan/FlickerCodeDecoder.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/tan/FlickerCodeDecoder.kt index 0b7c322b..d2761dd1 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/tan/FlickerCodeDecoder.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/tan/FlickerCodeDecoder.kt @@ -1,16 +1,16 @@ package net.dankito.banking.fints.tan import net.dankito.banking.fints.model.HHDVersion -import org.slf4j.LoggerFactory -import java.util.regex.Pattern +import net.dankito.banking.fints.util.log.LoggerFactory open class FlickerCodeDecoder { companion object { - val ContainsOtherSymbolsThanFiguresPattern: Pattern = Pattern.compile("\\D") + val ContainsOtherSymbolsThanFiguresPattern = Regex("\\D") - private val log = LoggerFactory.getLogger(FlickerCodeDecoder::class.java) + + private val log = LoggerFactory.getLogger(FlickerCodeDecoder::class) } @@ -44,7 +44,7 @@ open class FlickerCodeDecoder { return FlickerCode(challengeHHD_UC, parsedDataSet) } catch (e: Exception) { - log.error("Could not decode challenge $challengeHHD_UC") + log.error(e) { "Could not decode challenge $challengeHHD_UC" } return FlickerCode(challengeHHD_UC, "", e) } @@ -80,7 +80,7 @@ open class FlickerCodeDecoder { // Sollte ein Datenelement eine Zahl mit Komma-Trennung oder Vorzeichen beinhalten (z. B. Betrag oder Anzahl), // so muss als Format ASCII gewählt werden, da ggf. auch ein Sonderzeichen mit übertragen werden muss. - if (ContainsOtherSymbolsThanFiguresPattern.matcher(data).find()) { + if (encoding != FlickerCodeEncoding.ASCII && ContainsOtherSymbolsThanFiguresPattern.containsMatchIn(data)) { encoding = FlickerCodeEncoding.ASCII } @@ -208,7 +208,7 @@ open class FlickerCodeDecoder { } protected open fun parseIntToHex(string: String): Int { - return Integer.parseInt(string, 16) + return string.toInt(16) } protected open fun isBitSet(num: Int, bit: Int): Boolean { diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/tan/FlickerCodeEncoding.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/tan/FlickerCodeEncoding.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/tan/FlickerCodeEncoding.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/tan/FlickerCodeEncoding.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/tan/TanImage.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/tan/TanImage.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/tan/TanImage.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/tan/TanImage.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/tan/TanImageDecoder.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/tan/TanImageDecoder.kt similarity index 87% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/tan/TanImageDecoder.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/tan/TanImageDecoder.kt index f9db5ab2..e1e42f45 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/tan/TanImageDecoder.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/tan/TanImageDecoder.kt @@ -1,13 +1,14 @@ package net.dankito.banking.fints.tan +import io.ktor.utils.io.core.toByteArray import net.dankito.banking.fints.messages.HbciCharset -import org.slf4j.LoggerFactory +import net.dankito.banking.fints.util.log.LoggerFactory open class TanImageDecoder { companion object { - private val log = LoggerFactory.getLogger(TanImageDecoder::class.java) + private val log = LoggerFactory.getLogger(TanImageDecoder::class) } @@ -28,7 +29,7 @@ open class TanImageDecoder { return TanImage(mimeType, imageBytes) } catch (e: Exception) { - log.error("Could not decode challenge HHD_UC to TanImage: $challengeHHD_UC", e) + log.error(e) { "Could not decode challenge HHD_UC to TanImage: $challengeHHD_UC" } return TanImage("", ByteArray(0), e) } diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/transactions/IAccountTransactionsParser.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/transactions/IAccountTransactionsParser.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/transactions/IAccountTransactionsParser.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/transactions/IAccountTransactionsParser.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/transactions/Mt940AccountTransactionsParser.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/transactions/Mt940AccountTransactionsParser.kt similarity index 86% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/transactions/Mt940AccountTransactionsParser.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/transactions/Mt940AccountTransactionsParser.kt index d927fd58..217466a7 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/transactions/Mt940AccountTransactionsParser.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/transactions/Mt940AccountTransactionsParser.kt @@ -1,23 +1,24 @@ package net.dankito.banking.fints.transactions +import com.ionspin.kotlin.bignum.decimal.BigDecimal import net.dankito.banking.fints.model.AccountData import net.dankito.banking.fints.model.AccountTransaction +import net.dankito.banking.fints.model.Money import net.dankito.banking.fints.transactions.mt940.IMt940Parser import net.dankito.banking.fints.transactions.mt940.Mt940Parser import net.dankito.banking.fints.transactions.mt940.model.AccountStatement import net.dankito.banking.fints.transactions.mt940.model.Balance import net.dankito.banking.fints.transactions.mt940.model.Transaction import net.dankito.banking.fints.transactions.mt940.model.StatementLine -import org.slf4j.LoggerFactory -import java.math.BigDecimal +import net.dankito.banking.fints.util.log.LoggerFactory -open class Mt940AccountTransactionsParser @JvmOverloads constructor( +open class Mt940AccountTransactionsParser( protected val mt940Parser: IMt940Parser = Mt940Parser() ) : IAccountTransactionsParser { companion object { - private val log = LoggerFactory.getLogger(Mt940AccountTransactionsParser::class.java) + private val log = LoggerFactory.getLogger(Mt940AccountTransactionsParser::class) } @@ -37,17 +38,18 @@ open class Mt940AccountTransactionsParser @JvmOverloads constructor( try { return statement.transactions.map { mapToAccountTransaction(statement, it, account) } } catch (e: Exception) { - log.error("Could not map AccountStatement '$statement' to AccountTransactions", e) + log.error(e) { "Could not map AccountStatement '$statement' to AccountTransactions" } } return listOf() } protected open fun mapToAccountTransaction(statement: AccountStatement, transaction: Transaction, account: AccountData): AccountTransaction { + val currency = statement.closingBalance.currency + return AccountTransaction( account, - mapAmount(transaction.statementLine), - statement.closingBalance.currency, + Money(mapAmount(transaction.statementLine), currency), transaction.statementLine.isReversal, transaction.information?.unparsedUsage ?: "", transaction.statementLine.bookingDate ?: statement.closingBalance.bookingDate, @@ -58,8 +60,8 @@ open class Mt940AccountTransactionsParser @JvmOverloads constructor( transaction.statementLine.valueDate, statement.statementNumber, statement.sequenceNumber, - mapAmount(statement.openingBalance), // TODO: that's not true, these are the opening and closing balance of - mapAmount(statement.closingBalance), // all transactions of this day, not this specific transaction's ones + Money(mapAmount(statement.openingBalance), currency), // TODO: that's not true, these are the opening and closing balance of + Money(mapAmount(statement.closingBalance), currency), // all transactions of this day, not this specific transaction's ones transaction.information?.endToEndReference, transaction.information?.customerReference, diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/transactions/mt940/IMt940Parser.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/transactions/mt940/IMt940Parser.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/transactions/mt940/IMt940Parser.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/transactions/mt940/IMt940Parser.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/transactions/mt940/Mt940Parser.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/transactions/mt940/Mt940Parser.kt similarity index 85% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/transactions/mt940/Mt940Parser.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/transactions/mt940/Mt940Parser.kt index 4e06707e..e7bf2d81 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/transactions/mt940/Mt940Parser.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/transactions/mt940/Mt940Parser.kt @@ -1,11 +1,10 @@ package net.dankito.banking.fints.transactions.mt940 +import com.ionspin.kotlin.bignum.decimal.BigDecimal +import com.ionspin.kotlin.bignum.decimal.toBigDecimal +import com.soywiz.klock.* import net.dankito.banking.fints.transactions.mt940.model.* -import org.slf4j.LoggerFactory -import java.math.BigDecimal -import java.text.SimpleDateFormat -import java.util.* -import java.util.regex.Pattern +import net.dankito.banking.fints.util.log.LoggerFactory /* @@ -24,10 +23,10 @@ None of lines include only Space. open class Mt940Parser : IMt940Parser { companion object { - val AccountStatementsSeparatorPattern = Regex("^\\s*-\\s*\$", RegexOption.MULTILINE) // a line only with '-' and may other white space characters + val AccountStatementsSeparatorRegex = Regex("^\\s*-\\s*\$", RegexOption.MULTILINE) // a line only with '-' and may other white space characters // (? { - return mt940String.split(AccountStatementsSeparatorPattern) + return mt940String.split(AccountStatementsSeparatorRegex) .map { it.replace("\n", "").replace("\r", "") } } @@ -128,27 +127,25 @@ open class Mt940Parser : IMt940Parser { return parseAccountStatement(fieldsByCode) } catch (e: Exception) { - log.error("Could not parse account statement:\n$accountStatementString", e) + log.error(e) { "Could not parse account statement:\n$accountStatementString" } } return null } protected open fun splitIntoFields(accountStatementString: String): List> { - val matcher = AccountStatementFieldSeparatorPattern.matcher(accountStatementString) - val result = mutableListOf>() var lastMatchEnd = 0 var lastMatchedCode = "" - while (matcher.find()) { + AccountStatementFieldSeparatorRegex.findAll(accountStatementString).forEach { matchResult -> if (lastMatchEnd > 0) { - val previousStatement = accountStatementString.substring(lastMatchEnd, matcher.start()) + val previousStatement = accountStatementString.substring(lastMatchEnd, matchResult.range.first) result.add(Pair(lastMatchedCode, previousStatement)) } - lastMatchedCode = matcher.group().replace(":", "") - lastMatchEnd = matcher.end() + lastMatchedCode = matchResult.value.replace(":", "") + lastMatchEnd = matchResult.range.last + 1 } if (lastMatchEnd > 0) { @@ -237,25 +234,25 @@ open class Mt940Parser : IMt940Parser { val valueDateString = fieldValue.substring(0, 6) val valueDate = parseMt940Date(valueDateString) - val creditMarkMatcher = CreditDebitCancellationPattern.matcher(fieldValue) - creditMarkMatcher.find() - val isDebit = creditMarkMatcher.group().endsWith('D') - val isCancellation = creditMarkMatcher.group().startsWith('R') + val creditMarkMatchResult = CreditDebitCancellationRegex.find(fieldValue) + val isDebit = creditMarkMatchResult?.value?.endsWith('D') == true + val isCancellation = creditMarkMatchResult?.value?.startsWith('R') == true + + val creditMarkEnd = (creditMarkMatchResult?.range?.last ?: -1) + 1 // booking date is the second field and is optional. It is normally only used when different from the value date. - val bookingDateString = if (creditMarkMatcher.start() > 6) fieldValue.substring(6, 10) else null + val bookingDateString = if ((creditMarkMatchResult?.range?.start ?: 0) > 6) fieldValue.substring(6, 10) else null val bookingDate = bookingDateString?.let { // bookingDateString has format MMdd -> add year from valueDateString parseMt940BookingDate(bookingDateString, valueDateString, valueDate) } ?: valueDate - val amountMatcher = AmountPattern.matcher(fieldValue) - amountMatcher.find() - val amountString = amountMatcher.group() + val amountMatchResult = AmountRegex.find(fieldValue)!! + val amountString = amountMatchResult.value val amount = parseAmount(amountString) - val amountEndIndex = amountMatcher.end() + val amountEndIndex = amountMatchResult.range.last + 1 - val fundsCode = if (amountMatcher.start() - creditMarkMatcher.end() > 1) fieldValue.substring(creditMarkMatcher.end() + 1, creditMarkMatcher.end() + 2) else null + val fundsCode = if (amountMatchResult.range.start - creditMarkEnd > 1) fieldValue.substring(creditMarkEnd + 1, creditMarkEnd + 2) else null /** * S SWIFT transfer For entries related to SWIFT transfer instructions and subsequent charge messages. @@ -300,7 +297,7 @@ open class Mt940Parser : IMt940Parser { return information } catch (e: Exception) { - log.error("Could not parse InformationToAccountOwner from field value '$informationToAccountOwnerString'", e) + log.error(e) { "Could not parse InformationToAccountOwner from field value '$informationToAccountOwnerString'" } } return null @@ -349,7 +346,7 @@ open class Mt940Parser : IMt940Parser { } protected open fun isFormattedUsage(usageParts: List): Boolean { - return usageParts.any { UsageTypePattern.matcher(it).find() } + return usageParts.any { UsageTypeRegex.matches(it) } } /** @@ -387,17 +384,16 @@ open class Mt940Parser : IMt940Parser { var previousMatchEnd = 0 val usageParts = mutableMapOf() - val matcher = UsageTypePattern.matcher(unparsedUsage) - while (matcher.find()) { + UsageTypeRegex.findAll(unparsedUsage).forEach { matchResult -> if (previousMatchEnd > 0) { - val typeValue = unparsedUsage.substring(previousMatchEnd, matcher.start()) + val typeValue = unparsedUsage.substring(previousMatchEnd, matchResult.range.first) usageParts[previousMatchType] = typeValue } - previousMatchType = unparsedUsage.substring(matcher.start(), matcher.end()) - previousMatchEnd = matcher.end() + previousMatchType = unparsedUsage.substring(matchResult.range) + previousMatchEnd = matchResult.range.last + 1 } if (previousMatchEnd > 0) { @@ -427,11 +423,13 @@ open class Mt940Parser : IMt940Parser { protected open fun parseMt940Date(dateString: String): Date { + // TODO: this should be necessary anymore, isn't it? + // SimpleDateFormat is not thread-safe. Before adding another library i decided to parse // this really simple date format on my own if (dateString.length == 6) { try { - var year = dateString.substring(0, 2).toInt() + var year = dateString.substring(0, 2).toInt() + 2000 val month = dateString.substring(2, 4).toInt() val day = dateString.substring(4, 6).toInt() @@ -439,13 +437,13 @@ open class Mt940Parser : IMt940Parser { year -= 100 } - return Date(year + 100, month - 1, day) // java.util.Date years start at 1900 at month at 0 not at 1 + return Date(year, month, day) // java.util.Date years start at 1900 at month at 0 not at 1 } catch (e: Exception) { - log.error("Could not parse dateString '$dateString'", e) + log.error(e) { "Could not parse dateString '$dateString'" } } } - return DateFormat.parse(dateString) // fallback to not thread-safe SimpleDateFormat. Works in most cases but not all + return DateFormat.parse(dateString).utc.date // fallback to not thread-safe SimpleDateFormat. Works in most cases but not all } /** @@ -455,8 +453,8 @@ open class Mt940Parser : IMt940Parser { val bookingDate = parseMt940Date(valueDateString.substring(0, 2) + bookingDateString) // there are rare cases that booking date is e.g. on 31.12.2019 and value date on 01.01.2020 -> booking date would be on 31.12.2020 (and therefore in the future) - if (bookingDate.month != valueDate.month && bookingDate.month == 11) { - return parseMt940Date("" + (valueDate.year - 1 - 100) + bookingDateString) + if (bookingDate.month != valueDate.month && bookingDate.month == Month.December) { + return parseMt940Date("" + (valueDate.year - 1 - 2000) + bookingDateString) } return bookingDate diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/transactions/mt940/model/AccountStatement.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/transactions/mt940/model/AccountStatement.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/transactions/mt940/model/AccountStatement.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/transactions/mt940/model/AccountStatement.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/transactions/mt940/model/Balance.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/transactions/mt940/model/Balance.kt similarity index 68% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/transactions/mt940/model/Balance.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/transactions/mt940/model/Balance.kt index be607fc2..83d5cacb 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/transactions/mt940/model/Balance.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/transactions/mt940/model/Balance.kt @@ -1,8 +1,8 @@ package net.dankito.banking.fints.transactions.mt940.model -import java.math.BigDecimal -import java.text.DateFormat -import java.util.* +import com.ionspin.kotlin.bignum.decimal.BigDecimal +import com.soywiz.klock.Date +import com.soywiz.klock.DateTime open class Balance( @@ -42,11 +42,11 @@ open class Balance( ) { - internal constructor() : this(false, false, Date(), "", 0.toBigDecimal()) // for object deserializers + internal constructor() : this(false, false, DateTime.EPOCH.date, "", BigDecimal.ZERO) // for object deserializers override fun toString(): String { - return "${DateFormat.getDateInstance(DateFormat.MEDIUM).format(bookingDate)} ${if (isCredit) "+" else "-"}$amount $currency" + return "$bookingDate ${if (isCredit) "+" else "-"}$amount $currency" } } \ No newline at end of file diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/transactions/mt940/model/InformationToAccountOwner.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/transactions/mt940/model/InformationToAccountOwner.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/transactions/mt940/model/InformationToAccountOwner.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/transactions/mt940/model/InformationToAccountOwner.kt diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/transactions/mt940/model/StatementLine.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/transactions/mt940/model/StatementLine.kt similarity index 85% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/transactions/mt940/model/StatementLine.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/transactions/mt940/model/StatementLine.kt index 72a85932..b6b408d9 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/transactions/mt940/model/StatementLine.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/transactions/mt940/model/StatementLine.kt @@ -1,8 +1,7 @@ package net.dankito.banking.fints.transactions.mt940.model -import java.math.BigDecimal -import java.text.DateFormat -import java.util.* +import com.ionspin.kotlin.bignum.decimal.BigDecimal +import com.soywiz.klock.Date open class StatementLine( @@ -67,7 +66,7 @@ open class StatementLine( ) { override fun toString(): String { - return "${DateFormat.getDateInstance(DateFormat.MEDIUM).format(valueDate)} ${if (isCredit) "+" else "-"}$amount" + return "$valueDate ${if (isCredit) "+" else "-"}$amount" } } \ No newline at end of file diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/transactions/mt940/model/Transaction.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/transactions/mt940/model/Transaction.kt similarity index 100% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/transactions/mt940/model/Transaction.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/transactions/mt940/model/Transaction.kt diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/Base64.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/Base64.kt new file mode 100644 index 00000000..d97f4e9e --- /dev/null +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/Base64.kt @@ -0,0 +1,91 @@ +package net.dankito.banking.fints.util + + +open class Base64 { + + companion object { + + const val Base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" + + val NonBase64CharsRegex = Regex("[^=$Base64Chars]") + + } + + + open fun encode(string: String): String { + val paddingLength = when (string.length % 3) { + 1 -> 2 + 2 -> 1 + else -> 0 + } + + var padding = "" + var paddedString = string + + (0 until paddingLength).forEach { + padding += "=" + paddedString += 0.toChar() + } + + val encoded = encodePaddedString(paddedString) + + return encoded.dropLast(paddingLength) + padding + } + + protected open fun encodePaddedString(string: String): String { + val encoded = StringBuilder(string.length) + + (string.indices step 3).forEach { index -> + val number: Int = + (0xFF.and(string[index ].toInt()) shl 16) + + (0xFF.and(string[index + 1].toInt()) shl 8) + + 0xFF.and(string[index + 2].toInt()) + + encoded.append(Base64Chars[(number shr 18) and 0x3F]) + encoded.append(Base64Chars[(number shr 12) and 0x3F]) + encoded.append(Base64Chars[(number shr 6) and 0x3F]) + encoded.append(Base64Chars[ number and 0x3F]) + } + + return encoded.toString() + } + + + open fun decode(string: String): String { + if (string.length % 4 != 0) { + throw IllegalArgumentException("The string \"$string\" has an illegal length, has to be a multiple of four.") + } + + val paddingLength = when { + string.length >= 2 && string[string.length - 2] == '=' -> 2 + string.length >= 1 && string[string.length - 1] == '=' -> 1 + else -> 0 + } + + // replace non-Base64 characters like \r, \n, ... and padding character with A (= 0) + val clean = string.replace(NonBase64CharsRegex, "").replace("=", "A") + + val decoded = decodeCleanedString(clean) + + return decoded.dropLast(paddingLength) + } + + protected open fun decodeCleanedString(string: String): String { + val decoded = StringBuilder() + + (string.indices step 4).forEach { index -> + val number: Int = + (Base64Chars.indexOf(string[index ]) shl 18) + + (Base64Chars.indexOf(string[index + 1]) shl 12) + + (Base64Chars.indexOf(string[index + 2]) shl 6) + + Base64Chars.indexOf(string[index + 3]) + + decoded.append(0xFF.and(number shr 16).toChar()) + decoded.append(0xFF.and(number shr 8).toChar()) + decoded.append(0xFF.and(number).toChar()) + } + + return decoded.toString() + } + +} \ No newline at end of file diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/util/FinTsUtils.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/FinTsUtils.kt similarity index 70% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/util/FinTsUtils.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/FinTsUtils.kt index 1d66101e..3961f7ae 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/util/FinTsUtils.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/FinTsUtils.kt @@ -1,19 +1,21 @@ package net.dankito.banking.fints.util +import com.soywiz.klock.Date +import com.soywiz.klock.DateTime +import com.soywiz.klock.Time import net.dankito.banking.fints.messages.datenelemente.abgeleiteteformate.Datum import net.dankito.banking.fints.messages.datenelemente.abgeleiteteformate.Uhrzeit -import java.util.* open class FinTsUtils { open fun formatDateToday(): String { - return formatDate(Date()) + return formatDate(DateTime.now().date) } open fun formatDate(date: Date): String { - return Datum.HbciDateFormat.format(date) + return Datum.format(date) } open fun formatDateTodayAsInt(): Int { @@ -26,18 +28,18 @@ open class FinTsUtils { open fun formatTimeNow(): String { - return formatTime(Date()) + return formatTime(DateTime.now().time) } - open fun formatTime(time: Date): String { - return Uhrzeit.HbciTimeFormat.format(time) + open fun formatTime(time: Time): String { + return Uhrzeit.format(time) } open fun formatTimeNowAsInt(): Int { return convertToInt(formatTimeNow()) } - open fun formatTimeAsInt(time: Date): Int { + open fun formatTimeAsInt(time: Time): Int { return convertToInt(formatTime(time)) } diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/IBase64Service.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/IBase64Service.kt new file mode 100644 index 00000000..dccb6501 --- /dev/null +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/IBase64Service.kt @@ -0,0 +1,19 @@ +package net.dankito.banking.fints.util + +import io.ktor.utils.io.charsets.Charset +import net.dankito.banking.fints.messages.HbciCharset + + +interface IBase64Service { + + companion object { + val DefaultCharset = HbciCharset.DefaultCharset + } + + + fun encode(text: String, charset: Charset = DefaultCharset): String + + + fun decode(base64: String, charset: Charset = DefaultCharset): String + +} \ No newline at end of file diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/IThreadPool.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/IThreadPool.kt new file mode 100644 index 00000000..41f22d81 --- /dev/null +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/IThreadPool.kt @@ -0,0 +1,10 @@ +package net.dankito.banking.fints.util + + +interface IThreadPool { + + fun runAsync(runnable: () -> Unit) + + fun shutDown() + +} \ No newline at end of file diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/util/MessageUtils.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/MessageUtils.kt similarity index 65% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/util/MessageUtils.kt rename to fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/MessageUtils.kt index ba0b2933..14cece93 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/util/MessageUtils.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/MessageUtils.kt @@ -2,15 +2,12 @@ package net.dankito.banking.fints.util import net.dankito.banking.fints.messages.Separators import net.dankito.banking.fints.response.ResponseParser -import net.dankito.utils.extensions.allIndicesOf -import java.util.regex.Matcher -import java.util.regex.Pattern open class MessageUtils { companion object { - val BinaryDataHeaderPattern = Pattern.compile("@\\d+@") + val BinaryDataHeaderPattern = Regex("@\\d+@") } @@ -25,28 +22,26 @@ open class MessageUtils { } open fun findBinaryDataRanges(dataString: String): List { - val binaryDataRanges = mutableListOf() - val binaryDataMatcher = BinaryDataHeaderPattern.matcher(dataString) - while (binaryDataMatcher.find()) { - if (isEncryptionDataSegment(dataString, binaryDataMatcher) == false) { - val startIndex = binaryDataMatcher.end() - val length = binaryDataMatcher.group().replace(Separators.BinaryDataSeparator, "").toInt() + return BinaryDataHeaderPattern.findAll(dataString).mapNotNull { matchResult -> + if (isEncryptionDataSegment(dataString, matchResult) == false) { + val startIndex = matchResult.range.last + 1 + val length = matchResult.value.replace(Separators.BinaryDataSeparator, "").toInt() - binaryDataRanges.add(IntRange(startIndex, startIndex + length - 1)) + return@mapNotNull IntRange(startIndex, startIndex + length - 1) } - } - return binaryDataRanges + + null + }.toList() } - open fun isEncryptionDataSegment(dataString: String, binaryDataMatcher: Matcher): Boolean { - val binaryDataHeaderStartIndex = binaryDataMatcher.start() + open fun isEncryptionDataSegment(dataString: String, binaryDataMatcher: MatchResult): Boolean { + val binaryDataHeaderStartIndex = binaryDataMatcher.range.start if (binaryDataHeaderStartIndex > 15) { - val encryptionDataSegmentMatcher = ResponseParser.EncryptionDataSegmentHeaderPattern.matcher(dataString) - if (encryptionDataSegmentMatcher.find(binaryDataHeaderStartIndex - 15)) { - return encryptionDataSegmentMatcher.start() < binaryDataHeaderStartIndex + ResponseParser.EncryptionDataSegmentHeaderRegex.find(dataString, binaryDataHeaderStartIndex - 15)?.let { matchResult -> + return matchResult.range.start < binaryDataHeaderStartIndex } } @@ -94,4 +89,21 @@ open class MessageUtils { return maskedString } + + // TODO: move to a library + protected open fun String.allIndicesOf(toFind: String): List { + val indices = mutableListOf() + var index = -1 + + do { + index = this.indexOf(toFind, index + 1) + + if (index > -1) { + indices.add(index) + } + } while (index > -1) + + return indices + } + } \ No newline at end of file diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/PureKotlinBase64Service.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/PureKotlinBase64Service.kt new file mode 100644 index 00000000..459f40c0 --- /dev/null +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/PureKotlinBase64Service.kt @@ -0,0 +1,19 @@ +package net.dankito.banking.fints.util + +import io.ktor.utils.io.charsets.Charset + + +open class PureKotlinBase64Service : IBase64Service { + + protected val base64 = Base64() + + + override fun encode(text: String, charset: Charset): String { + return base64.encode(text) + } + + override fun decode(base64: String, charset: Charset): String { + return this.base64.decode(base64) + } + +} \ No newline at end of file diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/log/CachedLoggerFactory.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/log/CachedLoggerFactory.kt new file mode 100644 index 00000000..045e05f6 --- /dev/null +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/log/CachedLoggerFactory.kt @@ -0,0 +1,24 @@ +package net.dankito.banking.fints.util.log + + +abstract class CachedLoggerFactory : ILoggerFactory { + + abstract fun createLogger(name: String): Logger + + + protected open val loggerCache = mutableMapOf() // TODO: make thread safe like with ConcurrentHashMap + + + override fun getLogger(name: String): Logger { + loggerCache[name]?.let { + return it + } + + val logger = createLogger(name) + + loggerCache[name] = logger + + return logger + } + +} \ No newline at end of file diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/log/ConsoleLogger.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/log/ConsoleLogger.kt new file mode 100644 index 00000000..95ed2085 --- /dev/null +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/log/ConsoleLogger.kt @@ -0,0 +1,17 @@ +package net.dankito.banking.fints.util.log + +import com.soywiz.klock.DateTime + + +open class ConsoleLogger(name: String) : LoggerBase(name) { + + companion object { + private val DateFormat = com.soywiz.klock.DateFormat.invoke("HH:mm:ss.SSS") + } + + + override fun log(level: LogLevel, message: String) { + println("${DateTime.nowLocal().toString(DateFormat)} $level $name - $message") + } + +} \ No newline at end of file diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/log/ILoggerFactory.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/log/ILoggerFactory.kt new file mode 100644 index 00000000..9e10254b --- /dev/null +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/log/ILoggerFactory.kt @@ -0,0 +1,8 @@ +package net.dankito.banking.fints.util.log + + +interface ILoggerFactory { + + fun getLogger(name: String): Logger + +} \ No newline at end of file diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/log/LogLevel.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/log/LogLevel.kt new file mode 100644 index 00000000..c0fc28e7 --- /dev/null +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/log/LogLevel.kt @@ -0,0 +1,20 @@ +package net.dankito.banking.fints.util.log + + +enum class LogLevel(val priority: Int) { + + None(0), + + Fatal(1), + + Error(2), + + Warn(3), + + Info(4), + + Debug(5), + + Trace(6) + +} \ No newline at end of file diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/log/LogToConsoleLoggerFactory.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/log/LogToConsoleLoggerFactory.kt new file mode 100644 index 00000000..016dbf8e --- /dev/null +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/log/LogToConsoleLoggerFactory.kt @@ -0,0 +1,10 @@ +package net.dankito.banking.fints.util.log + + +open class LogToConsoleLoggerFactory : CachedLoggerFactory() { + + override fun createLogger(name: String): Logger { + return ConsoleLogger(name) + } + +} \ No newline at end of file diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/log/Logger.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/log/Logger.kt new file mode 100644 index 00000000..67fe73d5 --- /dev/null +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/log/Logger.kt @@ -0,0 +1,34 @@ +package net.dankito.banking.fints.util.log + + +interface Logger { + + val name: String + + + val isFatalEnabled: Boolean + + val isErrorEnabled: Boolean + + val isWarnEnabled: Boolean + + val isInfoEnabled: Boolean + + val isDebugEnabled: Boolean + + val isTraceEnabled: Boolean + + + fun fatal(exception: Throwable? = null, vararg arguments: Any, message: () -> String) + + fun error(exception: Throwable? = null, vararg arguments: Any, message: () -> String) + + fun warn(exception: Throwable? = null, vararg arguments: Any, message: () -> String) + + fun info(exception: Throwable? = null, vararg arguments: Any, message: () -> String) + + fun debug(exception: Throwable? = null, vararg arguments: Any, message: () -> String) + + fun trace(exception: Throwable? = null, vararg arguments: Any, message: () -> String) + +} \ No newline at end of file diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/log/LoggerBase.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/log/LoggerBase.kt new file mode 100644 index 00000000..890a7b56 --- /dev/null +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/log/LoggerBase.kt @@ -0,0 +1,61 @@ +package net.dankito.banking.fints.util.log + + +abstract class LoggerBase( + override val name: String, + open var level: LogLevel = LogLevel.Info +) : Logger { + + abstract fun log(level: LogLevel, message: String) + + + override val isFatalEnabled get() = isEnabled(LogLevel.Fatal) + + override val isErrorEnabled get() = isEnabled(LogLevel.Error) + + override val isWarnEnabled get() = isEnabled(LogLevel.Warn) + + override val isInfoEnabled get() = isEnabled(LogLevel.Info) + + override val isDebugEnabled get() = isEnabled(LogLevel.Debug) + + override val isTraceEnabled get() = isEnabled(LogLevel.Trace) + + open fun isEnabled(level: LogLevel) = level.priority <= this.level.priority + + + override fun fatal(exception: Throwable?, vararg arguments: Any, message: () -> String) { + logIfEnabled(LogLevel.Fatal, exception, message, *arguments) + } + + override fun error(exception: Throwable?, vararg arguments: Any, message: () -> String) { + logIfEnabled(LogLevel.Error, exception, message, *arguments) + } + + override fun warn(exception: Throwable?, vararg arguments: Any, message: () -> String) { + logIfEnabled(LogLevel.Warn, exception, message, *arguments) + } + + override fun info(exception: Throwable?, vararg arguments: Any, message: () -> String) { + logIfEnabled(LogLevel.Info, exception, message, *arguments) + } + + override fun debug(exception: Throwable?, vararg arguments: Any, message: () -> String) { + logIfEnabled(LogLevel.Debug, exception, message, *arguments) + } + + override fun trace(exception: Throwable?, vararg arguments: Any, message: () -> String) { + logIfEnabled(LogLevel.Trace, exception, message, *arguments) + } + + open fun logIfEnabled(level: LogLevel, exception: Throwable? = null, message: () -> String, vararg arguments: Any) { + if (isEnabled(level)) { + log(level, createMessage(exception, message(), *arguments)) + } + } + + open fun createMessage(exception: Throwable?, message: String, vararg arguments: Any): String { + return message // really, there's not String.format() ?! // TODO: add arguments and exception + } + +} \ No newline at end of file diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/log/LoggerFactory.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/log/LoggerFactory.kt new file mode 100644 index 00000000..3d695f7f --- /dev/null +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/util/log/LoggerFactory.kt @@ -0,0 +1,23 @@ +package net.dankito.banking.fints.util.log + +import kotlin.reflect.KClass + + +class LoggerFactory { + + companion object { + + var loggerFactory: ILoggerFactory = LogToConsoleLoggerFactory() + + + fun getLogger(name: String): Logger { + return loggerFactory.getLogger(name) + } + + fun getLogger(kClass: KClass<*>): Logger { + return getLogger(kClass.qualifiedName ?: kClass.toString()) + } + + } + +} \ No newline at end of file diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/webclient/IWebClient.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/webclient/IWebClient.kt new file mode 100644 index 00000000..69f3a051 --- /dev/null +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/webclient/IWebClient.kt @@ -0,0 +1,25 @@ +package net.dankito.banking.fints.webclient + + +interface IWebClient { + + companion object { + const val DefaultUserAgent = "Mozilla/5.0 (Windows NT 6.3; rv:55.0) Gecko/20100101 Firefox/55.0" + + const val DefaultMobileUserAgent = "Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/537.36 (KHTML, like Gecko) CChrome/60.0.3112.105 Safari/537.36" + + const val DefaultConnectionTimeoutMillis = 2000 + + const val DefaultReadTimeoutMillis = 15000 + + const val DefaultWriteTimeoutMillis = 30000 + + const val DefaultDownloadBufferSize = 8 * 1024 + + const val DefaultCountConnectionRetries = 2 + } + + + fun post(url: String, body: String, contentType: String = "application/octet-stream", userAgent: String = DefaultUserAgent) : WebClientResponse + +} \ No newline at end of file diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/webclient/KtorWebClient.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/webclient/KtorWebClient.kt new file mode 100644 index 00000000..0c123cae --- /dev/null +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/webclient/KtorWebClient.kt @@ -0,0 +1,50 @@ +package net.dankito.banking.fints.webclient + +import io.ktor.client.HttpClient +import io.ktor.client.request.post +import io.ktor.client.statement.HttpResponse +import io.ktor.client.statement.readText +import io.ktor.content.TextContent +import io.ktor.http.ContentType +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.async +import kotlinx.coroutines.cancel + + +open class KtorWebClient : IWebClient { + + protected val client = HttpClient() { + + } + + + open fun close() { + try { + client.close() + } catch (e: Exception) { + // Cancel after timeout + client.cancel() + } + } + + + override fun post(url: String, body: String, contentType: String, userAgent: String): WebClientResponse { + try { + val job = GlobalScope.async { + val clientResponse = client.post(url) { + this.body = TextContent(body, contentType = ContentType.Application.OctetStream) + } + + val responseBody = clientResponse.readText() + + WebClientResponse(clientResponse.status.value == 200, clientResponse.status.value, body = responseBody) + } + + while (job.isCompleted == false) { } // let's warm the CPU to get suspend function synchronous (runBlocking is not available in common projects) + + return job.getCompleted() + } catch (e: Exception) { + return WebClientResponse(false, error = e) + } + } +} \ No newline at end of file diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/webclient/WebClientResponse.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/webclient/WebClientResponse.kt new file mode 100644 index 00000000..c9ac14e6 --- /dev/null +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/webclient/WebClientResponse.kt @@ -0,0 +1,36 @@ +package net.dankito.banking.fints.webclient + + +open class WebClientResponse( + val successful: Boolean, + val responseCode: Int = -1, + val error: Exception? = null, + val body: String? = null +) { + + + open val isInformationalResponse: Boolean + get() = responseCode >= 100 && responseCode < 200 + + open val isSuccessResponse: Boolean + get() = responseCode >= 200 && responseCode < 300 + + open val isRedirectionResponse: Boolean + get() = responseCode >= 300 && responseCode < 400 + + open val isClientErrorResponse: Boolean + get() = responseCode >= 400 && responseCode < 500 + + open val isServerErrorResponse: Boolean + get() = responseCode >= 500 && responseCode < 600 + + + override fun toString(): String { + if (successful) { + return "Successful: $responseCode" + } + + return "Error: $responseCode $error" + } + +} \ No newline at end of file diff --git a/fints4k/src/test/java/net/dankito/banking/fints/JavaShowcase.java b/fints4k/src/commonTest/java/net/dankito/banking/fints/JavaShowcase.java similarity index 99% rename from fints4k/src/test/java/net/dankito/banking/fints/JavaShowcase.java rename to fints4k/src/commonTest/java/net/dankito/banking/fints/JavaShowcase.java index f7863794..69b2ef63 100644 --- a/fints4k/src/test/java/net/dankito/banking/fints/JavaShowcase.java +++ b/fints4k/src/commonTest/java/net/dankito/banking/fints/JavaShowcase.java @@ -8,7 +8,7 @@ import net.dankito.banking.fints.model.AccountData; import net.dankito.banking.fints.model.AccountFeature; import net.dankito.banking.fints.model.AccountTransaction; import net.dankito.banking.fints.model.BankData; -import net.dankito.banking.fints.model.BankInfo; +import net.dankito.banking.bankfinder.BankInfo; import net.dankito.banking.fints.model.BankTransferData; import net.dankito.banking.fints.model.CustomerData; import net.dankito.banking.fints.model.EnterTanGeneratorAtcResult; diff --git a/fints4k/src/test/kotlin/net/dankito/banking/fints/FinTsClientTest.kt b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/FinTsClientTestBase.kt similarity index 52% rename from fints4k/src/test/kotlin/net/dankito/banking/fints/FinTsClientTest.kt rename to fints4k/src/commonTest/kotlin/net/dankito/banking/fints/FinTsClientTestBase.kt index fd172944..5cf767c7 100644 --- a/fints4k/src/test/kotlin/net/dankito/banking/fints/FinTsClientTest.kt +++ b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/FinTsClientTestBase.kt @@ -1,7 +1,15 @@ package net.dankito.banking.fints -import net.dankito.banking.fints.banks.InMemoryBankFinder +import ch.tutteli.atrium.api.fluent.en_GB.* +import ch.tutteli.atrium.api.verbs.expect +import com.benasher44.uuid.uuid4 +import com.ionspin.kotlin.bignum.decimal.toBigDecimal +import com.soywiz.klock.DateFormat +import com.soywiz.klock.DateTimeTz +import net.dankito.banking.bankfinder.InMemoryBankFinder import net.dankito.banking.fints.callback.FinTsClientCallback +import net.dankito.banking.fints.extensions.isTrue +import net.dankito.banking.fints.extensions.isFalse import net.dankito.banking.fints.messages.datenelemente.abgeleiteteformate.Laenderkennzeichen import net.dankito.banking.fints.messages.datenelemente.implementierte.Dialogsprache import net.dankito.banking.fints.messages.datenelemente.implementierte.KundensystemStatus @@ -12,54 +20,56 @@ import net.dankito.banking.fints.messages.datenelemente.implementierte.tan.TanMe import net.dankito.banking.fints.messages.datenelemente.implementierte.tan.TanMediumKlasse import net.dankito.banking.fints.messages.segmente.id.CustomerSegmentId import net.dankito.banking.fints.model.* -import net.dankito.banking.fints.model.mapper.BankDataMapper +import net.dankito.banking.mapper.BankDataMapper +import net.dankito.banking.bankfinder.BankInfo import net.dankito.banking.fints.response.client.FinTsClientResponse -import net.dankito.banking.fints.util.Java8Base64Service -import org.assertj.core.api.Assertions.assertThat -import org.junit.Assert -import org.junit.Ignore -import org.junit.Test -import java.time.LocalDateTime -import java.time.format.DateTimeFormatter -import java.util.* -import java.util.concurrent.atomic.AtomicBoolean +import net.dankito.banking.fints.util.IBase64Service +import net.dankito.banking.fints.util.IThreadPool +import net.dankito.banking.fints.util.PureKotlinBase64Service +import net.dankito.banking.fints.webclient.KtorWebClient +import kotlin.test.DefaultAsserter.fail +import kotlin.test.Ignore +import kotlin.test.Test @Ignore // not an automatic test, supply your settings below -class FinTsClientTest { +abstract class FinTsClientTestBase { companion object { - val DateTimeFormatForUniqueBankTransferUsage = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS") + val DateTimeFormatForUniqueBankTransferUsage = DateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS") } - private val didAskUserForTanProcedure = AtomicBoolean(false) + protected abstract fun createThreadPool(): IThreadPool - private val didAskUserToEnterTan = AtomicBoolean(false) + + private var didAskUserForTanProcedure = false + + private var didAskUserToEnterTan = false private val callback = object : FinTsClientCallback { override fun askUserForTanProcedure(supportedTanProcedures: List, suggestedTanProcedure: TanProcedure?): TanProcedure? { + didAskUserForTanProcedure = true return suggestedTanProcedure // simply return suggestedTanProcedure as in most cases it's the best fitting one } override fun enterTan(customer: CustomerData, tanChallenge: TanChallenge): EnterTanResult { - didAskUserToEnterTan.set(true) + didAskUserToEnterTan = true return EnterTanResult.userDidNotEnterTan() } override fun enterTanGeneratorAtc(customer: CustomerData, tanMedium: TanGeneratorTanMedium): EnterTanGeneratorAtcResult { - Assert.fail("Bank asks you to synchronize your TAN generator for card ${tanMedium.cardNumber} " + + fail("Bank asks you to synchronize your TAN generator for card ${tanMedium.cardNumber} " + "(card sequence number ${tanMedium.cardSequenceNumber}). Please do this via your online banking portal or Banking UI.") - return EnterTanGeneratorAtcResult.userDidNotEnterAtc() // should actually never be called } } - private val underTest = object : FinTsClient(callback, Java8Base64Service()) { + private val underTest = object : FinTsClient(callback, KtorWebClient(), PureKotlinBase64Service(), createThreadPool()) { fun testSynchronizeCustomerSystemId(bank: BankData, customer: CustomerData): FinTsClientResponse { return synchronizeCustomerSystemId(bank, customer) @@ -84,12 +94,12 @@ class FinTsClientTest { val result = underTest.getAnonymousBankInfo(BankDataAnonymous) // then - assertThat(result.isSuccessful).isTrue() - assertThat(BankDataAnonymous.supportedHbciVersions).isNotEmpty() - assertThat(BankDataAnonymous.supportedTanProcedures).isNotEmpty() - assertThat(BankDataAnonymous.supportedJobs).isNotEmpty() - assertThat(BankDataAnonymous.supportedLanguages).isNotEmpty() - assertThat(BankDataAnonymous.name).isNotEmpty() + expect(result.isSuccessful).isTrue() + expect(BankDataAnonymous.supportedHbciVersions).isNotEmpty() + expect(BankDataAnonymous.supportedTanProcedures).isNotEmpty() + expect(BankDataAnonymous.supportedJobs).isNotEmpty() + expect(BankDataAnonymous.supportedLanguages).isNotEmpty() + expect(BankDataAnonymous.name).isNotEmpty() } @@ -100,23 +110,23 @@ class FinTsClientTest { val result = underTest.addAccount(Bank, Customer) // then - assertThat(result.isSuccessful).isTrue() + expect(result.isSuccessful).isTrue() - assertThat(didAskUserForTanProcedure).isFalse() + expect(didAskUserForTanProcedure).isFalse() - assertThat(Bank.name).isNotEmpty() - assertThat(Bank.supportedJobs).isNotEmpty() // supported jobs are now known - assertThat(Bank.supportedTanProcedures).isNotEmpty() // supported tan procedures are now known - assertThat(Bank.supportedHbciVersions).isNotEmpty() // supported HBIC versions are now known - assertThat(Bank.supportedLanguages).isNotEmpty() // supported languages are now known + expect(Bank.name).isNotEmpty() + expect(Bank.supportedJobs).isNotEmpty() // supported jobs are now known + expect(Bank.supportedTanProcedures).isNotEmpty() // supported tan procedures are now known + expect(Bank.supportedHbciVersions).isNotEmpty() // supported HBIC versions are now known + expect(Bank.supportedLanguages).isNotEmpty() // supported languages are now known - assertThat(Customer.name).isNotEmpty() - assertThat(Customer.supportedTanProcedures).isNotEmpty() - assertThat(Customer.selectedLanguage).isNotEqualTo(Dialogsprache.Default) // language is set now - assertThat(Customer.customerSystemId).isNotEqualTo(KundensystemStatus.SynchronizingCustomerSystemId) // customer system id is now set - assertThat(Customer.customerSystemStatus).isEqualTo(KundensystemStatusWerte.Benoetigt) // customerSystemStatus is set now - assertThat(Customer.accounts).isNotEmpty() // accounts are now known - assertThat(Customer.accounts.first().allowedJobs).isNotEmpty() // allowed jobs are now known + expect(Customer.name).isNotEmpty() + expect(Customer.supportedTanProcedures).isNotEmpty() + expect(Customer.selectedLanguage).notToBe(Dialogsprache.Default) // language is set now + expect(Customer.customerSystemId).notToBe(KundensystemStatus.SynchronizingCustomerSystemId.code) // customer system id is now set + expect(Customer.customerSystemStatus).toBe(KundensystemStatusWerte.Benoetigt) // customerSystemStatus is set now + expect(Customer.accounts).isNotEmpty() // accounts are now known + expect(Customer.accounts.first().allowedJobs).isNotEmpty() // allowed jobs are now known } @@ -127,20 +137,21 @@ class FinTsClientTest { val result = underTest.testSynchronizeCustomerSystemId(Bank, Customer) // then - assertThat(result.isSuccessful).isTrue() - assertThat(Customer.customerSystemId).isNotEqualTo(KundensystemStatus.SynchronizingCustomerSystemId) // customer system id is now set - assertThat(Customer.selectedLanguage).isNotEqualTo(Dialogsprache.Default) // language is set now - assertThat(Customer.customerSystemStatus).isEqualTo(KundensystemStatusWerte.Benoetigt) // customerSystemStatus is set now + expect(result.isSuccessful).isTrue() + expect(Customer.customerSystemId).notToBe(KundensystemStatus.SynchronizingCustomerSystemId.code) // customer system id is now set + expect(Customer.selectedLanguage).notToBe(Dialogsprache.Default) // language is set now + expect(Customer.customerSystemStatus).toBe(KundensystemStatusWerte.Benoetigt) // customerSystemStatus is set now } + @ExperimentalWithOptions @Test fun getTransactions() { // given underTest.addAccount(Bank, Customer) // retrieve basic data, e.g. accounts val account = Customer.accounts.firstOrNull { it.supportsFeature(AccountFeature.RetrieveAccountTransactions) } - assertThat(account).describedAs("We need at least one account that supports retrieving account transactions (${CustomerSegmentId.AccountTransactionsMt940.id})").isNotNull() + expect(account).withRepresentation("We need at least one account that supports retrieving account transactions (${CustomerSegmentId.AccountTransactionsMt940.id})").notToBeNull() // when @@ -149,8 +160,8 @@ class FinTsClientTest { // then - assertThat(result.isSuccessful).isTrue() - assertThat(result.bookedTransactions).isNotEmpty() + expect(result.isSuccessful).isTrue() + expect(result.bookedTransactions).isNotEmpty() } @@ -167,7 +178,7 @@ class FinTsClientTest { return } - assertThat(Customer.tanMedia).isEmpty() + expect(Customer.tanMedia).isEmpty() // when @@ -175,21 +186,23 @@ class FinTsClientTest { // then - assertThat(result.isSuccessful).isTrue() + expect(result.isSuccessful).isTrue() - assertThat(result.tanMediaList).isNotNull() - assertThat(result.tanMediaList!!.usageOption).isEqualByComparingTo(TanEinsatzOption.KundeKannGenauEinMediumZuEinerZeitNutzen) // TODO: may adjust to your value - assertThat(result.tanMediaList!!.tanMedia).isNotEmpty() + expect(result.tanMediaList).notToBeNull() + expect(result.tanMediaList!!.usageOption).toBe(TanEinsatzOption.KundeKannGenauEinMediumZuEinerZeitNutzen) // TODO: may adjust to your value + expect(result.tanMediaList!!.tanMedia).isNotEmpty() - assertThat(Customer.tanMedia).isNotEmpty() + expect(Customer.tanMedia).isNotEmpty() } @Ignore // only works with banks that don't support HKTAB version 5 - @Test(expected = UnsupportedOperationException::class) + @Test fun getTanMediaList_UnsupportedTanMediumClass() { // when - underTest.getTanMediaList(Bank, Customer, TanMedienArtVersion.Alle, TanMediumKlasse.BilateralVereinbart) + expect { + underTest.getTanMediaList(Bank, Customer, TanMedienArtVersion.Alle, TanMediumKlasse.BilateralVereinbart) + }.toThrow() // then @@ -197,6 +210,7 @@ class FinTsClientTest { } + @ExperimentalWithOptions @Test fun testBankTransfer() { @@ -205,21 +219,21 @@ class FinTsClientTest { // we need at least one account that supports cash transfer val account = Customer.accounts.firstOrNull { it.supportsFeature(AccountFeature.TransferMoney) } - assertThat(account).describedAs("We need at least one account that supports cash transfer (${CustomerSegmentId.SepaBankTransfer.id})").isNotNull() + expect(account).withRepresentation("We need at least one account that supports cash transfer (${CustomerSegmentId.SepaBankTransfer.id})").notToBeNull() // IBAN should be set - assertThat(account?.iban).describedAs("Account IBAN must be set").isNotNull() + expect(account?.iban).withRepresentation("Account IBAN must be set").notToBeNull() // transfer 1 cent to yourself. Transferring money to oneself also doesn't require to enter a TAN according to PSD2 val BankTransferData = BankTransferData(Customer.name, account?.iban!!, Bank.bic, 0.01.toBigDecimal(), - "${DateTimeFormatForUniqueBankTransferUsage.format(LocalDateTime.now())} Test transaction ${UUID.randomUUID()}") + "${DateTimeFormatForUniqueBankTransferUsage.format(DateTimeTz.nowLocal())} Test transaction ${uuid4()}") // when val result = underTest.doBankTransfer(BankTransferData, Bank, Customer, account) // then - assertThat(result.isSuccessful).isTrue() + expect(result.isSuccessful).isTrue() } } \ No newline at end of file diff --git a/fints4k/src/test/kotlin/net/dankito/banking/fints/FinTsTestBase.kt b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/FinTsTestBase.kt similarity index 77% rename from fints4k/src/test/kotlin/net/dankito/banking/fints/FinTsTestBase.kt rename to fints4k/src/commonTest/kotlin/net/dankito/banking/fints/FinTsTestBase.kt index 69b7068a..650addd1 100644 --- a/fints4k/src/test/kotlin/net/dankito/banking/fints/FinTsTestBase.kt +++ b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/FinTsTestBase.kt @@ -1,5 +1,8 @@ package net.dankito.banking.fints +import com.benasher44.uuid.uuid4 +import com.ionspin.kotlin.bignum.decimal.BigDecimal +import com.soywiz.klock.Date import net.dankito.banking.fints.messages.datenelemente.abgeleiteteformate.Datum import net.dankito.banking.fints.messages.datenelemente.abgeleiteteformate.Laenderkennzeichen import net.dankito.banking.fints.messages.datenelemente.implementierte.Dialogsprache @@ -8,21 +11,12 @@ import net.dankito.banking.fints.model.* import net.dankito.banking.fints.response.segments.AccountType import net.dankito.banking.fints.response.segments.ChangeTanMediaParameters import net.dankito.banking.fints.response.segments.JobParameters -import java.io.File -import java.math.BigDecimal -import java.nio.charset.Charset -import java.util.* abstract class FinTsTestBase { companion object { - const val TestFilesFolderName = "test_files/" - - const val TransactionsMt940Filename = "TransactionsMt940.txt" - - const val BankCode = "12345678" const val BankCountryCode = Laenderkennzeichen.Germany @@ -71,15 +65,15 @@ abstract class FinTsTestBase { protected open fun createDialogId(): String { - return UUID.randomUUID().toString().replace("-", "") + return uuid4().toString().replace("-", "") } protected open fun convertAmount(amount: BigDecimal): String { - return amount.toString().replace('.', ',') + return amount.toStringExpanded().replace('.', ',') } protected open fun convertDate(date: Date): String { - return Datum.HbciDateFormat.format(date) + return Datum.format(date) } protected open fun unmaskString(string: String): String { @@ -95,14 +89,4 @@ abstract class FinTsTestBase { return JobParameters("", 1, 1, 1, ":0:0") } - - /** - * 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() - } - } \ No newline at end of file diff --git a/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/extensions/BooleanAssertions.kt b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/extensions/BooleanAssertions.kt new file mode 100644 index 00000000..3c5bec49 --- /dev/null +++ b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/extensions/BooleanAssertions.kt @@ -0,0 +1,9 @@ +package net.dankito.banking.fints.extensions + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.ExpectImpl + + +fun Expect.isTrue(): Expect = addAssertion(ExpectImpl.any.toBe(this, true)) + +fun Expect.isFalse(): Expect = addAssertion(ExpectImpl.any.toBe(this, false)) \ No newline at end of file diff --git a/fints4k/src/test/kotlin/net/dankito/banking/fints/messages/MessageBuilderTest.kt b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/MessageBuilderTest.kt similarity index 84% rename from fints4k/src/test/kotlin/net/dankito/banking/fints/messages/MessageBuilderTest.kt rename to fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/MessageBuilderTest.kt index ee20465c..ea74a722 100644 --- a/fints4k/src/test/kotlin/net/dankito/banking/fints/messages/MessageBuilderTest.kt +++ b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/MessageBuilderTest.kt @@ -1,17 +1,18 @@ package net.dankito.banking.fints.messages +import ch.tutteli.atrium.api.fluent.en_GB.notToBeNull +import ch.tutteli.atrium.api.fluent.en_GB.toBe +import ch.tutteli.atrium.api.verbs.expect +import com.soywiz.klock.Date +import com.soywiz.klock.Month +import com.soywiz.klock.Time import net.dankito.banking.fints.FinTsTestBase import net.dankito.banking.fints.model.* import net.dankito.banking.fints.response.segments.AccountType import net.dankito.banking.fints.response.segments.JobParameters import net.dankito.banking.fints.util.FinTsUtils -import net.dankito.utils.datetime.asUtilDate -import org.assertj.core.api.Assertions.assertThat -import org.junit.After -import org.junit.Test -import java.time.LocalDate -import java.time.Month -import java.util.* +import kotlin.test.AfterTest +import kotlin.test.Test class MessageBuilderTest : FinTsTestBase() { @@ -21,7 +22,7 @@ class MessageBuilderTest : FinTsTestBase() { return Date.toString() } - override fun formatTime(time: Date): String { + override fun formatTime(time: Time): String { return Time.toString() } }) { @@ -33,7 +34,7 @@ class MessageBuilderTest : FinTsTestBase() { } - @After + @AfterTest fun tearDown() { Bank.supportedJobs = listOf() } @@ -49,7 +50,7 @@ class MessageBuilderTest : FinTsTestBase() { val result = underTest.createAnonymousDialogInitMessage(dialogContext).createdMessage // then - assertThat(result).isEqualTo( + expect(result).toBe( "HNHBK:1:3+000000000125+300+0+1'" + "HKIDN:2:2+280:12345678+9999999999+0+0'" + "HKVVB:3:3+0+0+0+$ProductName+$ProductVersion'" + @@ -62,13 +63,13 @@ class MessageBuilderTest : FinTsTestBase() { // given val dialogId = createDialogId() - val dialogContext = DialogContext(Bank, Customer, Product, null, dialogId) + val dialogContext = DialogContext(Bank, Customer, Product, false, null, dialogId) // when val result = underTest.createAnonymousDialogEndMessage(dialogContext).createdMessage ?: "" // then - assertThat(normalizeBinaryData(result)).isEqualTo(normalizeBinaryData( + expect(normalizeBinaryData(result)).toBe(normalizeBinaryData( "HNHBK:1:3+000000000086+300+$dialogId+1'" + "HKEND:2:1+$dialogId'" + "HNHBS:3:1+1'" @@ -86,7 +87,7 @@ class MessageBuilderTest : FinTsTestBase() { val result = underTest.createSynchronizeCustomerSystemIdMessage(dialogContext).createdMessage ?: "" // then - assertThat(normalizeBinaryData(result)).isEqualTo(normalizeBinaryData( + expect(normalizeBinaryData(result)).toBe(normalizeBinaryData( "HNHBK:1:3+000000000398+300+0+1'" + "HNVSK:998:3+PIN:2+998+1+1::0+1:$Date:$Time+2:16:14:@8@ :5:1+280:$BankCode:$CustomerId:V:0:0+0'" + "HNVSD:999:1+@234@" + "HNSHK:2:4+PIN:2+${SecurityFunction.code}+$ControlReference+1+1+1::0+1+1:$Date:$Time+1:999:1+6:10:16+280:$BankCode:$CustomerId:S:0:0'" + @@ -104,13 +105,13 @@ class MessageBuilderTest : FinTsTestBase() { // given val dialogId = createDialogId() - val dialogContext = DialogContext(Bank, Customer, Product, null, dialogId) + val dialogContext = DialogContext(Bank, Customer, Product, false, null, dialogId) // when val result = underTest.createDialogEndMessage(dialogContext).createdMessage ?: "" // then - assertThat(normalizeBinaryData(result)).isEqualTo(normalizeBinaryData( + expect(normalizeBinaryData(result)).toBe(normalizeBinaryData( "HNHBK:1:3+000000000329+300+$dialogId+1'" + "HNVSK:998:3+PIN:2+998+1+1::0+1:$Date:$Time+2:16:14:@8@ :5:1+280:$BankCode:$CustomerId:V:0:0+0'" + "HNVSD:999:1+@165@" + "HNSHK:2:4+PIN:2+${SecurityFunction.code}+$ControlReference+1+1+1::0+1+1:$Date:$Time+1:999:1+6:10:16+280:$BankCode:$CustomerId:S:0:0'" + @@ -131,7 +132,7 @@ class MessageBuilderTest : FinTsTestBase() { val result = underTest.createGetTransactionsMessage(GetTransactionsParameter(), Account, dialogContext) // then - assertThat(result.isJobAllowed).isFalse() + expect(result.isJobAllowed).toBe(false) } @Test @@ -149,8 +150,8 @@ class MessageBuilderTest : FinTsTestBase() { val result = underTest.createGetTransactionsMessage(GetTransactionsParameter(), account, dialogContext) // then - assertThat(result.isJobAllowed).isTrue() - assertThat(result.isJobVersionSupported).isFalse() + expect(result.isJobAllowed).toBe(true) + expect(result.isJobVersionSupported).toBe(false) } @Test @@ -163,17 +164,17 @@ class MessageBuilderTest : FinTsTestBase() { Customer.addAccount(account) val dialogContext = DialogContext(Bank, Customer, Product) - val fromDate = LocalDate.of(2019, Month.AUGUST, 6).asUtilDate() - val toDate = LocalDate.of(2019, Month.OCTOBER, 21).asUtilDate() + val fromDate = Date(2019, Month.August, 6) + val toDate = Date(2019, Month.October, 21) val maxCountEntries = 99 // when val result = underTest.createGetTransactionsMessage(GetTransactionsParameter(false, fromDate, toDate, maxCountEntries), account, dialogContext) // then - assertThat(result.createdMessage).isNotNull() + expect(result.createdMessage).notToBeNull() - assertThat(normalizeBinaryData(result.createdMessage!!)).isEqualTo(normalizeBinaryData( + expect(normalizeBinaryData(result.createdMessage!!)).toBe(normalizeBinaryData( "HNHBK:1:3+000000000362+300+0+1'" + "HNVSK:998:3+PIN:2+998+1+1::0+1:$Date:$Time+2:16:14:@8@ :5:1+280:$BankCode:$CustomerId:V:0:0+0'" + "HNVSD:999:1+@198@" + "HNSHK:2:4+PIN:2+${SecurityFunction.code}+$ControlReference+1+1+1::0+1+1:$Date:$Time+1:999:1+6:10:16+280:$BankCode:$CustomerId:S:0:0'" + @@ -194,18 +195,18 @@ class MessageBuilderTest : FinTsTestBase() { Customer.addAccount(account) val dialogContext = DialogContext(Bank, Customer, Product) - val fromDate = LocalDate.of(2019, Month.AUGUST, 6).asUtilDate() - val toDate = LocalDate.of(2019, Month.OCTOBER, 21).asUtilDate() + val fromDate = Date(2019, Month.August, 6) + val toDate = Date(2019, Month.October, 21) val maxCountEntries = 99 val continuationId = "9345-10-26-11.52.15.693455" // when - val result = underTest.createGetTransactionsMessage(GetTransactionsParameter(false, fromDate, toDate, maxCountEntries, false, continuationId), account, dialogContext) + val result = underTest.createGetTransactionsMessage(GetTransactionsParameter(false, fromDate, toDate, maxCountEntries, false), account, dialogContext) // TODO: test Aufsetzpunkt / continuationId // then - assertThat(result.createdMessage).isNotNull() + expect(result.createdMessage).notToBeNull() - assertThat(normalizeBinaryData(result.createdMessage!!)).isEqualTo(normalizeBinaryData( + expect(normalizeBinaryData(result.createdMessage!!)).toBe(normalizeBinaryData( "HNHBK:1:3+000000000389+300+0+1'" + "HNVSK:998:3+PIN:2+998+1+1::0+1:$Date:$Time+2:16:14:@8@ :5:1+280:$BankCode:$CustomerId:V:0:0+0'" + "HNVSD:999:1+@225@" + "HNSHK:2:4+PIN:2+${SecurityFunction.code}+$ControlReference+1+1+1::0+1+1:$Date:$Time+1:999:1+6:10:16+280:$BankCode:$CustomerId:S:0:0'" + diff --git a/fints4k/src/test/kotlin/net/dankito/banking/fints/messages/datenelemente/basisformate/TextDatenelementTest.kt b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/datenelemente/basisformate/TextDatenelementTest.kt similarity index 81% rename from fints4k/src/test/kotlin/net/dankito/banking/fints/messages/datenelemente/basisformate/TextDatenelementTest.kt rename to fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/datenelemente/basisformate/TextDatenelementTest.kt index 0dceece0..1d20512c 100644 --- a/fints4k/src/test/kotlin/net/dankito/banking/fints/messages/datenelemente/basisformate/TextDatenelementTest.kt +++ b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/datenelemente/basisformate/TextDatenelementTest.kt @@ -1,9 +1,11 @@ package net.dankito.banking.fints.messages.datenelemente.basisformate +import ch.tutteli.atrium.api.fluent.en_GB.toBe +import ch.tutteli.atrium.api.fluent.en_GB.toThrow +import ch.tutteli.atrium.api.verbs.expect import net.dankito.banking.fints.messages.Existenzstatus import net.dankito.banking.fints.messages.datenelementgruppen.implementierte.signatur.SicherheitsidentifikationDetails -import org.assertj.core.api.Assertions.assertThat -import org.junit.Test +import kotlin.test.Test class TextDatenelementTest { @@ -21,43 +23,40 @@ class TextDatenelementTest { // no exception } - @Test(expected = IllegalArgumentException::class) + @Test fun validate_GreekCharacter_Invalid() { // given val underTest = createTextDatenelement("α") // when - underTest.validate() - - // then - // exception gets thrown + expect { + underTest.validate() + }.toThrow() } - @Test(expected = IllegalArgumentException::class) + @Test fun validate_CyrillicCharacter_Invalid() { // given val underTest = createTextDatenelement("Я") // when - underTest.validate() - - // then - // exception gets thrown + expect { + underTest.validate() + }.toThrow() } - @Test(expected = IllegalArgumentException::class) + @Test fun validate_EuroSymbol_Invalid() { // given val underTest = createTextDatenelement("€") // is only allowed by ISO-8859-15, not by ISO-8859-1 // when - underTest.validate() - - // then - // exception gets thrown + expect { + underTest.validate() + }.toThrow() } @@ -76,7 +75,7 @@ class TextDatenelementTest { // then - assertThat(result).isEqualTo(expected) + expect(result).toBe(expected) } @Test @@ -94,7 +93,7 @@ class TextDatenelementTest { // then - assertThat(result).isEqualTo(expected) + expect(result).toBe(expected) } @Test @@ -112,7 +111,7 @@ class TextDatenelementTest { // then - assertThat(result).isEqualTo(expected) + expect(result).toBe(expected) } @Test @@ -131,7 +130,7 @@ class TextDatenelementTest { // then - assertThat(result).isEqualTo(expected) + expect(result).toBe(expected) } diff --git a/fints4k/src/test/kotlin/net/dankito/banking/fints/messages/datenelemente/basisformate/ZiffernDatenelementTest.kt b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/datenelemente/basisformate/ZiffernDatenelementTest.kt similarity index 74% rename from fints4k/src/test/kotlin/net/dankito/banking/fints/messages/datenelemente/basisformate/ZiffernDatenelementTest.kt rename to fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/datenelemente/basisformate/ZiffernDatenelementTest.kt index 542b5d11..1eda7d14 100644 --- a/fints4k/src/test/kotlin/net/dankito/banking/fints/messages/datenelemente/basisformate/ZiffernDatenelementTest.kt +++ b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/datenelemente/basisformate/ZiffernDatenelementTest.kt @@ -1,8 +1,10 @@ package net.dankito.banking.fints.messages.datenelemente.basisformate +import ch.tutteli.atrium.api.fluent.en_GB.toBe +import ch.tutteli.atrium.api.fluent.en_GB.toThrow +import ch.tutteli.atrium.api.verbs.expect import net.dankito.banking.fints.messages.Existenzstatus -import org.assertj.core.api.Assertions.assertThat -import org.junit.Test +import kotlin.test.Test class ZiffernDatenelementTest { @@ -17,7 +19,7 @@ class ZiffernDatenelementTest { val result = underTest.format() // then - assertThat(result).isEqualTo("000001") + expect(result).toBe("000001") } @@ -47,30 +49,28 @@ class ZiffernDatenelementTest { // no exception } - @Test(expected = IllegalArgumentException::class) + @Test fun validate_Minus1_Invalid() { // given val underTest = createZiffernDatenelement(-1, 3) // when - underTest.validate() - - // then - // exception gets thrown + expect { + underTest.validate() + }.toThrow() } - @Test(expected = IllegalArgumentException::class) + @Test fun validate_1000_Invalid() { // given val underTest = createZiffernDatenelement(1000, 3) // when - underTest.validate() - - // then - // exception gets thrown + expect { + underTest.validate() + }.toThrow() } diff --git a/fints4k/src/test/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/BPDVersionTest.kt b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/BPDVersionTest.kt similarity index 72% rename from fints4k/src/test/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/BPDVersionTest.kt rename to fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/BPDVersionTest.kt index 9ab6e32f..3a233e50 100644 --- a/fints4k/src/test/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/BPDVersionTest.kt +++ b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/BPDVersionTest.kt @@ -1,8 +1,10 @@ package net.dankito.banking.fints.messages.datenelemente.implementierte +import ch.tutteli.atrium.api.fluent.en_GB.toBe +import ch.tutteli.atrium.api.fluent.en_GB.toThrow +import ch.tutteli.atrium.api.verbs.expect import net.dankito.banking.fints.messages.Existenzstatus -import org.assertj.core.api.Assertions.assertThat -import org.junit.Test +import kotlin.test.Test class BPDVersionTest { @@ -17,7 +19,7 @@ class BPDVersionTest { val result = underTest.format() // then - assertThat(result).isEqualTo("3") + expect(result).toBe("3") } @@ -47,30 +49,28 @@ class BPDVersionTest { // no exception } - @Test(expected = IllegalArgumentException::class) + @Test fun validate_TooLow() { // given val underTest = BPDVersion(-1, Existenzstatus.Mandatory) // when - underTest.validate() - - // then - // exception gets thrown + expect { + underTest.validate() + }.toThrow() } - @Test(expected = IllegalArgumentException::class) + @Test fun validate_TooHigh() { // given val underTest = BPDVersion(1000, Existenzstatus.Mandatory) // when - underTest.validate() - - // then - // exception gets thrown + expect { + underTest.validate() + }.toThrow() } } \ No newline at end of file diff --git a/fints4k/src/test/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/ProduktbezeichnungTest.kt b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/ProduktbezeichnungTest.kt similarity index 72% rename from fints4k/src/test/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/ProduktbezeichnungTest.kt rename to fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/ProduktbezeichnungTest.kt index 044f736c..41b3720c 100644 --- a/fints4k/src/test/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/ProduktbezeichnungTest.kt +++ b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/datenelemente/implementierte/ProduktbezeichnungTest.kt @@ -1,7 +1,9 @@ package net.dankito.banking.fints.messages.datenelemente.implementierte +import ch.tutteli.atrium.api.fluent.en_GB.toThrow +import ch.tutteli.atrium.api.verbs.expect import net.dankito.banking.fints.messages.Existenzstatus -import org.junit.Test +import kotlin.test.Test class ProduktbezeichnungTest { @@ -19,17 +21,16 @@ class ProduktbezeichnungTest { // no exception } - @Test(expected = IllegalArgumentException::class) + @Test fun validate_MaxLengthExceeded() { // given val underTest = Produktbezeichnung("12345678901234567890123456", Existenzstatus.Mandatory) // when - underTest.validate() - - // then - // exception gets thrown + expect { + underTest.validate() + }.toThrow() } } \ No newline at end of file diff --git a/fints4k/src/test/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/DatenelementgruppeTest.kt b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/DatenelementgruppeTest.kt similarity index 73% rename from fints4k/src/test/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/DatenelementgruppeTest.kt rename to fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/DatenelementgruppeTest.kt index 1072aaca..e08a496d 100644 --- a/fints4k/src/test/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/DatenelementgruppeTest.kt +++ b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/datenelementgruppen/DatenelementgruppeTest.kt @@ -1,9 +1,11 @@ package net.dankito.banking.fints.messages.datenelementgruppen +import ch.tutteli.atrium.api.fluent.en_GB.isEmpty +import ch.tutteli.atrium.api.fluent.en_GB.toBe +import ch.tutteli.atrium.api.verbs.expect import net.dankito.banking.fints.messages.Separators import net.dankito.banking.fints.messages.datenelementgruppen.implementierte.signatur.BenutzerdefinierteSignatur -import org.assertj.core.api.Assertions.assertThat -import org.junit.Test +import kotlin.test.Test class DatenelementgruppeTest { @@ -20,7 +22,7 @@ class DatenelementgruppeTest { val result = dataElementGroup.format() // then - assertThat(result).isEqualTo(pin + Separators.DataElementsSeparator + tan) // ":" does not get written to output + expect(result).toBe(pin + Separators.DataElementsSeparator + tan) // ":" does not get written to output } @Test @@ -35,7 +37,7 @@ class DatenelementgruppeTest { val result = dataElementGroup.format() // then - assertThat(result).isEqualTo(pin) // ":" does not get written to output + expect(result).toBe(pin) // ":" does not get written to output } @Test @@ -50,7 +52,7 @@ class DatenelementgruppeTest { val result = dataElementGroup.format() // then - assertThat(result).isEmpty() // ":" does not get written to output + expect(result).isEmpty() // ":" does not get written to output } } \ No newline at end of file diff --git a/fints4k/src/test/kotlin/net/dankito/banking/fints/messages/segmente/SegmentTest.kt b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/segmente/SegmentTest.kt similarity index 88% rename from fints4k/src/test/kotlin/net/dankito/banking/fints/messages/segmente/SegmentTest.kt rename to fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/segmente/SegmentTest.kt index 8bc01dcd..5ded8e8b 100644 --- a/fints4k/src/test/kotlin/net/dankito/banking/fints/messages/segmente/SegmentTest.kt +++ b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/segmente/SegmentTest.kt @@ -1,10 +1,11 @@ package net.dankito.banking.fints.messages.segmente +import ch.tutteli.atrium.api.fluent.en_GB.toBe import net.dankito.banking.fints.messages.Existenzstatus import net.dankito.banking.fints.messages.datenelemente.DatenelementBase import net.dankito.banking.fints.messages.datenelemente.basisformate.TextDatenelement -import org.assertj.core.api.Assertions.assertThat -import org.junit.Test +import ch.tutteli.atrium.api.verbs.expect +import kotlin.test.Test class SegmentTest { @@ -31,7 +32,7 @@ class SegmentTest { // then // assert that empty data elements at end get cut but that the empty ones in the middle remain - assertThat(result).isEqualTo("DE1+DE2++++DE6++DE8") + expect(result).toBe("DE1+DE2++++DE6++DE8") } diff --git a/fints4k/src/test/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/IdentifikationsSegmentTest.kt b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/IdentifikationsSegmentTest.kt similarity index 70% rename from fints4k/src/test/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/IdentifikationsSegmentTest.kt rename to fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/IdentifikationsSegmentTest.kt index 72468111..5a70ad90 100644 --- a/fints4k/src/test/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/IdentifikationsSegmentTest.kt +++ b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/IdentifikationsSegmentTest.kt @@ -1,9 +1,10 @@ package net.dankito.banking.fints.messages.segmente.implementierte +import ch.tutteli.atrium.api.fluent.en_GB.toBe import net.dankito.banking.fints.FinTsTestBase import net.dankito.banking.fints.model.MessageBaseData -import org.assertj.core.api.Assertions.assertThat -import org.junit.Test +import ch.tutteli.atrium.api.verbs.expect +import kotlin.test.Test class IdentifikationsSegmentTest : FinTsTestBase() { @@ -18,7 +19,7 @@ class IdentifikationsSegmentTest : FinTsTestBase() { val result = underTest.format() // then - assertThat(result).isEqualTo("HKIDN:2:2+280:12345678+0987654321+0+0") + expect(result).toBe("HKIDN:2:2+280:12345678+0987654321+0+0") } } \ No newline at end of file diff --git a/fints4k/src/test/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/SignaturabschlussTest.kt b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/SignaturabschlussTest.kt similarity index 68% rename from fints4k/src/test/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/SignaturabschlussTest.kt rename to fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/SignaturabschlussTest.kt index 66f51663..21c78aa8 100644 --- a/fints4k/src/test/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/SignaturabschlussTest.kt +++ b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/SignaturabschlussTest.kt @@ -1,7 +1,8 @@ package net.dankito.banking.fints.messages.segmente.implementierte -import org.assertj.core.api.Assertions.assertThat -import org.junit.Test +import ch.tutteli.atrium.api.fluent.en_GB.toBe +import ch.tutteli.atrium.api.verbs.expect +import kotlin.test.Test class SignaturabschlussTest { @@ -19,7 +20,7 @@ class SignaturabschlussTest { val result = underTest.format() // then - assertThat(result).isEqualTo("HNSHA:$segmentNumber:2+$controlReference++$pin") + expect(result).toBe("HNSHA:$segmentNumber:2+$controlReference++$pin") } } \ No newline at end of file diff --git a/fints4k/src/test/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/SignaturkopfTest.kt b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/SignaturkopfTest.kt similarity index 65% rename from fints4k/src/test/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/SignaturkopfTest.kt rename to fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/SignaturkopfTest.kt index bb5e295a..dd92225e 100644 --- a/fints4k/src/test/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/SignaturkopfTest.kt +++ b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/SignaturkopfTest.kt @@ -1,9 +1,10 @@ package net.dankito.banking.fints.messages.segmente.implementierte +import ch.tutteli.atrium.api.fluent.en_GB.toBe import net.dankito.banking.fints.FinTsTestBase import net.dankito.banking.fints.model.MessageBaseData -import org.assertj.core.api.Assertions.assertThat -import org.junit.Test +import ch.tutteli.atrium.api.verbs.expect +import kotlin.test.Test class SignaturkopfTest : FinTsTestBase() { @@ -21,7 +22,7 @@ class SignaturkopfTest : FinTsTestBase() { val result = underTest.format() // then - assertThat(result).isEqualTo("HNSHK:2:4+PIN:2+${SecurityFunction.code}+$controlReference+1+1+1::0+1+1:$Date:$Time+1:999:1+6:10:16+280:$BankCode:$CustomerId:S:0:0") + expect(result).toBe("HNSHK:2:4+PIN:2+${SecurityFunction.code}+$controlReference+1+1+1::0+1+1:$Date:$Time+1:999:1+6:10:16+280:$BankCode:$CustomerId:S:0:0") } } \ No newline at end of file diff --git a/fints4k/src/test/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/VerschluesselungskopfTest.kt b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/VerschluesselungskopfTest.kt similarity index 63% rename from fints4k/src/test/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/VerschluesselungskopfTest.kt rename to fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/VerschluesselungskopfTest.kt index 23d79cf0..8c8a099b 100644 --- a/fints4k/src/test/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/VerschluesselungskopfTest.kt +++ b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/VerschluesselungskopfTest.kt @@ -1,9 +1,10 @@ package net.dankito.banking.fints.messages.segmente.implementierte +import ch.tutteli.atrium.api.fluent.en_GB.toBe import net.dankito.banking.fints.FinTsTestBase import net.dankito.banking.fints.model.MessageBaseData -import org.assertj.core.api.Assertions.assertThat -import org.junit.Test +import ch.tutteli.atrium.api.verbs.expect +import kotlin.test.Test class VerschluesselungskopfTest : FinTsTestBase() { @@ -19,7 +20,7 @@ class VerschluesselungskopfTest : FinTsTestBase() { val result = underTest.format() // then - assertThat(normalizeBinaryData(result)).isEqualTo("HNVSK:998:3+PIN:2+998+1+1::0+1:$Date:$Time+2:16:14:@8@ :5:1+280:$BankCode:$CustomerId:V:0:0+0") + expect(normalizeBinaryData(result)).toBe("HNVSK:998:3+PIN:2+998+1+1::0+1:$Date:$Time+2:16:14:@8@ :5:1+280:$BankCode:$CustomerId:V:0:0+0") } } \ No newline at end of file diff --git a/fints4k/src/test/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/SepaBankTransferBaseTest.kt b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/SepaBankTransferBaseTest.kt similarity index 84% rename from fints4k/src/test/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/SepaBankTransferBaseTest.kt rename to fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/SepaBankTransferBaseTest.kt index d56d8cf0..19fa2417 100644 --- a/fints4k/src/test/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/SepaBankTransferBaseTest.kt +++ b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/SepaBankTransferBaseTest.kt @@ -1,11 +1,13 @@ package net.dankito.banking.fints.messages.segmente.implementierte.sepa +import ch.tutteli.atrium.api.fluent.en_GB.contains +import ch.tutteli.atrium.api.verbs.expect +import com.ionspin.kotlin.bignum.decimal.toBigDecimal import net.dankito.banking.fints.messages.segmente.id.CustomerSegmentId import net.dankito.banking.fints.model.AccountData import net.dankito.banking.fints.model.BankTransferData import net.dankito.banking.fints.model.CustomerData -import org.assertj.core.api.Assertions.assertThat -import org.junit.Test +import kotlin.test.Test class SepaBankTransferBaseTest { @@ -43,7 +45,7 @@ class SepaBankTransferBaseTest { // then - assertThat(result).contains(debitorName, debitorIban, debitorBic, creditorName, creditorIban, creditorBic, + expect(result).contains(debitorName, debitorIban, debitorBic, creditorName, creditorIban, creditorBic, amount.toString(), usage, "urn?:iso?:std?:iso?:20022?:tech?:xsd?:pain.001.001.03") } @@ -65,7 +67,7 @@ class SepaBankTransferBaseTest { // then - assertThat(result).contains(debitorName, debitorIban, debitorBic, creditorName, creditorIban, creditorBic, + expect(result).contains(debitorName, debitorIban, debitorBic, creditorName, creditorIban, creditorBic, amount.toString(), usage, "urn?:iso?:std?:iso?:20022?:tech?:xsd?:pain.001.003.03") } diff --git a/fints4k/src/test/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/SepaMessageCreatorTest.kt b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/SepaMessageCreatorTest.kt similarity index 79% rename from fints4k/src/test/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/SepaMessageCreatorTest.kt rename to fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/SepaMessageCreatorTest.kt index 5629b8e3..ed353271 100644 --- a/fints4k/src/test/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/SepaMessageCreatorTest.kt +++ b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/SepaMessageCreatorTest.kt @@ -1,7 +1,9 @@ package net.dankito.banking.fints.messages.segmente.implementierte.sepa -import org.assertj.core.api.Assertions.assertThat -import org.junit.Test +import ch.tutteli.atrium.api.verbs.expect +import net.dankito.banking.fints.extensions.isFalse +import net.dankito.banking.fints.extensions.isTrue +import kotlin.test.Test class SepaMessageCreatorTest { @@ -16,7 +18,7 @@ class SepaMessageCreatorTest { val result = underTest.containsOnlyAllowedCharacters("Marieke Musterfrau") // then - assertThat(result).isTrue() + expect(result).isTrue() } @Test @@ -26,7 +28,7 @@ class SepaMessageCreatorTest { val result = underTest.containsOnlyAllowedCharacters("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789,.?+-/()") // then - assertThat(result).isTrue() + expect(result).isTrue() } @Test @@ -36,7 +38,7 @@ class SepaMessageCreatorTest { val result = underTest.containsOnlyAllowedCharacters(":") // then - assertThat(result).isTrue() + expect(result).isTrue() } @Test @@ -46,7 +48,7 @@ class SepaMessageCreatorTest { val result = underTest.containsOnlyAllowedCharacters("!") // then - assertThat(result).isFalse() + expect(result).isFalse() } @Test @@ -56,7 +58,7 @@ class SepaMessageCreatorTest { val result = underTest.containsOnlyAllowedCharacters("€") // then - assertThat(result).isFalse() + expect(result).isFalse() } @Test @@ -66,7 +68,7 @@ class SepaMessageCreatorTest { val result = underTest.containsOnlyAllowedCharacters("@") // then - assertThat(result).isFalse() + expect(result).isFalse() } @Test @@ -76,7 +78,7 @@ class SepaMessageCreatorTest { val result = underTest.containsOnlyAllowedCharacters("ö") // then - assertThat(result).isFalse() + expect(result).isFalse() } } \ No newline at end of file diff --git a/fints4k/src/test/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/tan/TanGeneratorTanMediumAnOderUmmeldenTest.kt b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/tan/TanGeneratorTanMediumAnOderUmmeldenTest.kt similarity index 82% rename from fints4k/src/test/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/tan/TanGeneratorTanMediumAnOderUmmeldenTest.kt rename to fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/tan/TanGeneratorTanMediumAnOderUmmeldenTest.kt index 504c5907..ae8c4d7d 100644 --- a/fints4k/src/test/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/tan/TanGeneratorTanMediumAnOderUmmeldenTest.kt +++ b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/tan/TanGeneratorTanMediumAnOderUmmeldenTest.kt @@ -1,12 +1,14 @@ package net.dankito.banking.fints.messages.segmente.implementierte.tan +import ch.tutteli.atrium.api.fluent.en_GB.toBe +import ch.tutteli.atrium.api.verbs.expect import net.dankito.banking.fints.FinTsTestBase import net.dankito.banking.fints.messages.datenelemente.implementierte.tan.TanGeneratorTanMedium import net.dankito.banking.fints.messages.datenelemente.implementierte.tan.TanMediumKlasse import net.dankito.banking.fints.messages.datenelemente.implementierte.tan.TanMediumStatus import net.dankito.banking.fints.response.segments.ChangeTanMediaParameters -import org.assertj.core.api.Assertions.assertThat -import org.junit.Test +import kotlin.test.Test + class TanGeneratorTanMediumAnOderUmmeldenTest: FinTsTestBase() { @@ -48,7 +50,7 @@ class TanGeneratorTanMediumAnOderUmmeldenTest: FinTsTestBase() { // then - assertThat(result).isEqualTo("HKTAU:$SegmentNumber:1+G+$CardNumber") + expect(result).toBe("HKTAU:$SegmentNumber:1+G+$CardNumber") } @Test @@ -65,7 +67,7 @@ class TanGeneratorTanMediumAnOderUmmeldenTest: FinTsTestBase() { // then - assertThat(result).isEqualTo("HKTAU:$SegmentNumber:1+G+$CardNumber+++$ATC+$TAN") + expect(result).toBe("HKTAU:$SegmentNumber:1+G+$CardNumber+++$ATC+$TAN") } @Test @@ -82,7 +84,7 @@ class TanGeneratorTanMediumAnOderUmmeldenTest: FinTsTestBase() { // then - assertThat(result).isEqualTo("HKTAU:$SegmentNumber:1+G+$CardNumber+$CardSequenceNumber") + expect(result).toBe("HKTAU:$SegmentNumber:1+G+$CardNumber+$CardSequenceNumber") } @Test @@ -99,7 +101,7 @@ class TanGeneratorTanMediumAnOderUmmeldenTest: FinTsTestBase() { // then - assertThat(result).isEqualTo("HKTAU:$SegmentNumber:1+G+$CardNumber+$CardSequenceNumber++$ATC+$TAN") + expect(result).toBe("HKTAU:$SegmentNumber:1+G+$CardNumber+$CardSequenceNumber++$ATC+$TAN") } @@ -117,7 +119,7 @@ class TanGeneratorTanMediumAnOderUmmeldenTest: FinTsTestBase() { // then - assertThat(result).isEqualTo("HKTAU:$SegmentNumber:2+G+$CardNumber+++$CustomerId::$BankCountryCode:$BankCode") + expect(result).toBe("HKTAU:$SegmentNumber:2+G+$CardNumber+++$CustomerId::$BankCountryCode:$BankCode") } @Test @@ -134,7 +136,7 @@ class TanGeneratorTanMediumAnOderUmmeldenTest: FinTsTestBase() { // then - assertThat(result).isEqualTo("HKTAU:$SegmentNumber:2+G+$CardNumber+++$CustomerId::$BankCountryCode:$BankCode++++$ATC+$TAN") + expect(result).toBe("HKTAU:$SegmentNumber:2+G+$CardNumber+++$CustomerId::$BankCountryCode:$BankCode++++$ATC+$TAN") } @Test @@ -151,7 +153,7 @@ class TanGeneratorTanMediumAnOderUmmeldenTest: FinTsTestBase() { // then - assertThat(result).isEqualTo("HKTAU:$SegmentNumber:2+G+$CardNumber+$CardSequenceNumber++$CustomerId::$BankCountryCode:$BankCode") + expect(result).toBe("HKTAU:$SegmentNumber:2+G+$CardNumber+$CardSequenceNumber++$CustomerId::$BankCountryCode:$BankCode") } @Test @@ -168,7 +170,7 @@ class TanGeneratorTanMediumAnOderUmmeldenTest: FinTsTestBase() { // then - assertThat(result).isEqualTo("HKTAU:$SegmentNumber:2+G+$CardNumber++$CardType+$CustomerId::$BankCountryCode:$BankCode") + expect(result).toBe("HKTAU:$SegmentNumber:2+G+$CardNumber++$CardType+$CustomerId::$BankCountryCode:$BankCode") } @Test @@ -185,7 +187,7 @@ class TanGeneratorTanMediumAnOderUmmeldenTest: FinTsTestBase() { // then - assertThat(result).isEqualTo("HKTAU:$SegmentNumber:2+G+$CardNumber+$CardSequenceNumber+$CardType+$CustomerId::$BankCountryCode:$BankCode++++$ATC+$TAN") + expect(result).toBe("HKTAU:$SegmentNumber:2+G+$CardNumber+$CardSequenceNumber+$CardType+$CustomerId::$BankCountryCode:$BankCode++++$ATC+$TAN") } // TODO: may also test 'gueltig ab' and 'gueltig bis' diff --git a/fints4k/src/test/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/SaldenabfrageVersion5Test.kt b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/SaldenabfrageVersion5Test.kt similarity index 69% rename from fints4k/src/test/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/SaldenabfrageVersion5Test.kt rename to fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/SaldenabfrageVersion5Test.kt index 11e74822..a7e951a5 100644 --- a/fints4k/src/test/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/SaldenabfrageVersion5Test.kt +++ b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/SaldenabfrageVersion5Test.kt @@ -1,8 +1,9 @@ package net.dankito.banking.fints.messages.segmente.implementierte.umsaetze +import ch.tutteli.atrium.api.fluent.en_GB.toBe +import ch.tutteli.atrium.api.verbs.expect import net.dankito.banking.fints.FinTsTestBase -import org.assertj.core.api.Assertions.assertThat -import org.junit.Test +import kotlin.test.Test class SaldenabfrageVersion5Test : FinTsTestBase() { @@ -17,7 +18,7 @@ class SaldenabfrageVersion5Test : FinTsTestBase() { val result = underTest.format() // then - assertThat(result).isEqualTo("HKSAL:3:5+$CustomerId::280:$BankCode+N") + expect(result).toBe("HKSAL:3:5+$CustomerId::280:$BankCode+N") } @Test @@ -30,7 +31,7 @@ class SaldenabfrageVersion5Test : FinTsTestBase() { val result = underTest.format() // then - assertThat(result).isEqualTo("HKSAL:3:5+$CustomerId::280:$BankCode+J") + expect(result).toBe("HKSAL:3:5+$CustomerId::280:$BankCode+J") } } \ No newline at end of file diff --git a/fints4k/src/test/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/SaldenabfrageVersion7Test.kt b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/SaldenabfrageVersion7Test.kt similarity index 69% rename from fints4k/src/test/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/SaldenabfrageVersion7Test.kt rename to fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/SaldenabfrageVersion7Test.kt index 5e70da22..9fd3f935 100644 --- a/fints4k/src/test/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/SaldenabfrageVersion7Test.kt +++ b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/umsaetze/SaldenabfrageVersion7Test.kt @@ -1,8 +1,9 @@ package net.dankito.banking.fints.messages.segmente.implementierte.umsaetze +import ch.tutteli.atrium.api.fluent.en_GB.toBe import net.dankito.banking.fints.FinTsTestBase -import org.assertj.core.api.Assertions.assertThat -import org.junit.Test +import ch.tutteli.atrium.api.verbs.expect +import kotlin.test.Test class SaldenabfrageVersion7Test : FinTsTestBase() { @@ -17,7 +18,7 @@ class SaldenabfrageVersion7Test : FinTsTestBase() { val result = underTest.format() // then - assertThat(result).isEqualTo("HKSAL:3:7+$Iban::$CustomerId::280:$BankCode+N") + expect(result).toBe("HKSAL:3:7+$Iban::$CustomerId::280:$BankCode+N") } @Test @@ -30,7 +31,7 @@ class SaldenabfrageVersion7Test : FinTsTestBase() { val result = underTest.format() // then - assertThat(result).isEqualTo("HKSAL:3:7+$Iban::$CustomerId::280:$BankCode+J") + expect(result).toBe("HKSAL:3:7+$Iban::$CustomerId::280:$BankCode+J") } } \ No newline at end of file diff --git a/fints4k/src/test/kotlin/net/dankito/banking/fints/response/ResponseParserTest.kt b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/response/ResponseParserTest.kt similarity index 60% rename from fints4k/src/test/kotlin/net/dankito/banking/fints/response/ResponseParserTest.kt rename to fints4k/src/commonTest/kotlin/net/dankito/banking/fints/response/ResponseParserTest.kt index dc9bdf6d..e547e4fe 100644 --- a/fints4k/src/test/kotlin/net/dankito/banking/fints/response/ResponseParserTest.kt +++ b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/response/ResponseParserTest.kt @@ -1,7 +1,7 @@ package net.dankito.banking.fints.response +import ch.tutteli.atrium.api.fluent.en_GB.* import net.dankito.banking.fints.FinTsTestBase -import net.dankito.banking.fints.messages.HbciCharset import net.dankito.banking.fints.messages.datenelemente.implementierte.Dialogsprache import net.dankito.banking.fints.messages.datenelemente.implementierte.HbciVersion import net.dankito.banking.fints.messages.datenelemente.implementierte.signatur.Sicherheitsfunktion @@ -12,11 +12,13 @@ import net.dankito.banking.fints.messages.datenelementgruppen.implementierte.sig import net.dankito.banking.fints.messages.segmente.id.ISegmentId import net.dankito.banking.fints.messages.segmente.id.MessageSegmentId import net.dankito.banking.fints.response.segments.* -import net.dankito.banking.fints.tan.TanImageDecoder -import org.assertj.core.api.Assertions.assertThat -import org.junit.Assert -import org.junit.Test -import java.math.BigDecimal +import ch.tutteli.atrium.api.verbs.expect +import com.ionspin.kotlin.bignum.decimal.BigDecimal +import com.ionspin.kotlin.bignum.decimal.toBigDecimal +import net.dankito.banking.fints.extensions.isFalse +import net.dankito.banking.fints.extensions.isTrue +import kotlin.test.Test +import kotlin.test.fail class ResponseParserTest : FinTsTestBase() { @@ -34,9 +36,9 @@ class ResponseParserTest : FinTsTestBase() { ) // then - assertThat(result.receivedSegments).hasSize(2) + expect(result.receivedSegments).hasSize(2) - assertThat(result.messageHeader?.dialogId).isEqualTo("abcd'efg") + expect(result.messageHeader?.dialogId).toBe("abcd'efg") } @Test @@ -49,9 +51,9 @@ class ResponseParserTest : FinTsTestBase() { ) // then - assertThat(result.receivedSegments).hasSize(2) + expect(result.receivedSegments).hasSize(2) - assertThat(result.messageHeader?.dialogId).isEqualTo("abcd+efg") + expect(result.messageHeader?.dialogId).toBe("abcd+efg") } @Test @@ -64,9 +66,9 @@ class ResponseParserTest : FinTsTestBase() { ) // then - assertThat(result.receivedSegments).hasSize(2) + expect(result.receivedSegments).hasSize(2) - assertThat(result.messageHeader?.dialogId).isEqualTo("https://www.example.org") + expect(result.messageHeader?.dialogId).toBe("https://www.example.org") } @Test @@ -79,9 +81,9 @@ class ResponseParserTest : FinTsTestBase() { ) // then - assertThat(result.receivedSegments).hasSize(2) + expect(result.receivedSegments).hasSize(2) - assertThat(result.messageHeader?.dialogId).isEqualTo("abcd?efg") + expect(result.messageHeader?.dialogId).toBe("abcd?efg") } @@ -95,34 +97,13 @@ class ResponseParserTest : FinTsTestBase() { "HNHBS:3:1+1'") // then - assertThat(result.receivedSegments).hasSize(5) + expect(result.receivedSegments).hasSize(5) assertCouldParseSegment(result, InstituteSegmentId.MessageFeedback, 2, 2) - assertThat(result.messageFeedback).isNotNull - assertThat(result.messageFeedback?.isError).isTrue() - assertThat(result.messageFeedback?.feedbacks?.map { it.message }).containsExactly("Nachricht nicht erwartet.", "Dialoginitialisierung abgebrochen.") - } - - @Test - fun `decode TanChallenge HHD_UC`() { - - // given - val response = loadTestFile("Decode_TanChallengeHhdUc_WithMaskedCharacter.txt", HbciCharset.DefaultCharset) - - - // when - val result = underTest.parse(response) - - - // then - assertThat(result.successful).isTrue() - - assertThat(result.tanResponse).isNotNull - - val decodedChallengeHhdUc = TanImageDecoder().decodeChallenge(result.tanResponse?.challengeHHD_UC ?: "") - assertThat(decodedChallengeHhdUc.decodingSuccessful).isTrue() - assertThat(decodedChallengeHhdUc.imageBytes.size).isEqualTo(3664) + expect(result.messageFeedback).notToBeNull() + expect(result.messageFeedback?.isError ?: false).isTrue() + expect(result.messageFeedback?.feedbacks?.map { it.message } ?: listOf()).containsExactly("Nachricht nicht erwartet.", "Dialoginitialisierung abgebrochen.") } @@ -135,13 +116,13 @@ class ResponseParserTest : FinTsTestBase() { // then assertSuccessfullyParsedSegment(result, MessageSegmentId.MessageHeader, 1, 3) - assertThat(result.messageHeader).isNotNull + expect(result.messageHeader).notToBeNull() val header = result.receivedSegments.first() as ReceivedMessageHeader - assertThat(header.messageSize).isEqualTo(596) - assertThat(header.finTsVersion).isEqualTo(300) - assertThat(header.dialogId).isEqualTo("817407729605=887211382312BLB4=") - assertThat(header.messageNumber).isEqualTo(2) + expect(header.messageSize).toBe(596) + expect(header.finTsVersion).toBe(300) + expect(header.dialogId).toBe("817407729605=887211382312BLB4=") + expect(header.messageNumber).toBe(2) } @@ -154,17 +135,17 @@ class ResponseParserTest : FinTsTestBase() { // then assertSuccessfullyParsedSegment(result, InstituteSegmentId.MessageFeedback, 3, 2) - assertThat(result.messageFeedback).isNotNull() + expect(result.messageFeedback).notToBeNull() - assertThat(result.messageFeedback?.feedbacks).hasSize(1) + expect(result.messageFeedback?.feedbacks ?: listOf()).hasSize(1) val firstFeedback = result.messageFeedback?.feedbacks?.get(0)!! - assertThat(firstFeedback.responseCode).isEqualTo(3060) - assertThat(firstFeedback.isSuccess).isFalse() - assertThat(firstFeedback.isWarning).isTrue() - assertThat(firstFeedback.isError).isFalse() - assertThat(firstFeedback.message).isEqualTo("Bitte beachten Sie die enthaltenen Warnungen/Hinweise.") - assertThat(firstFeedback.parameter).isNull() + expect(firstFeedback.responseCode).toBe(3060) + expect(firstFeedback.isSuccess).isFalse() + expect(firstFeedback.isWarning).isTrue() + expect(firstFeedback.isError).isFalse() + expect(firstFeedback.message).toBe("Bitte beachten Sie die enthaltenen Warnungen/Hinweise.") + expect(firstFeedback.parameter).toBe(null) } @Test @@ -176,17 +157,17 @@ class ResponseParserTest : FinTsTestBase() { // then assertCouldParseSegment(result, InstituteSegmentId.MessageFeedback, 3, 2) - assertThat(result.messageFeedback).isNotNull() + expect(result.messageFeedback).notToBeNull() - assertThat(result.messageFeedback?.feedbacks).hasSize(1) + expect(result.messageFeedback?.feedbacks ?: listOf()).hasSize(1) val firstFeedback = result.messageFeedback?.feedbacks?.get(0)!! - assertThat(firstFeedback.responseCode).isEqualTo(9050) - assertThat(firstFeedback.isSuccess).isFalse() - assertThat(firstFeedback.isWarning).isFalse() - assertThat(firstFeedback.isError).isTrue() - assertThat(firstFeedback.message).isEqualTo("Die Nachricht enthält Fehler.") - assertThat(firstFeedback.parameter).isNull() + expect(firstFeedback.responseCode).toBe(9050) + expect(firstFeedback.isSuccess).isFalse() + expect(firstFeedback.isWarning).isFalse() + expect(firstFeedback.isError).isTrue() + expect(firstFeedback.message).toBe("Die Nachricht enthält Fehler.") + expect(firstFeedback.parameter).toBe(null) } @Test @@ -198,25 +179,25 @@ class ResponseParserTest : FinTsTestBase() { // then assertCouldParseSegment(result, InstituteSegmentId.MessageFeedback, 3, 2) - assertThat(result.messageFeedback).isNotNull() + expect(result.messageFeedback).notToBeNull() - assertThat(result.messageFeedback?.feedbacks).hasSize(2) + expect(result.messageFeedback?.feedbacks ?: listOf()).hasSize(2) val firstFeedback = result.messageFeedback?.feedbacks?.get(0)!! - assertThat(firstFeedback.responseCode).isEqualTo(9050) - assertThat(firstFeedback.isSuccess).isFalse() - assertThat(firstFeedback.isWarning).isFalse() - assertThat(firstFeedback.isError).isTrue() - assertThat(firstFeedback.message).isEqualTo("Die Nachricht enthält Fehler.") - assertThat(firstFeedback.parameter).isNull() + expect(firstFeedback.responseCode).toBe(9050) + expect(firstFeedback.isSuccess).isFalse() + expect(firstFeedback.isWarning).isFalse() + expect(firstFeedback.isError).isTrue() + expect(firstFeedback.message).toBe("Die Nachricht enthält Fehler.") + expect(firstFeedback.parameter).toBe(null) val secondFeedback = result.messageFeedback?.feedbacks?.get(1)!! - assertThat(secondFeedback.responseCode).isEqualTo(3905) - assertThat(secondFeedback.isSuccess).isFalse() - assertThat(secondFeedback.isWarning).isTrue() - assertThat(secondFeedback.isError).isFalse() - assertThat(secondFeedback.message).isEqualTo("Es wurde keine Challenge erzeugt.") - assertThat(secondFeedback.parameter).isNull() + expect(secondFeedback.responseCode).toBe(3905) + expect(secondFeedback.isSuccess).isFalse() + expect(secondFeedback.isWarning).isTrue() + expect(secondFeedback.isError).isFalse() + expect(secondFeedback.message).toBe("Es wurde keine Challenge erzeugt.") + expect(secondFeedback.parameter).toBe(null) } @Test @@ -228,25 +209,25 @@ class ResponseParserTest : FinTsTestBase() { // then assertCouldParseSegment(result, InstituteSegmentId.MessageFeedback, 3, 2) - assertThat(result.messageFeedback).isNotNull() + expect(result.messageFeedback).notToBeNull() - assertThat(result.messageFeedback?.feedbacks).hasSize(2) + expect(result.messageFeedback?.feedbacks ?: listOf()).hasSize(2) val firstFeedback = result.messageFeedback?.feedbacks?.get(0)!! - assertThat(firstFeedback.responseCode).isEqualTo(9050) - assertThat(firstFeedback.isSuccess).isFalse() - assertThat(firstFeedback.isWarning).isFalse() - assertThat(firstFeedback.isError).isTrue() - assertThat(firstFeedback.message).isEqualTo("Die Nachricht enthält Fehler.") - assertThat(firstFeedback.parameter).isNull() + expect(firstFeedback.responseCode).toBe(9050) + expect(firstFeedback.isSuccess).isFalse() + expect(firstFeedback.isWarning).isFalse() + expect(firstFeedback.isError).isTrue() + expect(firstFeedback.message).toBe("Die Nachricht enthält Fehler.") + expect(firstFeedback.parameter).toBe(null) val secondFeedback = result.messageFeedback?.feedbacks?.get(1)!! - assertThat(secondFeedback.responseCode).isEqualTo(3905) - assertThat(secondFeedback.isSuccess).isFalse() - assertThat(secondFeedback.isWarning).isTrue() - assertThat(secondFeedback.isError).isFalse() - assertThat(secondFeedback.message).isEqualTo("Es wurde keine Challenge erzeugt.") - assertThat(secondFeedback.parameter).isNull() + expect(secondFeedback.responseCode).toBe(3905) + expect(secondFeedback.isSuccess).isFalse() + expect(secondFeedback.isWarning).isTrue() + expect(secondFeedback.isError).isFalse() + expect(secondFeedback.message).toBe("Es wurde keine Challenge erzeugt.") + expect(secondFeedback.parameter).toBe(null) } @@ -260,7 +241,7 @@ class ResponseParserTest : FinTsTestBase() { // then assertCouldParseSegment(result, InstituteSegmentId.SegmentFeedback, 4, 2, 3) - assertThat(result.aufsetzpunkt).isEqualTo("9345-10-26-11.52.15.693455") + expect(result.aufsetzpunkt).toBe("9345-10-26-11.52.15.693455") } @Test @@ -273,42 +254,42 @@ class ResponseParserTest : FinTsTestBase() { // then assertCouldParseSegment(result, InstituteSegmentId.SegmentFeedback, 4, 2, 4) - assertThat(result.segmentFeedbacks).hasSize(1) + expect(result.segmentFeedbacks).hasSize(1) - assertThat(result.supportedTanProceduresForUser).containsExactlyInAnyOrder(Sicherheitsfunktion.PIN_TAN_910, + expect(result.supportedTanProceduresForUser).containsExactly(Sicherheitsfunktion.PIN_TAN_910, Sicherheitsfunktion.PIN_TAN_911, Sicherheitsfunktion.PIN_TAN_912, Sicherheitsfunktion.PIN_TAN_913) val segmentFeedback = result.segmentFeedbacks.first() - assertThat(segmentFeedback.feedbacks).hasSize(3) + expect(segmentFeedback.feedbacks).hasSize(3) val firstFeedback = segmentFeedback.feedbacks[0] - assertThat(firstFeedback.responseCode).isEqualTo(3050) - assertThat(firstFeedback.isSuccess).isFalse() - assertThat(firstFeedback.isWarning).isTrue() - assertThat(firstFeedback.isError).isFalse() - assertThat(firstFeedback.message).isEqualTo("BPD nicht mehr aktuell, aktuelle Version enthalten.") - assertThat(firstFeedback.parameter).isNull() + expect(firstFeedback.responseCode).toBe(3050) + expect(firstFeedback.isSuccess).isFalse() + expect(firstFeedback.isWarning).isTrue() + expect(firstFeedback.isError).isFalse() + expect(firstFeedback.message).toBe("BPD nicht mehr aktuell, aktuelle Version enthalten.") + expect(firstFeedback.parameter).toBe(null) val secondFeedback = segmentFeedback.feedbacks[1] - assertThat(secondFeedback is SupportedTanProceduresForUserFeedback).isTrue() - assertThat((secondFeedback as SupportedTanProceduresForUserFeedback).supportedTanProcedures) - .containsExactlyInAnyOrder(Sicherheitsfunktion.PIN_TAN_910,Sicherheitsfunktion.PIN_TAN_911, + expect(secondFeedback is SupportedTanProceduresForUserFeedback).isTrue() + expect((secondFeedback as SupportedTanProceduresForUserFeedback).supportedTanProcedures) + .containsExactly(Sicherheitsfunktion.PIN_TAN_910,Sicherheitsfunktion.PIN_TAN_911, Sicherheitsfunktion.PIN_TAN_912, Sicherheitsfunktion.PIN_TAN_913) - assertThat(secondFeedback.responseCode).isEqualTo(3920) - assertThat(secondFeedback.isSuccess).isFalse() - assertThat(secondFeedback.isWarning).isTrue() - assertThat(secondFeedback.isError).isFalse() - assertThat(secondFeedback.message).isEqualTo("Zugelassene Zwei-Schritt-Verfahren für den Benutzer.") - assertThat(secondFeedback.parameter).isNull() + expect(secondFeedback.responseCode).toBe(3920) + expect(secondFeedback.isSuccess).isFalse() + expect(secondFeedback.isWarning).isTrue() + expect(secondFeedback.isError).isFalse() + expect(secondFeedback.message).toBe("Zugelassene Zwei-Schritt-Verfahren für den Benutzer.") + expect(secondFeedback.parameter).toBe(null) val thirdFeedback = segmentFeedback.feedbacks[2] - assertThat(thirdFeedback.responseCode).isEqualTo(20) - assertThat(thirdFeedback.isSuccess).isTrue() - assertThat(thirdFeedback.isWarning).isFalse() - assertThat(thirdFeedback.isError).isFalse() - assertThat(thirdFeedback.message).isEqualTo("Der Auftrag wurde ausgeführt.") - assertThat(thirdFeedback.parameter).isNull() + expect(thirdFeedback.responseCode).toBe(20) + expect(thirdFeedback.isSuccess).isTrue() + expect(thirdFeedback.isWarning).isFalse() + expect(thirdFeedback.isError).isFalse() + expect(thirdFeedback.message).toBe("Der Auftrag wurde ausgeführt.") + expect(thirdFeedback.parameter).toBe(null) } @@ -322,9 +303,9 @@ class ResponseParserTest : FinTsTestBase() { assertSuccessfullyParsedSegment(result, InstituteSegmentId.Synchronization, 173, 4, 6) result.getFirstSegmentById(InstituteSegmentId.Synchronization)?.let { segment -> - assertThat(segment.customerSystemId).isEqualTo("WL/2/Trhmm0BAAAjIADlyFkXrAQA") + expect(segment.customerSystemId).toBe("WL/2/Trhmm0BAAAjIADlyFkXrAQA") } - ?: run { Assert.fail("No segment of type ReceivedSynchronization found in ${result.receivedSegments}") } + ?: run { fail("No segment of type ReceivedSynchronization found in ${result.receivedSegments}") } } @@ -338,20 +319,20 @@ class ResponseParserTest : FinTsTestBase() { assertSuccessfullyParsedSegment(result, InstituteSegmentId.BankParameters, 5, 3, 3) result.getFirstSegmentById(InstituteSegmentId.BankParameters)?.let { segment -> - assertThat(segment.bpdVersion).isEqualTo(34) - assertThat(segment.bankCountryCode).isEqualTo(280) - assertThat(segment.bankCode).isEqualTo("10070000") - assertThat(segment.bankName).isEqualTo("Deutsche Bank") + expect(segment.bpdVersion).toBe(34) + expect(segment.bankCountryCode).toBe(280) + expect(segment.bankCode).toBe("10070000") + expect(segment.bankName).toBe("Deutsche Bank") - assertThat(segment.countMaxJobsPerMessage).isEqualTo(0) - assertThat(segment.supportedLanguages).containsExactly(Dialogsprache.German) - assertThat(segment.supportedHbciVersions).containsExactly(HbciVersion.FinTs_3_0_0) + expect(segment.countMaxJobsPerMessage).toBe(0) + expect(segment.supportedLanguages).containsExactly(Dialogsprache.German) + expect(segment.supportedHbciVersions).containsExactly(HbciVersion.FinTs_3_0_0) - assertThat(segment.maxMessageSize).isEqualTo(0) - assertThat(segment.minTimeout).isNull() - assertThat(segment.maxTimeout).isNull() + expect(segment.maxMessageSize).toBe(0) + expect(segment.minTimeout).toBe(null) + expect(segment.maxTimeout).toBe(null) } - ?: run { Assert.fail("No segment of type BankParameters found in ${result.receivedSegments}") } + ?: run { fail("No segment of type BankParameters found in ${result.receivedSegments}") } } // Baader Bank @@ -366,20 +347,20 @@ class ResponseParserTest : FinTsTestBase() { assertSuccessfullyParsedSegment(result, InstituteSegmentId.BankParameters, 3, 3, 3) result.getFirstSegmentById(InstituteSegmentId.BankParameters)?.let { segment -> - assertThat(segment.bpdVersion).isEqualTo(0) - assertThat(segment.bankCountryCode).isEqualTo(280) - assertThat(segment.bankCode).isEqualTo("70033100") - assertThat(segment.bankName).isEqualTo("Baader Bank AG") + expect(segment.bpdVersion).toBe(0) + expect(segment.bankCountryCode).toBe(280) + expect(segment.bankCode).toBe("70033100") + expect(segment.bankName).toBe("Baader Bank AG") - assertThat(segment.countMaxJobsPerMessage).isEqualTo(1) - assertThat(segment.supportedLanguages).containsExactly(Dialogsprache.German) - assertThat(segment.supportedHbciVersions).containsExactly(HbciVersion.FinTs_3_0_0) + expect(segment.countMaxJobsPerMessage).toBe(1) + expect(segment.supportedLanguages).containsExactly(Dialogsprache.German) + expect(segment.supportedHbciVersions).containsExactly(HbciVersion.FinTs_3_0_0) - assertThat(segment.maxMessageSize).isNull() - assertThat(segment.minTimeout).isEqualTo(0) - assertThat(segment.maxTimeout).isEqualTo(300) + expect(segment.maxMessageSize).toBe(null) + expect(segment.minTimeout).toBe(0) + expect(segment.maxTimeout).toBe(300) } - ?: run { Assert.fail("No segment of type BankParameters found in ${result.receivedSegments}") } + ?: run { fail("No segment of type BankParameters found in ${result.receivedSegments}") } } @Test @@ -392,9 +373,9 @@ class ResponseParserTest : FinTsTestBase() { assertSuccessfullyParsedSegment(result, InstituteSegmentId.SecurityMethods, 7, 3, 3) result.getFirstSegmentById(InstituteSegmentId.SecurityMethods)?.let { segment -> - assertThat(segment.mixingAllowed).isFalse() + expect(segment.mixingAllowed).isFalse() - assertThat(segment.securityProfiles).contains( + expect(segment.securityProfiles).contains( Sicherheitsprofil(Sicherheitsverfahren.RDH, VersionDesSicherheitsverfahrens.Version_1), Sicherheitsprofil(Sicherheitsverfahren.RDH, VersionDesSicherheitsverfahrens.Version_9), Sicherheitsprofil(Sicherheitsverfahren.RDH, VersionDesSicherheitsverfahrens.Version_10), @@ -402,7 +383,7 @@ class ResponseParserTest : FinTsTestBase() { Sicherheitsprofil(Sicherheitsverfahren.PIN_TAN_Verfahren, VersionDesSicherheitsverfahrens.Version_1) ) } - ?: run { Assert.fail("No segment of type SecurityMethods found in ${result.receivedSegments}") } + ?: run { fail("No segment of type SecurityMethods found in ${result.receivedSegments}") } } @Test @@ -415,9 +396,9 @@ class ResponseParserTest : FinTsTestBase() { assertSuccessfullyParsedSegment(result, InstituteSegmentId.SecurityMethods, 7, 3, 3) result.getFirstSegmentById(InstituteSegmentId.SecurityMethods)?.let { segment -> - assertThat(segment.mixingAllowed).isFalse() + expect(segment.mixingAllowed).isFalse() - assertThat(segment.securityProfiles).contains( + expect(segment.securityProfiles).contains( Sicherheitsprofil(Sicherheitsverfahren.RDH, VersionDesSicherheitsverfahrens.Version_1), Sicherheitsprofil(Sicherheitsverfahren.RDH, VersionDesSicherheitsverfahrens.Version_3), Sicherheitsprofil(Sicherheitsverfahren.RDH, VersionDesSicherheitsverfahrens.Version_5), @@ -430,7 +411,7 @@ class ResponseParserTest : FinTsTestBase() { Sicherheitsprofil(Sicherheitsverfahren.PIN_TAN_Verfahren, VersionDesSicherheitsverfahrens.Version_1) ) } - ?: run { Assert.fail("No segment of type SecurityMethods found in ${result.receivedSegments}") } + ?: run { fail("No segment of type SecurityMethods found in ${result.receivedSegments}") } } @Test @@ -446,17 +427,17 @@ class ResponseParserTest : FinTsTestBase() { assertSuccessfullyParsedSegment(result, InstituteSegmentId.CommunicationInfo, 5, 4, 3) result.getFirstSegmentById(InstituteSegmentId.CommunicationInfo)?.let { segment -> - assertThat(segment.bankInfo.bankCountryCode).isEqualTo(BankCountryCode) - assertThat(segment.bankInfo.bankCode).isEqualTo(BankCode) + expect(segment.bankInfo.bankCountryCode).toBe(BankCountryCode) + expect(segment.bankInfo.bankCode).toBe(BankCode) - assertThat(segment.defaultLanguage).isEqualTo(language) + expect(segment.defaultLanguage).toBe(language) - assertThat(segment.parameters).containsExactlyInAnyOrder( + expect(segment.parameters).containsExactly( CommunicationParameter(Kommunikationsdienst.Https, BankFinTsServerAddress), CommunicationParameter(Kommunikationsdienst.TCP_IP, BankFinTsServerAddress) ) } - ?: run { Assert.fail("No segment of type CommunicationInfo found in ${result.receivedSegments}") } + ?: run { fail("No segment of type CommunicationInfo found in ${result.receivedSegments}") } } @@ -470,13 +451,13 @@ class ResponseParserTest : FinTsTestBase() { assertSuccessfullyParsedSegment(result, InstituteSegmentId.UserParameters, 6, 4, 4) result.getFirstSegmentById(InstituteSegmentId.UserParameters)?.let { segment -> - assertThat(segment.userIdentifier).isEqualTo("3498443795") - assertThat(segment.updVersion).isEqualTo(34) - assertThat(segment.areListedJobsBlocked).isTrue() - assertThat(segment.username).isNull() - assertThat(segment.extension).isEqualTo("PERSNR0010789316542") + expect(segment.userIdentifier).toBe("3498443795") + expect(segment.updVersion).toBe(34) + expect(segment.areListedJobsBlocked).isTrue() + expect(segment.username).toBe(null) + expect(segment.extension).toBe("PERSNR0010789316542") } - ?: run { Assert.fail("No segment of type UserParameters found in ${result.receivedSegments}") } + ?: run { fail("No segment of type UserParameters found in ${result.receivedSegments}") } } @Test @@ -491,22 +472,22 @@ class ResponseParserTest : FinTsTestBase() { assertSuccessfullyParsedSegment(result, InstituteSegmentId.AccountInfo, 7, 6, 4) result.getFirstSegmentById(InstituteSegmentId.AccountInfo)?.let { segment -> - assertThat(segment.accountIdentifier).isEqualTo("0987654321") - assertThat(segment.subAccountAttribute).isNull() - assertThat(segment.bankCountryCode).isEqualTo(280) - assertThat(segment.bankCode).isEqualTo("12345678") - assertThat(segment.iban).isEqualTo("DE11123456780987654321") - assertThat(segment.customerId).isEqualTo("2197654321") - assertThat(segment.accountType).isEqualTo(AccountType.Girokonto) - assertThat(segment.currency).isEqualTo("EUR") - assertThat(segment.accountHolderName1).isEqualTo("Hans Dampf") - assertThat(segment.accountHolderName2).isNull() - assertThat(segment.productName).isEqualTo("Sichteinlagen") - assertThat(segment.accountLimit).isNull() - assertThat(segment.allowedJobNames).hasSize(44) - assertThat(segment.extension).isNotNull() + expect(segment.accountIdentifier).toBe("0987654321") + expect(segment.subAccountAttribute).toBe(null) + expect(segment.bankCountryCode).toBe(280) + expect(segment.bankCode).toBe("12345678") + expect(segment.iban).toBe("DE11123456780987654321") + expect(segment.customerId).toBe("2197654321") + expect(segment.accountType).toBe(AccountType.Girokonto) + expect(segment.currency).toBe("EUR") + expect(segment.accountHolderName1).toBe("Hans Dampf") + expect(segment.accountHolderName2).toBe(null) + expect(segment.productName).toBe("Sichteinlagen") + expect(segment.accountLimit).toBe(null) + expect(segment.allowedJobNames).hasSize(44) + expect(segment.extension).notToBeNull() } - ?: run { Assert.fail("No segment of type AccountInfo found in ${result.receivedSegments}") } + ?: run { fail("No segment of type AccountInfo found in ${result.receivedSegments}") } } @Test @@ -519,22 +500,22 @@ class ResponseParserTest : FinTsTestBase() { assertSuccessfullyParsedSegment(result, InstituteSegmentId.AccountInfo, 74, 6, 3) result.getFirstSegmentById(InstituteSegmentId.AccountInfo)?.let { segment -> - assertThat(segment.accountIdentifier).isEqualTo("9999999999") - assertThat(segment.subAccountAttribute).isNull() - assertThat(segment.bankCountryCode).isEqualTo(280) - assertThat(segment.bankCode).isEqualTo("10070000") - assertThat(segment.iban).isNull() - assertThat(segment.customerId).isEqualTo("9999999999") - assertThat(segment.accountType).isNull() - assertThat(segment.currency).isNull() - assertThat(segment.accountHolderName1).isEqualTo("anonym") - assertThat(segment.accountHolderName2).isNull() - assertThat(segment.productName).isNull() - assertThat(segment.accountLimit).isNull() - assertThat(segment.allowedJobNames).isEmpty() - assertThat(segment.extension).isNull() + expect(segment.accountIdentifier).toBe("9999999999") + expect(segment.subAccountAttribute).toBe(null) + expect(segment.bankCountryCode).toBe(280) + expect(segment.bankCode).toBe("10070000") + expect(segment.iban).toBe(null) + expect(segment.customerId).toBe("9999999999") + expect(segment.accountType).toBe(null) + expect(segment.currency).toBe(null) + expect(segment.accountHolderName1).toBe("anonym") + expect(segment.accountHolderName2).toBe(null) + expect(segment.productName).toBe(null) + expect(segment.accountLimit).toBe(null) + expect(segment.allowedJobNames).isEmpty() + expect(segment.extension).toBe(null) } - ?: run { Assert.fail("No segment of type AccountInfo found in ${result.receivedSegments}") } + ?: run { fail("No segment of type AccountInfo found in ${result.receivedSegments}") } } @Test @@ -547,15 +528,15 @@ class ResponseParserTest : FinTsTestBase() { assertSuccessfullyParsedSegment(result, InstituteSegmentId.SepaAccountInfo, 5, 1, 3) result.getFirstSegmentById(InstituteSegmentId.SepaAccountInfo)?.let { segment -> - assertThat(segment.account.isSepaAccount).isTrue() - assertThat(segment.account.iban).isEqualTo(Iban) - assertThat(segment.account.bic).isEqualTo(Bic) - assertThat(segment.account.accountIdentifier).isEqualTo(CustomerId) - assertThat(segment.account.subAccountAttribute).isNull() - assertThat(segment.account.bankInfo.bankCountryCode).isEqualTo(BankCountryCode) - assertThat(segment.account.bankInfo.bankCode).isEqualTo(BankCode) + expect(segment.account.isSepaAccount).isTrue() + expect(segment.account.iban).toBe(Iban) + expect(segment.account.bic).toBe(Bic) + expect(segment.account.accountIdentifier).toBe(CustomerId) + expect(segment.account.subAccountAttribute).toBe(null) + expect(segment.account.bankInfo.bankCountryCode).toBe(BankCountryCode) + expect(segment.account.bankInfo.bankCode).toBe(BankCode) } - ?: run { Assert.fail("No segment of type SepaAccountInfo found in ${result.receivedSegments}") } + ?: run { fail("No segment of type SepaAccountInfo found in ${result.receivedSegments}") } } @Test @@ -569,18 +550,18 @@ class ResponseParserTest : FinTsTestBase() { assertCouldParseResponse(result) val sepaAccountInfoParameters = result.getSegmentsById(InstituteSegmentId.SepaAccountInfoParameters) - assertThat(sepaAccountInfoParameters).hasSize(2) + expect(sepaAccountInfoParameters).hasSize(2) assertCouldParseJobParametersSegment(sepaAccountInfoParameters[0], InstituteSegmentId.SepaAccountInfoParameters, 147, 1, 3, "HKSPA", 1, 1, 1) assertCouldParseJobParametersSegment(sepaAccountInfoParameters[1], InstituteSegmentId.SepaAccountInfoParameters, 148, 2, 3, "HKSPA", 1, 1, 1) for (segment in sepaAccountInfoParameters) { - assertThat(segment.retrieveSingleAccountAllowed).isTrue() - assertThat(segment.nationalAccountRelationshipAllowed).isFalse() - assertThat(segment.structuredUsageAllowed).isFalse() - assertThat(segment.settingMaxAllowedEntriesAllowed).isFalse() - assertThat(segment.countReservedUsageLength).isEqualTo(SepaAccountInfoParameters.CountReservedUsageLengthNotSet) - assertThat(segment.supportedSepaFormats).containsExactlyInAnyOrder( + expect(segment.retrieveSingleAccountAllowed).isTrue() + expect(segment.nationalAccountRelationshipAllowed).isFalse() + expect(segment.structuredUsageAllowed).isFalse() + expect(segment.settingMaxAllowedEntriesAllowed).isFalse() + expect(segment.countReservedUsageLength).toBe(SepaAccountInfoParameters.CountReservedUsageLengthNotSet) + expect(segment.supportedSepaFormats).containsExactly( "sepade.pain.001.001.02.xsd", "sepade.pain.001.002.02.xsd", "sepade.pain.001.002.03.xsd", @@ -593,6 +574,7 @@ class ResponseParserTest : FinTsTestBase() { } } + @ExperimentalWithOptions @Test fun parseSupportedJobs() { @@ -694,11 +676,11 @@ class ResponseParserTest : FinTsTestBase() { // then - assertThat(result.successful).isTrue() - assertThat(result.receivedSegments).hasSize(92) + expect(result.successful).isTrue() + expect(result.receivedSegments).hasSize(92) for (segment in result.receivedSegments) { - assertThat(segment is JobParameters).describedAs("$segment should be of type JobParameters").isTrue() + expect(segment is JobParameters).withRepresentation("$segment should be of type JobParameters").isTrue() } } @@ -713,17 +695,17 @@ class ResponseParserTest : FinTsTestBase() { assertSuccessfullyParsedSegment(result, InstituteSegmentId.PinInfo, 49, 1, 4) result.getFirstSegmentById(InstituteSegmentId.PinInfo)?.let { segment -> - assertThat(segment.minPinLength).isEqualTo(5) - assertThat(segment.maxPinLength).isEqualTo(20) - assertThat(segment.minTanLength).isEqualTo(6) - assertThat(segment.userIdHint).isEqualTo("VR-NetKey oder Alias") - assertThat(segment.customerIdHint).isNull() + expect(segment.minPinLength).toBe(5) + expect(segment.maxPinLength).toBe(20) + expect(segment.minTanLength).toBe(6) + expect(segment.userIdHint).toBe("VR-NetKey oder Alias") + expect(segment.customerIdHint).toBe(null) - assertThat(segment.jobTanConfiguration).hasSize(37) - assertThat(segment.jobTanConfiguration.first { it.segmentId == "HKKAZ" }.tanRequired).isTrue() - assertThat(segment.jobTanConfiguration.first { it.segmentId == "HKSAL" }.tanRequired).isFalse() + expect(segment.jobTanConfiguration).hasSize(37) + expect(segment.jobTanConfiguration.first { it.segmentId == "HKKAZ" }.tanRequired).isTrue() + expect(segment.jobTanConfiguration.first { it.segmentId == "HKSAL" }.tanRequired).isFalse() } - ?: run { Assert.fail("No segment of type PinInfo found in ${result.receivedSegments}") } + ?: run { fail("No segment of type PinInfo found in ${result.receivedSegments}") } } @@ -737,19 +719,19 @@ class ResponseParserTest : FinTsTestBase() { assertSuccessfullyParsedSegment(result, InstituteSegmentId.TanInfo, 171, 6, 4) result.getFirstSegmentById(InstituteSegmentId.TanInfo)?.let { segment -> - assertThat(segment.maxCountJobs).isEqualTo(1) - assertThat(segment.minimumCountSignatures).isEqualTo(1) - assertThat(segment.securityClass).isEqualTo(1) - assertThat(segment.tanProcedureParameters.oneStepProcedureAllowed).isTrue() - assertThat(segment.tanProcedureParameters.moreThanOneTanDependentJobPerMessageAllowed).isFalse() - assertThat(segment.tanProcedureParameters.jobHashValue).isEqualTo("0") + expect(segment.maxCountJobs).toBe(1) + expect(segment.minimumCountSignatures).toBe(1) + expect(segment.securityClass).toBe(1) + expect(segment.tanProcedureParameters.oneStepProcedureAllowed).isTrue() + expect(segment.tanProcedureParameters.moreThanOneTanDependentJobPerMessageAllowed).isFalse() + expect(segment.tanProcedureParameters.jobHashValue).toBe("0") - assertThat(segment.tanProcedureParameters.procedureParameters).hasSize(7) - assertThat(segment.tanProcedureParameters.procedureParameters).extracting("procedureName") - .containsExactlyInAnyOrder("chipTAN manuell", "chipTAN optisch", "chipTAN-USB", "chipTAN-QR", + expect(segment.tanProcedureParameters.procedureParameters).hasSize(7) + expect(segment.tanProcedureParameters.procedureParameters.map { it.procedureName }) + .containsExactly("chipTAN manuell", "chipTAN optisch", "chipTAN-USB", "chipTAN-QR", "smsTAN", "pushTAN", "iTAN") } - ?: run { Assert.fail("No segment of type TanInfo found in ${result.receivedSegments}") } + ?: run { fail("No segment of type TanInfo found in ${result.receivedSegments}") } } @Test @@ -762,18 +744,18 @@ class ResponseParserTest : FinTsTestBase() { assertSuccessfullyParsedSegment(result, InstituteSegmentId.TanInfo, 27, 6, 3) result.getFirstSegmentById(InstituteSegmentId.TanInfo)?.let { segment -> - assertThat(segment.maxCountJobs).isEqualTo(1) - assertThat(segment.minimumCountSignatures).isEqualTo(1) - assertThat(segment.securityClass).isEqualTo(1) - assertThat(segment.tanProcedureParameters.oneStepProcedureAllowed).isFalse() - assertThat(segment.tanProcedureParameters.moreThanOneTanDependentJobPerMessageAllowed).isFalse() - assertThat(segment.tanProcedureParameters.jobHashValue).isEqualTo("0") + expect(segment.maxCountJobs).toBe(1) + expect(segment.minimumCountSignatures).toBe(1) + expect(segment.securityClass).toBe(1) + expect(segment.tanProcedureParameters.oneStepProcedureAllowed).isFalse() + expect(segment.tanProcedureParameters.moreThanOneTanDependentJobPerMessageAllowed).isFalse() + expect(segment.tanProcedureParameters.jobHashValue).toBe("0") - assertThat(segment.tanProcedureParameters.procedureParameters).hasSize(2) - assertThat(segment.tanProcedureParameters.procedureParameters).extracting("procedureName") - .containsExactlyInAnyOrder("mobileTAN-Verfahren", "photoTAN-Verfahren") + expect(segment.tanProcedureParameters.procedureParameters).hasSize(2) + expect(segment.tanProcedureParameters.procedureParameters.map { it.procedureName }) + .containsExactly("mobileTAN-Verfahren", "photoTAN-Verfahren") } - ?: run { Assert.fail("No segment of type TanInfo found in ${result.receivedSegments}") } + ?: run { fail("No segment of type TanInfo found in ${result.receivedSegments}") } } @Test @@ -786,18 +768,18 @@ class ResponseParserTest : FinTsTestBase() { assertSuccessfullyParsedSegment(result, InstituteSegmentId.TanInfo, 56, 6, 3) result.getFirstSegmentById(InstituteSegmentId.TanInfo)?.let { segment -> - assertThat(segment.maxCountJobs).isEqualTo(1) - assertThat(segment.minimumCountSignatures).isEqualTo(1) - assertThat(segment.securityClass).isEqualTo(1) - assertThat(segment.tanProcedureParameters.oneStepProcedureAllowed).isFalse() - assertThat(segment.tanProcedureParameters.moreThanOneTanDependentJobPerMessageAllowed).isFalse() - assertThat(segment.tanProcedureParameters.jobHashValue).isEqualTo("0") + expect(segment.maxCountJobs).toBe(1) + expect(segment.minimumCountSignatures).toBe(1) + expect(segment.securityClass).toBe(1) + expect(segment.tanProcedureParameters.oneStepProcedureAllowed).isFalse() + expect(segment.tanProcedureParameters.moreThanOneTanDependentJobPerMessageAllowed).isFalse() + expect(segment.tanProcedureParameters.jobHashValue).toBe("0") - assertThat(segment.tanProcedureParameters.procedureParameters).hasSize(5) - assertThat(segment.tanProcedureParameters.procedureParameters).extracting("procedureName") - .containsExactlyInAnyOrder("SMS-TAN", "chipTAN comfort", "chipTAN comfort manuell", "BV AppTAN", "PhotoTAN") + expect(segment.tanProcedureParameters.procedureParameters).hasSize(5) + expect(segment.tanProcedureParameters.procedureParameters.map { it.procedureName }) + .containsExactly("SMS-TAN", "chipTAN comfort", "chipTAN comfort manuell", "BV AppTAN", "PhotoTAN") } - ?: run { Assert.fail("No segment of type TanInfo found in ${result.receivedSegments}") } + ?: run { fail("No segment of type TanInfo found in ${result.receivedSegments}") } } @Test @@ -810,19 +792,19 @@ class ResponseParserTest : FinTsTestBase() { assertSuccessfullyParsedSegment(result, InstituteSegmentId.TanInfo, 33, 7, 3) result.getFirstSegmentById(InstituteSegmentId.TanInfo)?.let { segment -> - assertThat(segment.maxCountJobs).isEqualTo(1) - assertThat(segment.minimumCountSignatures).isEqualTo(1) - assertThat(segment.securityClass).isEqualTo(0) - assertThat(segment.tanProcedureParameters.oneStepProcedureAllowed).isFalse() - assertThat(segment.tanProcedureParameters.moreThanOneTanDependentJobPerMessageAllowed).isFalse() - assertThat(segment.tanProcedureParameters.jobHashValue).isEqualTo("1") + expect(segment.maxCountJobs).toBe(1) + expect(segment.minimumCountSignatures).toBe(1) + expect(segment.securityClass).toBe(0) + expect(segment.tanProcedureParameters.oneStepProcedureAllowed).isFalse() + expect(segment.tanProcedureParameters.moreThanOneTanDependentJobPerMessageAllowed).isFalse() + expect(segment.tanProcedureParameters.jobHashValue).toBe("1") - assertThat(segment.tanProcedureParameters.procedureParameters).hasSize(6) - assertThat(segment.tanProcedureParameters.procedureParameters).extracting("procedureName") - .containsExactlyInAnyOrder("iTAN", "mobile TAN", "App-basiertes Verfahren", "chipTAN 1.4", + expect(segment.tanProcedureParameters.procedureParameters).hasSize(6) + expect(segment.tanProcedureParameters.procedureParameters.map { it.procedureName }) + .containsExactly("iTAN", "mobile TAN", "App-basiertes Verfahren", "chipTAN 1.4", "chipTAN 1.4 manuell", "Vorlagen und Informationen") } - ?: run { Assert.fail("No segment of type TanInfo found in ${result.receivedSegments}") } + ?: run { fail("No segment of type TanInfo found in ${result.receivedSegments}") } } @Test @@ -834,18 +816,18 @@ class ResponseParserTest : FinTsTestBase() { // then assertSuccessfullyParsedSegment(result, InstituteSegmentId.Tan, 6, 6, 5) - assertThat(result.isStrongAuthenticationRequired).isFalse() + expect(result.isStrongAuthenticationRequired).isFalse() result.getFirstSegmentById(InstituteSegmentId.Tan)?.let { segment -> - assertThat(segment.tanProcess).isEqualTo(TanProcess.TanProcess4) - assertThat(segment.jobHashValue).isNull() - assertThat(segment.jobReference).isEqualTo(TanResponse.NoJobReferenceResponse) - assertThat(segment.challenge).isEqualTo(TanResponse.NoChallengeResponse) - assertThat(segment.challengeHHD_UC).isNull() - assertThat(segment.validityDateTimeForChallenge).isNull() - assertThat(segment.tanMediaIdentifier).isNull() + expect(segment.tanProcess).toBe(TanProcess.TanProcess4) + expect(segment.jobHashValue).toBe(null) + expect(segment.jobReference).toBe(TanResponse.NoJobReferenceResponse) + expect(segment.challenge).toBe(TanResponse.NoChallengeResponse) + expect(segment.challengeHHD_UC).toBe(null) + expect(segment.validityDateTimeForChallenge).toBe(null) + expect(segment.tanMediaIdentifier).toBe(null) } - ?: run { Assert.fail("No segment of type TanResponse found in ${result.receivedSegments}") } + ?: run { fail("No segment of type TanResponse found in ${result.receivedSegments}") } } @Test @@ -863,18 +845,18 @@ class ResponseParserTest : FinTsTestBase() { // then assertSuccessfullyParsedSegment(result, InstituteSegmentId.Tan, 5, 6, 4) - assertThat(result.isStrongAuthenticationRequired).isTrue() + expect(result.isStrongAuthenticationRequired).isTrue() result.getFirstSegmentById(InstituteSegmentId.Tan)?.let { segment -> - assertThat(segment.tanProcess).isEqualTo(TanProcess.TanProcess4) - assertThat(segment.jobHashValue).isNull() - assertThat(segment.jobReference).isEqualTo(jobReference) - assertThat(segment.challenge).isEqualTo(unmaskString(challenge)) - assertThat(segment.challengeHHD_UC).isEqualTo(challengeHHD_UC) - assertThat(segment.validityDateTimeForChallenge).isNull() - assertThat(segment.tanMediaIdentifier).isEqualTo(tanMediaIdentifier) + expect(segment.tanProcess).toBe(TanProcess.TanProcess4) + expect(segment.jobHashValue).toBe(null) + expect(segment.jobReference).toBe(jobReference) + expect(segment.challenge).toBe(unmaskString(challenge)) + expect(segment.challengeHHD_UC).toBe(challengeHHD_UC) + expect(segment.validityDateTimeForChallenge).toBe(null) + expect(segment.tanMediaIdentifier).toBe(tanMediaIdentifier) } - ?: run { Assert.fail("No segment of type TanResponse found in ${result.receivedSegments}") } + ?: run { fail("No segment of type TanResponse found in ${result.receivedSegments}") } } @@ -892,16 +874,16 @@ class ResponseParserTest : FinTsTestBase() { // then assertSuccessfullyParsedSegment(result, InstituteSegmentId.TanMediaList, 5, 4, 3) - assertThat(result.isStrongAuthenticationRequired).isFalse() + expect(result.isStrongAuthenticationRequired).isFalse() result.getFirstSegmentById(InstituteSegmentId.TanMediaList)?.let { segment -> - assertThat(segment.usageOption).isEqualTo(TanEinsatzOption.KundeKannGenauEinMediumZuEinerZeitNutzen) - assertThat(segment.tanMedia).containsOnly( + expect(segment.usageOption).toBe(TanEinsatzOption.KundeKannGenauEinMediumZuEinerZeitNutzen) + expect(segment.tanMedia).containsExactly( TanGeneratorTanMedium(TanMediumKlasse.TanGenerator, TanMediumStatus.AktivFolgekarte, oldCardNumber, cardSequenceNumber, null, null, null, mediaName), TanGeneratorTanMedium(TanMediumKlasse.TanGenerator, TanMediumStatus.Verfuegbar, cardSequenceNumber, null, null, null, null, mediaName) ) } - ?: run { Assert.fail("No segment of type TanMediaList found in ${result.receivedSegments}") } + ?: run { fail("No segment of type TanMediaList found in ${result.receivedSegments}") } } @@ -916,18 +898,18 @@ class ResponseParserTest : FinTsTestBase() { assertSuccessfullyParsedSegment(result, InstituteSegmentId.ChangeTanMediaParameters, 64, 1, 3) result.getFirstSegmentById(InstituteSegmentId.ChangeTanMediaParameters)?.let { segment -> - assertThat(segment.maxCountJobs).isEqualTo(1) - assertThat(segment.minimumCountSignatures).isEqualTo(1) - assertThat(segment.securityClass).isEqualTo(1) + expect(segment.maxCountJobs).toBe(1) + expect(segment.minimumCountSignatures).toBe(1) + expect(segment.securityClass).toBe(1) - assertThat(segment.enteringTanListNumberRequired).isTrue() - assertThat(segment.enteringCardSequenceNumberRequired).isFalse() - assertThat(segment.enteringAtcAndTanRequired).isTrue() - assertThat(segment.enteringCardTypeAllowed).isFalse() - assertThat(segment.accountInfoRequired).isFalse() - assertThat(segment.allowedCardTypes).isEmpty() + expect(segment.enteringTanListNumberRequired).isTrue() + expect(segment.enteringCardSequenceNumberRequired).isFalse() + expect(segment.enteringAtcAndTanRequired).isTrue() + expect(segment.enteringCardTypeAllowed).isFalse() + expect(segment.accountInfoRequired).isFalse() + expect(segment.allowedCardTypes).isEmpty() } - ?: run { Assert.fail("No segment of type ChangeTanMediaParameters found in ${result.receivedSegments}") } + ?: run { fail("No segment of type ChangeTanMediaParameters found in ${result.receivedSegments}") } } @Test @@ -940,18 +922,18 @@ class ResponseParserTest : FinTsTestBase() { assertSuccessfullyParsedSegment(result, InstituteSegmentId.ChangeTanMediaParameters, 64, 2, 3) result.getFirstSegmentById(InstituteSegmentId.ChangeTanMediaParameters)?.let { segment -> - assertThat(segment.maxCountJobs).isEqualTo(1) - assertThat(segment.minimumCountSignatures).isEqualTo(1) - assertThat(segment.securityClass).isEqualTo(1) + expect(segment.maxCountJobs).toBe(1) + expect(segment.minimumCountSignatures).toBe(1) + expect(segment.securityClass).toBe(1) - assertThat(segment.enteringTanListNumberRequired).isFalse() - assertThat(segment.enteringCardSequenceNumberRequired).isTrue() - assertThat(segment.enteringAtcAndTanRequired).isFalse() - assertThat(segment.enteringCardTypeAllowed).isTrue() - assertThat(segment.accountInfoRequired).isFalse() - assertThat(segment.allowedCardTypes).containsExactlyInAnyOrder(11, 13, 15, 17) + expect(segment.enteringTanListNumberRequired).isFalse() + expect(segment.enteringCardSequenceNumberRequired).isTrue() + expect(segment.enteringAtcAndTanRequired).isFalse() + expect(segment.enteringCardTypeAllowed).isTrue() + expect(segment.accountInfoRequired).isFalse() + expect(segment.allowedCardTypes).containsExactly(11, 13, 15, 17) } - ?: run { Assert.fail("No segment of type ChangeTanMediaParameters found in ${result.receivedSegments}") } + ?: run { fail("No segment of type ChangeTanMediaParameters found in ${result.receivedSegments}") } } @Test @@ -964,18 +946,18 @@ class ResponseParserTest : FinTsTestBase() { assertSuccessfullyParsedSegment(result, InstituteSegmentId.ChangeTanMediaParameters, 64, 3, 3) result.getFirstSegmentById(InstituteSegmentId.ChangeTanMediaParameters)?.let { segment -> - assertThat(segment.maxCountJobs).isEqualTo(1) - assertThat(segment.minimumCountSignatures).isEqualTo(1) - assertThat(segment.securityClass).isEqualTo(1) + expect(segment.maxCountJobs).toBe(1) + expect(segment.minimumCountSignatures).toBe(1) + expect(segment.securityClass).toBe(1) - assertThat(segment.enteringTanListNumberRequired).isFalse() - assertThat(segment.enteringCardSequenceNumberRequired).isTrue() - assertThat(segment.enteringAtcAndTanRequired).isFalse() - assertThat(segment.enteringCardTypeAllowed).isTrue() - assertThat(segment.accountInfoRequired).isTrue() - assertThat(segment.allowedCardTypes).containsExactlyInAnyOrder(11, 13, 15, 17) + expect(segment.enteringTanListNumberRequired).isFalse() + expect(segment.enteringCardSequenceNumberRequired).isTrue() + expect(segment.enteringAtcAndTanRequired).isFalse() + expect(segment.enteringCardTypeAllowed).isTrue() + expect(segment.accountInfoRequired).isTrue() + expect(segment.allowedCardTypes).containsExactly(11, 13, 15, 17) } - ?: run { Assert.fail("No segment of type ChangeTanMediaParameters found in ${result.receivedSegments}") } + ?: run { fail("No segment of type ChangeTanMediaParameters found in ${result.receivedSegments}") } } @@ -984,7 +966,7 @@ class ResponseParserTest : FinTsTestBase() { // given val balance = 1234.56.toBigDecimal() - val date = java.util.Date(88, 2, 27) + val date = com.soywiz.klock.Date(1988, 3, 27) val bankCode = "12345678" val accountId = "0987654321" val accountProductName = "Sichteinlagen" @@ -997,13 +979,13 @@ class ResponseParserTest : FinTsTestBase() { assertSuccessfullyParsedSegment(result, InstituteSegmentId.Balance, 8, 5, 3) result.getFirstSegmentById(InstituteSegmentId.Balance)?.let { segment -> - assertThat(segment.balance).isEqualTo(balance) - assertThat(segment.currency).isEqualTo("EUR") - assertThat(segment.date).isEqualTo(date) - assertThat(segment.accountProductName).isEqualTo(accountProductName) - assertThat(segment.balanceOfPreBookedTransactions).isNull() + expect(segment.balance).toBe(balance) + expect(segment.currency).toBe("EUR") + expect(segment.date).toBe(date) + expect(segment.accountProductName).toBe(accountProductName) + expect(segment.balanceOfPreBookedTransactions).toBe(null) } - ?: run { Assert.fail("No segment of type BalanceSegment found in ${result.receivedSegments}") } + ?: run { fail("No segment of type BalanceSegment found in ${result.receivedSegments}") } } @Test @@ -1011,7 +993,7 @@ class ResponseParserTest : FinTsTestBase() { // given val balance = BigDecimal.ZERO - val date = java.util.Date(2020, 5, 11) + val date = com.soywiz.klock.Date(2020, 6, 11) val bankCode = "12345678" val accountId = "0987654321" val accountProductName = "Girokonto" @@ -1024,13 +1006,13 @@ class ResponseParserTest : FinTsTestBase() { assertSuccessfullyParsedSegment(result, InstituteSegmentId.Balance, 7, 5, 3) result.getFirstSegmentById(InstituteSegmentId.Balance)?.let { segment -> - assertThat(segment.balance).isEqualTo(balance) - assertThat(segment.currency).isEqualTo("EUR") - assertThat(segment.date).isEqualTo(date) - assertThat(segment.accountProductName).isEqualTo(accountProductName) - assertThat(segment.balanceOfPreBookedTransactions).isNull() + expect(segment.balance).toBe(balance) + expect(segment.currency).toBe("EUR") + expect(segment.date).toBe(date) + expect(segment.accountProductName).toBe(accountProductName) + expect(segment.balanceOfPreBookedTransactions).toBe(null) } - ?: run { Assert.fail("No segment of type BalanceSegment found in ${result.receivedSegments}") } + ?: run { fail("No segment of type BalanceSegment found in ${result.receivedSegments}") } } @@ -1043,11 +1025,11 @@ class ResponseParserTest : FinTsTestBase() { } private fun assertCouldParseResponse(result: Response) { - assertThat(result.successful).isTrue() - assertThat(result.responseContainsErrors).isFalse() - assertThat(result.exception).isNull() - assertThat(result.errorsToShowToUser).isEmpty() - assertThat(result.receivedResponse).isNotNull() + expect(result.successful).isTrue() + expect(result.responseContainsErrors).isFalse() + expect(result.exception).toBe(null) + expect(result.errorsToShowToUser).isEmpty() + expect(result.receivedResponse).notToBeNull() } private fun assertCouldParseSegment(result: Response, segmentId: ISegmentId, segmentNumber: Int, @@ -1061,13 +1043,13 @@ class ResponseParserTest : FinTsTestBase() { private fun assertCouldParseSegment(segment: ReceivedSegment?, segmentId: ISegmentId, segmentNumber: Int, segmentVersion: Int, referenceSegmentNumber: Int?) { - assertThat(segment).isNotNull() + expect(segment).notToBeNull() segment?.let { - assertThat(segment.segmentId).isEqualTo(segmentId.id) - assertThat(segment.segmentNumber).isEqualTo(segmentNumber) - assertThat(segment.segmentVersion).isEqualTo(segmentVersion) - assertThat(segment.referenceSegmentNumber).isEqualTo(referenceSegmentNumber) + expect(segment.segmentId).toBe(segmentId.id) + expect(segment.segmentNumber).toBe(segmentNumber) + expect(segment.segmentVersion).toBe(segmentVersion) + expect(segment.referenceSegmentNumber).toBe(referenceSegmentNumber) } } @@ -1078,10 +1060,10 @@ class ResponseParserTest : FinTsTestBase() { assertCouldParseSegment(segment, segmentId, segmentNumber, segmentVersion, referenceSegmentNumber) segment?.let { - assertThat(segment.jobName).isEqualTo(jobName) - assertThat(segment.maxCountJobs).isEqualTo(maxCountJobs) - assertThat(segment.minimumCountSignatures).isEqualTo(minimumCountSignatures) - assertThat(segment.securityClass).isEqualTo(securityClass) + expect(segment.jobName).toBe(jobName) + expect(segment.maxCountJobs).toBe(maxCountJobs) + expect(segment.minimumCountSignatures).toBe(minimumCountSignatures) + expect(segment.securityClass).toBe(securityClass) } } diff --git a/fints4k/src/test/kotlin/net/dankito/banking/fints/tan/FlickerCodeDecoderTest.kt b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/tan/FlickerCodeDecoderTest.kt similarity index 72% rename from fints4k/src/test/kotlin/net/dankito/banking/fints/tan/FlickerCodeDecoderTest.kt rename to fints4k/src/commonTest/kotlin/net/dankito/banking/fints/tan/FlickerCodeDecoderTest.kt index 466f6280..de7b7d2f 100644 --- a/fints4k/src/test/kotlin/net/dankito/banking/fints/tan/FlickerCodeDecoderTest.kt +++ b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/tan/FlickerCodeDecoderTest.kt @@ -1,8 +1,9 @@ package net.dankito.banking.fints.tan +import ch.tutteli.atrium.api.fluent.en_GB.toBe +import ch.tutteli.atrium.api.verbs.expect import net.dankito.banking.fints.model.HHDVersion -import org.assertj.core.api.Assertions.assertThat -import org.junit.Test +import kotlin.test.Test class FlickerCodeDecoderTest { @@ -22,7 +23,7 @@ class FlickerCodeDecoderTest { // then - assertThat(response.parsedDataSet).isEqualTo("070520829019981A") + expect(response.parsedDataSet).toBe("070520829019981A") } @@ -38,7 +39,7 @@ class FlickerCodeDecoderTest { // then - assertThat(response.parsedDataSet).isEqualTo("100520829019981849453939424F46494B") + expect(response.parsedDataSet).toBe("100520829019981849453939424F46494B") } @Test @@ -51,7 +52,7 @@ class FlickerCodeDecoderTest { val result = underTest.decodeChallenge(challenge, HHDVersion.HHD_1_3) // then - assertThat(result.parsedDataSet).isEqualTo("1204881696280598765432101533322C30303A") + expect(result.parsedDataSet).toBe("1204881696280598765432101533322C30303A") } @Test @@ -64,7 +65,7 @@ class FlickerCodeDecoderTest { val result = underTest.decodeChallenge(challenge, HHDVersion.HHD_1_3) // then - assertThat(result.parsedDataSet).isEqualTo("0604800402430B") + expect(result.parsedDataSet).toBe("0604800402430B") } @@ -78,7 +79,7 @@ class FlickerCodeDecoderTest { val result = underTest.decodeChallenge(challenge, HHDVersion.HHD_1_4) // then - assertThat(result.parsedDataSet).isEqualTo("1F85012392301246564445323631323334353637383039383736353433323175") + expect(result.parsedDataSet).toBe("1F85012392301246564445323631323334353637383039383736353433323175") } @Test @@ -91,7 +92,7 @@ class FlickerCodeDecoderTest { val result = underTest.decodeChallenge(challenge, HHDVersion.HHD_1_4) // then - assertThat(result.parsedDataSet).isEqualTo("2584011093744F5644453236313233343536373830393837363534333231463130302C303008") + expect(result.parsedDataSet).toBe("2584011093744F5644453236313233343536373830393837363534333231463130302C303008") } } \ No newline at end of file diff --git a/fints4k/src/test/kotlin/net/dankito/banking/fints/transactions/Mt940ParserTest.kt b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/transactions/Mt940ParserTest.kt similarity index 80% rename from fints4k/src/test/kotlin/net/dankito/banking/fints/transactions/Mt940ParserTest.kt rename to fints4k/src/commonTest/kotlin/net/dankito/banking/fints/transactions/Mt940ParserTest.kt index 3bcede1d..2a08108d 100644 --- a/fints4k/src/test/kotlin/net/dankito/banking/fints/transactions/Mt940ParserTest.kt +++ b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/transactions/Mt940ParserTest.kt @@ -1,16 +1,20 @@ package net.dankito.banking.fints.transactions +import ch.tutteli.atrium.api.fluent.en_GB.hasSize +import ch.tutteli.atrium.api.fluent.en_GB.notToBeNull +import ch.tutteli.atrium.api.fluent.en_GB.toBe import net.dankito.banking.fints.FinTsTestBase import net.dankito.banking.fints.transactions.mt940.Mt940Parser import net.dankito.banking.fints.transactions.mt940.model.Balance import net.dankito.banking.fints.transactions.mt940.model.InformationToAccountOwner import net.dankito.banking.fints.transactions.mt940.model.StatementLine -import net.dankito.utils.Stopwatch -import org.assertj.core.api.Assertions.assertThat -import org.junit.Test -import java.math.BigDecimal -import java.text.SimpleDateFormat -import java.util.* +import ch.tutteli.atrium.api.verbs.expect +import com.ionspin.kotlin.bignum.decimal.BigDecimal +import com.ionspin.kotlin.bignum.decimal.toBigDecimal +import kotlin.test.Test +import com.soywiz.klock.Date +import com.soywiz.klock.DateFormat +import net.dankito.banking.fints.extensions.isFalse class Mt940ParserTest : FinTsTestBase() { @@ -19,8 +23,8 @@ class Mt940ParserTest : FinTsTestBase() { const val Currency = "EUR" - val AccountStatement1PreviousStatementBookingDate = Date(88, 2, 26) - val AccountStatement1BookingDate = Date(88, 2, 27) + val AccountStatement1PreviousStatementBookingDate = Date(1988, 2, 26) + val AccountStatement1BookingDate = Date(1988, 2, 27) val AccountStatement1OpeningBalanceAmount = 12345.67.toBigDecimal() @@ -49,16 +53,16 @@ class Mt940ParserTest : FinTsTestBase() { // then - assertThat(result).hasSize(1) + expect(result).hasSize(1) val statement = result.first() - assertThat(statement.bankCodeBicOrIban).isEqualTo(BankCode) - assertThat(statement.accountIdentifier).isEqualTo(CustomerId) + expect(statement.bankCodeBicOrIban).toBe(BankCode) + expect(statement.accountIdentifier).toBe(CustomerId) assertBalance(statement.openingBalance, true, AccountStatement1PreviousStatementBookingDate, AccountStatement1OpeningBalanceAmount) assertBalance(statement.closingBalance, true, AccountStatement1BookingDate, AccountStatement1ClosingBalanceAmount) - assertThat(statement.transactions).hasSize(1) + expect(statement.transactions).hasSize(1) val transaction = statement.transactions.first() assertTurnover(transaction.statementLine, AccountStatement1BookingDate, AccountStatement1Transaction1Amount) @@ -70,28 +74,28 @@ class Mt940ParserTest : FinTsTestBase() { fun accountStatementWithSingleTransaction_SheetNumberOmitted() { // given - val amount = BigDecimal("15.00") + val amount = BigDecimal.parseString("15.00") val isCredit = false - val bookingDate = Date(120, 4, 11) + val bookingDate = Date(2020, 5, 11) // when val result = underTest.parseMt940String(AccountStatementWithSingleTransaction_SheetNumberOmitted) // then - assertThat(result).hasSize(1) + expect(result).hasSize(1) val statement = result.first() - assertThat(statement.bankCodeBicOrIban).isEqualTo(BankCode) - assertThat(statement.accountIdentifier).isEqualTo(CustomerId) - assertThat(statement.statementNumber).isEqualTo(0) - assertThat(statement.sequenceNumber).isNull() + expect(statement.bankCodeBicOrIban).toBe(BankCode) + expect(statement.accountIdentifier).toBe(CustomerId) + expect(statement.statementNumber).toBe(0) + expect(statement.sequenceNumber).toBe(null) - assertBalance(statement.openingBalance, true, bookingDate, BigDecimal("0.00")) + assertBalance(statement.openingBalance, true, bookingDate, BigDecimal.parseString("0.00")) assertBalance(statement.closingBalance, isCredit, bookingDate, amount) - assertThat(statement.transactions).hasSize(1) + expect(statement.transactions).hasSize(1) val transaction = statement.transactions.first() assertTurnover(transaction.statementLine, bookingDate, amount, isCredit) @@ -106,16 +110,16 @@ class Mt940ParserTest : FinTsTestBase() { // then - assertThat(result).hasSize(1) + expect(result).hasSize(1) val statement = result.first() - assertThat(statement.bankCodeBicOrIban).isEqualTo(BankCode) - assertThat(statement.accountIdentifier).isEqualTo(CustomerId) + expect(statement.bankCodeBicOrIban).toBe(BankCode) + expect(statement.accountIdentifier).toBe(CustomerId) assertBalance(statement.openingBalance, true, AccountStatement1PreviousStatementBookingDate, AccountStatement1OpeningBalanceAmount) assertBalance(statement.closingBalance, true, AccountStatement1BookingDate, AccountStatement1With2TransactionsClosingBalanceAmount) - assertThat(statement.transactions).hasSize(2) + expect(statement.transactions).hasSize(2) val firstTransaction = statement.transactions.first() assertTurnover(firstTransaction.statementLine, AccountStatement1BookingDate, AccountStatement1Transaction1Amount) @@ -150,13 +154,13 @@ class Mt940ParserTest : FinTsTestBase() { // then - assertThat(result).hasSize(1) - assertThat(result.first().transactions).hasSize(2) + expect(result).hasSize(1) + expect(result.first().transactions).hasSize(2) - assertThat(result.first().transactions[0].statementLine.bookingDate).isEqualTo(Date(119, 11, 30)) - assertThat(result.first().transactions[0].statementLine.valueDate).isEqualTo(Date(120, 0, 1)) - assertThat(result.first().transactions[1].statementLine.bookingDate).isEqualTo(Date(119, 11, 30)) - assertThat(result.first().transactions[1].statementLine.valueDate).isEqualTo(Date(120, 0, 1)) + expect(result.first().transactions[0].statementLine.bookingDate).toBe(Date(2019, 12, 30)) + expect(result.first().transactions[0].statementLine.valueDate).toBe(Date(2020, 1, 1)) + expect(result.first().transactions[1].statementLine.bookingDate).toBe(Date(2019, 12, 30)) + expect(result.first().transactions[1].statementLine.valueDate).toBe(Date(2020, 1, 1)) } @Test @@ -218,8 +222,8 @@ class Mt940ParserTest : FinTsTestBase() { // then - assertThat(result).hasSize(3) - assertThat(result.flatMap { it.transactions }).hasSize(7) + expect(result).hasSize(3) + expect(result.flatMap { it.transactions }).hasSize(7) } @Test @@ -257,61 +261,46 @@ class Mt940ParserTest : FinTsTestBase() { // then - assertThat(result).hasSize(1) - assertThat(result.flatMap { it.transactions }).hasSize(3) + expect(result).hasSize(1) + expect(result.flatMap { it.transactions }).hasSize(3) result.flatMap { it.transactions }.forEach { transaction -> - assertThat(transaction.information).isNotNull() + expect(transaction.information).notToBeNull() - assertThat(transaction.information?.sepaUsage).isNotNull() + expect(transaction.information?.sepaUsage).notToBeNull() if (transaction.information?.unparsedUsage?.contains("KREF+") == true) { - assertThat(transaction.information?.customerReference).isNotNull() + expect(transaction.information?.customerReference).notToBeNull() } } } - @Test - fun parseTransactions() { - - // given - val transactionsString = loadTestFile(TransactionsMt940Filename) - - - // when - val result = underTest.parseMt940String(transactionsString) - - - // then - assertThat(result).hasSize(32) - } - private fun assertBalance(balance: Balance, isCredit: Boolean, bookingDate: Date, amount: BigDecimal) { - assertThat(balance.isCredit).isEqualTo(isCredit) - assertThat(balance.bookingDate).isEqualTo(bookingDate) - assertThat(balance.amount).isEqualTo(amount) - assertThat(balance.currency).isEqualTo(Currency) + expect(balance.isCredit).toBe(isCredit) + expect(balance.bookingDate).toBe(bookingDate) + expect(balance.amount).toBe(amount) + expect(balance.currency).toBe(Currency) } private fun assertTurnover(statementLine: StatementLine, valueDate: Date, amount: BigDecimal, isCredit: Boolean = true, bookingDate: Date? = valueDate) { - assertThat(statementLine.isCredit).isEqualTo(isCredit) - assertThat(statementLine.isReversal).isFalse() - assertThat(statementLine.valueDate).isEqualTo(valueDate) - assertThat(statementLine.bookingDate).isEqualTo(bookingDate) - assertThat(statementLine.amount).isEqualTo(amount) + expect(statementLine.isCredit).toBe(isCredit) + expect(statementLine.isReversal).isFalse() + expect(statementLine.valueDate).toBe(valueDate) + expect(statementLine.bookingDate).toBe(bookingDate) + expect(statementLine.amount).toBe(amount) } private fun assertTransactionDetails(details: InformationToAccountOwner?, otherPartyName: String, otherPartyBankCode: String, otherPartyAccountId: String) { - assertThat(details).isNotNull() + expect(details).notToBeNull() - assertThat(details?.otherPartyName).isEqualTo(otherPartyName) - assertThat(details?.otherPartyBankCode).isEqualTo(otherPartyBankCode) - assertThat(details?.otherPartyAccountId).isEqualTo(otherPartyAccountId) + expect(details?.otherPartyName).toBe(otherPartyName) + expect(details?.otherPartyBankCode).toBe(otherPartyBankCode) + expect(details?.otherPartyAccountId).toBe(otherPartyAccountId) } @@ -360,11 +349,11 @@ class Mt940ParserTest : FinTsTestBase() { private fun convertMt940Date(date: Date): String { - return Mt940Parser.DateFormat.format(date) + return Mt940Parser.DateFormat.format(date.dateTimeDayStart.localUnadjusted) } private fun convertToShortBookingDate(date: Date): String { - return SimpleDateFormat("MMdd").format(date) + return DateFormat("MMdd").format(date.dateTimeDayStart.localUnadjusted) } } \ No newline at end of file diff --git a/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/util/Base64Test.kt b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/util/Base64Test.kt new file mode 100644 index 00000000..6cf5ae13 --- /dev/null +++ b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/util/Base64Test.kt @@ -0,0 +1,92 @@ +package net.dankito.banking.fints.util + +import ch.tutteli.atrium.api.fluent.en_GB.ExperimentalWithOptions +import ch.tutteli.atrium.api.fluent.en_GB.toBe +import ch.tutteli.atrium.api.fluent.en_GB.withRepresentation +import ch.tutteli.atrium.api.verbs.expect +import com.soywiz.klock.DateTime +import kotlin.random.Random +import kotlin.test.Test + + +class Base64Test { + + private val underTest = Base64() + + + @Test + fun encode() { + testEncode("Kotlin is awesome", "S290bGluIGlzIGF3ZXNvbWU=") + } + + @Test + fun testEncodingPadding() { + testEncode("", "") + testEncode("1", "MQ==") + testEncode("22", "MjI=") + testEncode("333", "MzMz") + testEncode("4444", "NDQ0NA==") + } + + private fun testEncode(input: String, expectedOutput: String) { + val actualOutput = underTest.encode(input) + + expect(actualOutput).toBe(expectedOutput) + } + + + @Test + fun decode() { + testDecode("S290bGluIGlzIGF3ZXNvbWU=", "Kotlin is awesome") + } + + @Test + fun testDecodingPadding() { + testDecode("", "") + testDecode("MQ==", "1") + testDecode("MjI=", "22") + testDecode("MzMz", "333") + testDecode("NDQ0NA==", "4444") + } + + private fun testDecode(input: String, expectedOutput: String) { + val actualOutput = underTest.decode(input) + + expect(actualOutput).toBe(expectedOutput) + } + + + @Test + @ExperimentalWithOptions + fun testRandomStrings() { + val steps = 1000000 + val random = Random(DateTime.nowUnixLong()) + + for (count in 0 until steps) { + // given + val original = createRandomString(random) + + + // when + val encoded: String = underTest.encode(original) + + val decoded = underTest.decode(encoded) + + + // then + expect(decoded).withRepresentation { "Decoded string '$decoded' should actually be '$original'" }.toBe(original) + } + } + + private fun createRandomString(random: Random): String { + val len: Int = random.nextInt(1, 1000) + val original = CharArray(len) + + for (i in 0 until len) { + original[i] = random.nextInt(0xFF).toChar() + } + + return original.toString() + } + +} \ No newline at end of file diff --git a/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/util/FinTsUtilsTest.kt b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/util/FinTsUtilsTest.kt new file mode 100644 index 00000000..200639ac --- /dev/null +++ b/fints4k/src/commonTest/kotlin/net/dankito/banking/fints/util/FinTsUtilsTest.kt @@ -0,0 +1,93 @@ +package net.dankito.banking.fints.util + +import ch.tutteli.atrium.api.fluent.en_GB.toBe +import ch.tutteli.atrium.api.verbs.expect +import com.soywiz.klock.Date +import com.soywiz.klock.Time +import kotlin.test.Test + +class FinTsUtilsTest { + + private val underTest = FinTsUtils() + + + @Test + fun formatDate() { + + // given + val date = Date(1988, 3, 27) + + // when + val result = underTest.formatDate(date) + + // then + expect(result).toBe("19880327") + } + + @Test + fun formatDateAsInt() { + + // given + val date = Date(1988, 3, 27) + + // when + val result = underTest.formatDateAsInt(date) + + // then + expect(result).toBe(19880327) + } + + + @Test + fun formatTime_AM() { + + // given + val time = Time(8, 2, 1) + + // when + val result = underTest.formatTime(time) + + // then + expect(result).toBe("080201") + } + + @Test + fun formatTime_PM() { + + // given + val time = Time(18, 22, 51) + + // when + val result = underTest.formatTime(time) + + // then + expect(result).toBe("182251") + } + + @Test + fun formatTimeAsInt_AM() { + + // given + val time = Time(8, 2, 1) + + // when + val result = underTest.formatTimeAsInt(time) + + // then + expect(result).toBe(80201) + } + + @Test + fun formatTimeAsInt_PM() { + + // given + val time = Time(18, 22, 51) + + // when + val result = underTest.formatTimeAsInt(time) + + // then + expect(result).toBe(182251) + } + +} \ No newline at end of file diff --git a/fints4k/src/jvm6Main/kotlin/net/dankito/banking/fints/util/JavaThreadPool.kt b/fints4k/src/jvm6Main/kotlin/net/dankito/banking/fints/util/JavaThreadPool.kt new file mode 100644 index 00000000..07e46c30 --- /dev/null +++ b/fints4k/src/jvm6Main/kotlin/net/dankito/banking/fints/util/JavaThreadPool.kt @@ -0,0 +1,22 @@ +package net.dankito.banking.fints.util + +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors + + +open class JavaThreadPool : IThreadPool { + + protected val threadPool: ExecutorService = Executors.newCachedThreadPool() + + + override fun runAsync(runnable: () -> Unit) { + threadPool.execute(runnable) + } + + override fun shutDown() { + if (threadPool.isShutdown == false) { + threadPool.shutdownNow() + } + } + +} \ No newline at end of file diff --git a/fints4k/src/jvm6Main/kotlin/net/dankito/banking/fints/util/log/Slf4jLogger.kt b/fints4k/src/jvm6Main/kotlin/net/dankito/banking/fints/util/log/Slf4jLogger.kt new file mode 100644 index 00000000..61e843f5 --- /dev/null +++ b/fints4k/src/jvm6Main/kotlin/net/dankito/banking/fints/util/log/Slf4jLogger.kt @@ -0,0 +1,74 @@ +package net.dankito.banking.fints.util.log + + +open class Slf4jLogger(protected val slf4jLogger: org.slf4j.Logger) : Logger { + + override val name: String + get() = slf4jLogger.name + + + override val isFatalEnabled: Boolean + get() = isErrorEnabled + + override val isErrorEnabled: Boolean + get() = slf4jLogger.isErrorEnabled + + override val isWarnEnabled: Boolean + get() = slf4jLogger.isWarnEnabled + + override val isInfoEnabled: Boolean + get() = slf4jLogger.isInfoEnabled + + override val isDebugEnabled: Boolean + get() = slf4jLogger.isDebugEnabled + + override val isTraceEnabled: Boolean + get() = slf4jLogger.isTraceEnabled + + + override fun fatal(exception: Throwable?, vararg arguments: Any, message: () -> String) { + error(exception, *arguments, message = message) + } + + override fun error(exception: Throwable?, vararg arguments: Any, message: () -> String) { + log(exception, arguments, message, { msg, args -> slf4jLogger.error(msg, *args) } ) + } + + override fun warn(exception: Throwable?, vararg arguments: Any, message: () -> String) { + log(exception, arguments, message, { msg, args -> slf4jLogger.warn(msg, *args) } ) + } + + override fun info(exception: Throwable?, vararg arguments: Any, message: () -> String) { + log(exception, arguments, message, { msg, args -> slf4jLogger.info(msg, *args) } ) + } + + override fun debug(exception: Throwable?, vararg arguments: Any, message: () -> String) { + log(exception, arguments, message, { msg, args -> slf4jLogger.debug(msg, *args) } ) + } + + override fun trace(exception: Throwable?, vararg arguments: Any, message: () -> String) { + log(exception, arguments, message, { msg, args -> slf4jLogger.trace(msg, *args) } ) + } + + protected open fun log(exception: Throwable?, arguments: Array, messageCreator: () -> String, + logOnLevel: (String, Array) -> Unit) { + + val message = messageCreator() + + if (exception != null) { + if (arguments.isEmpty()) { + logOnLevel(message, arrayOf(exception)) + } + else { + val argumentsIncludingException: MutableList = mutableListOf(exception) + argumentsIncludingException.addAll(0, arguments.toList()) + + logOnLevel(message, argumentsIncludingException.toTypedArray()) + } + } + else { + logOnLevel(message, arguments) + } + } + +} \ No newline at end of file diff --git a/fints4k/src/jvm6Main/kotlin/net/dankito/banking/fints/util/log/Slf4jLoggerFactory.kt b/fints4k/src/jvm6Main/kotlin/net/dankito/banking/fints/util/log/Slf4jLoggerFactory.kt new file mode 100644 index 00000000..9226e901 --- /dev/null +++ b/fints4k/src/jvm6Main/kotlin/net/dankito/banking/fints/util/log/Slf4jLoggerFactory.kt @@ -0,0 +1,12 @@ +package net.dankito.banking.fints.util.log + +import org.slf4j.LoggerFactory + + +open class Slf4jLoggerFactory : CachedLoggerFactory() { + + override fun createLogger(name: String): Logger { + return Slf4jLogger(LoggerFactory.getLogger(name)) + } + +} \ No newline at end of file diff --git a/fints4k/src/jvm6Test/kotlin/net/dankito/banking/fints/FinTsClientTestJvm.kt b/fints4k/src/jvm6Test/kotlin/net/dankito/banking/fints/FinTsClientTestJvm.kt new file mode 100644 index 00000000..7b0a953a --- /dev/null +++ b/fints4k/src/jvm6Test/kotlin/net/dankito/banking/fints/FinTsClientTestJvm.kt @@ -0,0 +1,12 @@ +package net.dankito.banking.fints + +import net.dankito.banking.fints.util.* + + +class FinTsClientTestJvm : FinTsClientTestBase() { + + override fun createThreadPool(): IThreadPool { + return JavaThreadPool() + } + +} \ No newline at end of file diff --git a/fints4k/src/jvm6Test/kotlin/net/dankito/banking/fints/FinTsTestBaseJvm.kt b/fints4k/src/jvm6Test/kotlin/net/dankito/banking/fints/FinTsTestBaseJvm.kt new file mode 100644 index 00000000..c3e39272 --- /dev/null +++ b/fints4k/src/jvm6Test/kotlin/net/dankito/banking/fints/FinTsTestBaseJvm.kt @@ -0,0 +1,25 @@ +package net.dankito.banking.fints + +import java.io.File +import java.nio.charset.Charset + + +open class FinTsTestBaseJvm : FinTsTestBase() { + + companion object { + const val TestFilesFolderName = "test_files/" + + const val TransactionsMt940Filename = "TransactionsMt940.txt" + } + + + /** + * 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 = FinTsTestBaseJvm::class.java.classLoader.getResourceAsStream(File(TestFilesFolderName, testFilename).path) + + return fileStream.reader(charset).readText() + } + +} \ No newline at end of file diff --git a/fints4k/src/test/kotlin/net/dankito/banking/fints/bankdetails/BanksFinTsDetailsRetriever.kt b/fints4k/src/jvm6Test/kotlin/net/dankito/banking/fints/bankdetails/BanksFinTsDetailsRetriever.kt similarity index 97% rename from fints4k/src/test/kotlin/net/dankito/banking/fints/bankdetails/BanksFinTsDetailsRetriever.kt rename to fints4k/src/jvm6Test/kotlin/net/dankito/banking/fints/bankdetails/BanksFinTsDetailsRetriever.kt index 413b09fa..26c3e40f 100644 --- a/fints4k/src/test/kotlin/net/dankito/banking/fints/bankdetails/BanksFinTsDetailsRetriever.kt +++ b/fints4k/src/jvm6Test/kotlin/net/dankito/banking/fints/bankdetails/BanksFinTsDetailsRetriever.kt @@ -1,7 +1,7 @@ package net.dankito.banking.fints.bankdetails import net.dankito.banking.fints.FinTsClient -import net.dankito.banking.fints.banks.InMemoryBankFinder +import net.dankito.banking.bankfinder.InMemoryBankFinder import net.dankito.banking.fints.callback.NoOpFinTsClientCallback import net.dankito.banking.fints.messages.MessageBuilder import net.dankito.banking.fints.messages.MessageBuilderResult @@ -11,16 +11,18 @@ import net.dankito.banking.fints.messages.datenelemente.implementierte.tan.Auftr import net.dankito.banking.fints.messages.datenelemente.implementierte.tan.BezeichnungDesTanMediumsErforderlich import net.dankito.banking.fints.messages.datenelemente.implementierte.tan.SmsAbbuchungskontoErforderlich import net.dankito.banking.fints.model.* -import net.dankito.banking.fints.model.mapper.BankDataMapper +import net.dankito.banking.mapper.BankDataMapper +import net.dankito.banking.bankfinder.BankInfo import net.dankito.banking.fints.response.Response import net.dankito.banking.fints.response.segments.SepaAccountInfoParameters import net.dankito.banking.fints.response.segments.TanInfo import net.dankito.banking.fints.response.segments.TanProcedureParameters -import net.dankito.banking.fints.util.Java8Base64Service +import net.dankito.banking.fints.util.* +import net.dankito.banking.fints.webclient.KtorWebClient import org.apache.commons.csv.CSVFormat import org.apache.commons.csv.CSVPrinter import org.junit.Ignore -import org.junit.Test +import kotlin.test.Test import org.slf4j.LoggerFactory import java.io.File import java.io.FileWriter @@ -46,7 +48,7 @@ class BanksFinTsDetailsRetriever { private val messageBuilder = MessageBuilder() - private val finTsClient = object : FinTsClient(NoOpFinTsClientCallback(), Java8Base64Service()) { + private val finTsClient = object : FinTsClient(NoOpFinTsClientCallback(), KtorWebClient(), PureKotlinBase64Service(), JavaThreadPool()) { fun getAndHandleResponseForMessagePublic(message: MessageBuilderResult, dialogContext: DialogContext): Response { return getAndHandleResponseForMessage(message, dialogContext) diff --git a/fints4k/src/jvm6Test/kotlin/net/dankito/banking/fints/response/ResponseParserTestJvm.kt b/fints4k/src/jvm6Test/kotlin/net/dankito/banking/fints/response/ResponseParserTestJvm.kt new file mode 100644 index 00000000..e4a191be --- /dev/null +++ b/fints4k/src/jvm6Test/kotlin/net/dankito/banking/fints/response/ResponseParserTestJvm.kt @@ -0,0 +1,37 @@ +package net.dankito.banking.fints.response + +import net.dankito.banking.fints.FinTsTestBaseJvm +import net.dankito.banking.fints.messages.HbciCharset +import net.dankito.banking.fints.tan.TanImageDecoder +import org.assertj.core.api.Assertions.assertThat +import org.junit.Test +import java.nio.charset.Charset + + +class ResponseParserTestJvm : FinTsTestBaseJvm() { + + private val underTest = ResponseParser() + + + @Test + fun `decode TanChallenge HHD_UC`() { + + // given + val response = loadTestFile("Decode_TanChallengeHhdUc_WithMaskedCharacter.txt", Charset.forName(HbciCharset.DefaultCharset.displayName())) + + + // when + val result = underTest.parse(response) + + + // then + assertThat(result.successful).isTrue() + + assertThat(result.tanResponse).isNotNull + + val decodedChallengeHhdUc = TanImageDecoder().decodeChallenge(result.tanResponse?.challengeHHD_UC ?: "") + assertThat(decodedChallengeHhdUc.decodingSuccessful).isTrue() + assertThat(decodedChallengeHhdUc.imageBytes.size).isEqualTo(3664) + } + +} \ No newline at end of file diff --git a/fints4k/src/test/kotlin/net/dankito/banking/fints/transactions/Mt940AccountTransactionsParserTest.kt b/fints4k/src/jvm6Test/kotlin/net/dankito/banking/fints/transactions/Mt940AccountTransactionsParserTest.kt similarity index 82% rename from fints4k/src/test/kotlin/net/dankito/banking/fints/transactions/Mt940AccountTransactionsParserTest.kt rename to fints4k/src/jvm6Test/kotlin/net/dankito/banking/fints/transactions/Mt940AccountTransactionsParserTest.kt index 18201c38..a92b7fe2 100644 --- a/fints4k/src/test/kotlin/net/dankito/banking/fints/transactions/Mt940AccountTransactionsParserTest.kt +++ b/fints4k/src/jvm6Test/kotlin/net/dankito/banking/fints/transactions/Mt940AccountTransactionsParserTest.kt @@ -1,12 +1,12 @@ package net.dankito.banking.fints.transactions -import net.dankito.banking.fints.FinTsTestBase +import net.dankito.banking.fints.FinTsTestBaseJvm import net.dankito.banking.fints.model.AccountData import org.assertj.core.api.Assertions.assertThat import org.junit.Test -class Mt940AccountTransactionsParserTest : FinTsTestBase() { +class Mt940AccountTransactionsParserTest : FinTsTestBaseJvm() { private val underTest = Mt940AccountTransactionsParser() diff --git a/fints4k/src/jvm6Test/kotlin/net/dankito/banking/fints/transactions/Mt940ParserTestJvm.kt b/fints4k/src/jvm6Test/kotlin/net/dankito/banking/fints/transactions/Mt940ParserTestJvm.kt new file mode 100644 index 00000000..38b1b399 --- /dev/null +++ b/fints4k/src/jvm6Test/kotlin/net/dankito/banking/fints/transactions/Mt940ParserTestJvm.kt @@ -0,0 +1,29 @@ +package net.dankito.banking.fints.transactions + +import net.dankito.banking.fints.FinTsTestBaseJvm +import net.dankito.banking.fints.transactions.mt940.Mt940Parser +import org.assertj.core.api.Assertions.assertThat +import org.junit.Test + + +class Mt940ParserTestJvm : FinTsTestBaseJvm() { + + private val underTest = Mt940Parser() + + + @Test + fun parseTransactions() { + + // given + val transactionsString = loadTestFile(TransactionsMt940Filename) + + + // when + val result = underTest.parseMt940String(transactionsString) + + + // then + assertThat(result).hasSize(32) + } + +} \ No newline at end of file diff --git a/fints4k/src/test/resources/logback-test.xml b/fints4k/src/jvm6Test/resources/logback-test.xml similarity index 100% rename from fints4k/src/test/resources/logback-test.xml rename to fints4k/src/jvm6Test/resources/logback-test.xml diff --git a/fints4k/src/test/resources/test_files/Decode_TanChallengeHhdUc_WithMaskedCharacter.txt b/fints4k/src/jvm6Test/resources/test_files/Decode_TanChallengeHhdUc_WithMaskedCharacter.txt similarity index 100% rename from fints4k/src/test/resources/test_files/Decode_TanChallengeHhdUc_WithMaskedCharacter.txt rename to fints4k/src/jvm6Test/resources/test_files/Decode_TanChallengeHhdUc_WithMaskedCharacter.txt diff --git a/fints4k/src/test/resources/test_files/TransactionsMt940.txt b/fints4k/src/jvm6Test/resources/test_files/TransactionsMt940.txt similarity index 100% rename from fints4k/src/test/resources/test_files/TransactionsMt940.txt rename to fints4k/src/jvm6Test/resources/test_files/TransactionsMt940.txt diff --git a/fints4k/src/test/resources/test_files/TransactionsMt940_2.txt b/fints4k/src/jvm6Test/resources/test_files/TransactionsMt940_2.txt similarity index 100% rename from fints4k/src/test/resources/test_files/TransactionsMt940_2.txt rename to fints4k/src/jvm6Test/resources/test_files/TransactionsMt940_2.txt diff --git a/fints4k/src/main/AndroidManifest.xml b/fints4k/src/main/AndroidManifest.xml new file mode 100644 index 00000000..aa7335e3 --- /dev/null +++ b/fints4k/src/main/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/util/IBase64Service.kt b/fints4k/src/main/kotlin/net/dankito/banking/fints/util/IBase64Service.kt deleted file mode 100644 index c9d8e6ee..00000000 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/util/IBase64Service.kt +++ /dev/null @@ -1,27 +0,0 @@ -package net.dankito.banking.fints.util - -import net.dankito.banking.fints.messages.HbciCharset -import java.nio.charset.Charset - - -interface IBase64Service { - - companion object { - val DefaultCharset = HbciCharset.DefaultCharset - } - - - fun encode(text: String): String { - return encode(text, DefaultCharset) - } - - fun encode(text: String, charset: Charset): String - - - fun decode(base64: String): String { - return decode(base64, DefaultCharset) - } - - fun decode(base64: String, charset: Charset): String - -} \ No newline at end of file diff --git a/fints4k/src/main/resources/sepa/pain.001.001.03.xml b/fints4k/src/main/resources/sepa/pain.001.001.03.xml deleted file mode 100644 index 4a57d09f..00000000 --- a/fints4k/src/main/resources/sepa/pain.001.001.03.xml +++ /dev/null @@ -1 +0,0 @@ -$MessageId$$CreationDateTime$$NumberOfTransactions$$Amount$$DebitorName$$PaymentInformationId$TRF$NumberOfTransactions$$Amount$SEPA$RequestedExecutionDate$$DebitorName$$DebitorIban$$DebitorBic$SLEVNOTPROVIDED$Amount$$CreditorBic$$CreditorName$$CreditorIban$$Usage$ \ No newline at end of file diff --git a/fints4k/src/main/resources/sepa/pain.001.003.03.xml b/fints4k/src/main/resources/sepa/pain.001.003.03.xml deleted file mode 100644 index 92a727ee..00000000 --- a/fints4k/src/main/resources/sepa/pain.001.003.03.xml +++ /dev/null @@ -1 +0,0 @@ -$MessageId$$CreationDateTime$$NumberOfTransactions$$DebitorName$$PaymentInformationId$TRFtrue$NumberOfTransactions$$Amount$SEPA$RequestedExecutionDate$$DebitorName$$DebitorIban$$DebitorBic$SLEVNOTPROVIDED$Amount$$CreditorBic$$CreditorName$$CreditorIban$$Usage$ \ No newline at end of file diff --git a/fints4k/src/test/kotlin/net/dankito/banking/fints/util/FinTsUtilsTest.kt b/fints4k/src/test/kotlin/net/dankito/banking/fints/util/FinTsUtilsTest.kt deleted file mode 100644 index 2da2451d..00000000 --- a/fints4k/src/test/kotlin/net/dankito/banking/fints/util/FinTsUtilsTest.kt +++ /dev/null @@ -1,91 +0,0 @@ -package net.dankito.banking.fints.util - -import org.assertj.core.api.Assertions.assertThat -import org.junit.Test -import java.util.* - -class FinTsUtilsTest { - - private val underTest = FinTsUtils() - - - @Test - fun formatDate() { - - // given - val date = Date(88, 2, 27) - - // when - val result = underTest.formatDate(date) - - // then - assertThat(result).isEqualTo("19880327") - } - - @Test - fun formatDateAsInt() { - - // given - val date = Date(88, 2, 27) - - // when - val result = underTest.formatDateAsInt(date) - - // then - assertThat(result).isEqualTo(19880327) - } - - - @Test - fun formatTime_AM() { - - // given - val date = Date(119, 9, 1, 8, 2, 1) - - // when - val result = underTest.formatTime(date) - - // then - assertThat(result).isEqualTo("080201") - } - - @Test - fun formatTime_PM() { - - // given - val date = Date(119, 9, 1, 18, 22, 51) - - // when - val result = underTest.formatTime(date) - - // then - assertThat(result).isEqualTo("182251") - } - - @Test - fun formatTimeAsInt_AM() { - - // given - val date = Date(119, 9, 1, 8, 2, 1) - - // when - val result = underTest.formatTimeAsInt(date) - - // then - assertThat(result).isEqualTo(80201) - } - - @Test - fun formatTimeAsInt_PM() { - - // given - val date = Date(119, 9, 1, 18, 22, 51) - - // when - val result = underTest.formatTimeAsInt(date) - - // then - assertThat(result).isEqualTo(182251) - } - -} \ No newline at end of file diff --git a/fints4k/src/test/kotlin/net/dankito/banking/fints/util/Java8Base64Service.kt b/fints4k/src/test/kotlin/net/dankito/banking/fints/util/Java8Base64Service.kt deleted file mode 100644 index e0866bfc..00000000 --- a/fints4k/src/test/kotlin/net/dankito/banking/fints/util/Java8Base64Service.kt +++ /dev/null @@ -1,21 +0,0 @@ -package net.dankito.banking.fints.util - -import java.nio.charset.Charset -import java.util.* - - -// TODO: use version from JavaFxUtils -class Java8Base64Service : IBase64Service { - - - override fun encode(text: String, charset: Charset): String { - return Base64.getEncoder().encodeToString(text.toByteArray(charset)) - } - - override fun decode(base64: String, charset: Charset): String { - val decodedBytes = Base64.getDecoder().decode(base64) - - return String(decodedBytes, charset) - } - -} diff --git a/settings.gradle b/settings.gradle index ee0b5235..3c549273 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,6 +1,10 @@ rootProject.name = 'fints4kProject' +enableFeaturePreview('GRADLE_METADATA') // for klock + + include ':fints4k' +include ':fints4k-jvm' /* UI */ @@ -36,7 +40,9 @@ project(':LuceneBankingPersistence').projectDir = "$rootDir/persistence/LuceneBa /* Tools */ +include ':BankFinder' include ':BankListCreator' +project(':BankFinder').projectDir = "$rootDir/tools/BankFinder/" as File project(':BankListCreator').projectDir = "$rootDir/tools/BankListCreator/" as File diff --git a/tools/BankFinder/build.gradle b/tools/BankFinder/build.gradle new file mode 100644 index 00000000..e0d87d9a --- /dev/null +++ b/tools/BankFinder/build.gradle @@ -0,0 +1,20 @@ +apply plugin: 'java-library' +apply plugin: 'kotlin' + +sourceCompatibility = "7" +targetCompatibility = "7" + + +dependencies { + implementation project(":BankingUiCommon") + + implementation "net.dankito.search:lucene-4-utils:$luceneUtilsVersion" + + + testImplementation "org.junit.jupiter:junit-jupiter:$junit5Version" + testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit5Version" + + testImplementation "org.assertj:assertj-core:$assertJVersion" + testImplementation "org.mockito:mockito-core:$mockitoVersion" + +} \ No newline at end of file diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/banks/BankFinderBase.kt b/tools/BankFinder/src/main/kotlin/net/dankito/banking/bankfinder/BankFinderBase.kt similarity index 94% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/banks/BankFinderBase.kt rename to tools/BankFinder/src/main/kotlin/net/dankito/banking/bankfinder/BankFinderBase.kt index 978e4deb..1604d7b6 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/banks/BankFinderBase.kt +++ b/tools/BankFinder/src/main/kotlin/net/dankito/banking/bankfinder/BankFinderBase.kt @@ -1,6 +1,5 @@ -package net.dankito.banking.fints.banks +package net.dankito.banking.bankfinder -import net.dankito.banking.fints.model.BankInfo import net.dankito.utils.serialization.JacksonJsonSerializer import org.slf4j.LoggerFactory diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/banks/InMemoryBankFinder.kt b/tools/BankFinder/src/main/kotlin/net/dankito/banking/bankfinder/InMemoryBankFinder.kt similarity index 94% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/banks/InMemoryBankFinder.kt rename to tools/BankFinder/src/main/kotlin/net/dankito/banking/bankfinder/InMemoryBankFinder.kt index fe3e15a0..1e0077df 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/banks/InMemoryBankFinder.kt +++ b/tools/BankFinder/src/main/kotlin/net/dankito/banking/bankfinder/InMemoryBankFinder.kt @@ -1,6 +1,4 @@ -package net.dankito.banking.fints.banks - -import net.dankito.banking.fints.model.BankInfo +package net.dankito.banking.bankfinder open class InMemoryBankFinder() : BankFinderBase(), IBankFinder { diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/banks/LuceneBankFinder.kt b/tools/BankFinder/src/main/kotlin/net/dankito/banking/bankfinder/LuceneBankFinder.kt similarity index 97% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/banks/LuceneBankFinder.kt rename to tools/BankFinder/src/main/kotlin/net/dankito/banking/bankfinder/LuceneBankFinder.kt index 8a064b93..ce702c26 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/banks/LuceneBankFinder.kt +++ b/tools/BankFinder/src/main/kotlin/net/dankito/banking/bankfinder/LuceneBankFinder.kt @@ -1,6 +1,5 @@ -package net.dankito.banking.fints.banks +package net.dankito.banking.bankfinder -import net.dankito.banking.fints.model.BankInfo import net.dankito.utils.hashing.HashAlgorithm import net.dankito.utils.hashing.HashService import net.dankito.utils.io.FileUtils @@ -167,7 +166,8 @@ open class LuceneBankFinder(indexFolder: File) : BankFinderBase(), IBankFinder { createDocumentForBank(it, writer) }) - writer.updateDocument(IndexedBankListFileHashIdFieldName, IndexedBankListFileHashIdFieldValue, + writer.updateDocument( + IndexedBankListFileHashIdFieldName, IndexedBankListFileHashIdFieldValue, fields.storedField(IndexedBankListFileHashFieldName, bankListFileHash)) writer.optimizeIndex() diff --git a/fints4k/src/main/resources/BankList.json b/tools/BankFinder/src/main/resources/BankList.json similarity index 100% rename from fints4k/src/main/resources/BankList.json rename to tools/BankFinder/src/main/resources/BankList.json diff --git a/fints4k/src/test/kotlin/net/dankito/banking/fints/banks/BankFinderTestBase.kt b/tools/BankFinder/src/test/kotlin/net/dankito/banking/bankfinder/BankFinderTestBase.kt similarity index 95% rename from fints4k/src/test/kotlin/net/dankito/banking/fints/banks/BankFinderTestBase.kt rename to tools/BankFinder/src/test/kotlin/net/dankito/banking/bankfinder/BankFinderTestBase.kt index 6760cf27..b26399e4 100644 --- a/fints4k/src/test/kotlin/net/dankito/banking/fints/banks/BankFinderTestBase.kt +++ b/tools/BankFinder/src/test/kotlin/net/dankito/banking/bankfinder/BankFinderTestBase.kt @@ -1,7 +1,8 @@ -package net.dankito.banking.fints.banks +package net.dankito.banking.bankfinder import org.assertj.core.api.Assertions.assertThat -import org.junit.Test +import org.junit.jupiter.api.Test + abstract class BankFinderTestBase { diff --git a/fints4k/src/test/kotlin/net/dankito/banking/fints/banks/InMemoryBankFinderTest.kt b/tools/BankFinder/src/test/kotlin/net/dankito/banking/bankfinder/InMemoryBankFinderTest.kt similarity index 78% rename from fints4k/src/test/kotlin/net/dankito/banking/fints/banks/InMemoryBankFinderTest.kt rename to tools/BankFinder/src/test/kotlin/net/dankito/banking/bankfinder/InMemoryBankFinderTest.kt index 2759a2d2..163f6e09 100644 --- a/fints4k/src/test/kotlin/net/dankito/banking/fints/banks/InMemoryBankFinderTest.kt +++ b/tools/BankFinder/src/test/kotlin/net/dankito/banking/bankfinder/InMemoryBankFinderTest.kt @@ -1,4 +1,4 @@ -package net.dankito.banking.fints.banks +package net.dankito.banking.bankfinder class InMemoryBankFinderTest : BankFinderTestBase() { diff --git a/fints4k/src/test/kotlin/net/dankito/banking/fints/banks/LuceneBankFinderTest.kt b/tools/BankFinder/src/test/kotlin/net/dankito/banking/bankfinder/LuceneBankFinderTest.kt similarity index 83% rename from fints4k/src/test/kotlin/net/dankito/banking/fints/banks/LuceneBankFinderTest.kt rename to tools/BankFinder/src/test/kotlin/net/dankito/banking/bankfinder/LuceneBankFinderTest.kt index 86aafdb3..ec611ce8 100644 --- a/fints4k/src/test/kotlin/net/dankito/banking/fints/banks/LuceneBankFinderTest.kt +++ b/tools/BankFinder/src/test/kotlin/net/dankito/banking/bankfinder/LuceneBankFinderTest.kt @@ -1,7 +1,7 @@ -package net.dankito.banking.fints.banks +package net.dankito.banking.bankfinder import net.dankito.utils.io.FileUtils -import org.junit.AfterClass +import org.junit.jupiter.api.AfterAll import java.io.File @@ -11,7 +11,7 @@ class LuceneBankFinderTest : BankFinderTestBase() { private val IndexFolder = File("testData", "index") - @AfterClass + @AfterAll @JvmStatic fun deleteIndex() { FileUtils().deleteFolderRecursively(IndexFolder.parentFile) diff --git a/ui/BankingAndroidApp/build.gradle b/ui/BankingAndroidApp/build.gradle index 2d00f2b6..7a8b93d3 100644 --- a/ui/BankingAndroidApp/build.gradle +++ b/ui/BankingAndroidApp/build.gradle @@ -5,21 +5,29 @@ apply plugin: 'kotlin-kapt' android { - compileSdkVersion 28 + compileSdkVersion androidCompileSdkVersion + buildToolsVersion androidBuildToolsVersion defaultConfig { applicationId "net.dankito.banking.android" - minSdkVersion 16 - targetSdkVersion 28 + + minSdkVersion androidMinSdkVersion + targetSdkVersion androidTargetSdkVersion + + versionName version versionCode appVersionCode - versionName appVersionName multiDexEnabled true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + buildTypes { release { minifyEnabled false @@ -38,11 +46,21 @@ android { } packagingOptions { - exclude 'META-INF/DEPENDENCIES' - exclude 'META-INF/NOTICE' - exclude 'META-INF/LICENSE' - exclude 'META-INF/LICENSE.txt' - exclude 'META-INF/NOTICE.txt' + pickFirst 'META-INF/kotlinx-coroutines-io.kotlin_module' + pickFirst 'META-INF/kotlinx-io.kotlin_module' + pickFirst 'META-INF/kotlinx-serialization-runtime.kotlin_module' + pickFirst 'META-INF/ktor-utils.kotlin_module' + pickFirst 'META-INF/ktor-client-core.kotlin_module' + pickFirst 'META-INF/ktor-http.kotlin_module' + pickFirst 'META-INF/ktor-io.kotlin_module' + pickFirst 'META-INF/ktor-http-cio.kotlin_module' + pickFirst 'META-INF/atomicfu.kotlin_module' + + pickFirst 'META-INF/DEPENDENCIES' + pickFirst 'META-INF/NOTICE' + pickFirst 'META-INF/LICENSE' + pickFirst 'META-INF/LICENSE.txt' + pickFirst 'META-INF/NOTICE.txt' } lintOptions { @@ -52,10 +70,16 @@ android { } dependencies { + implementation project(":fints4k"), { + exclude group: "com.soywiz.korlibs.klock", module: "klock-android" // klock-jvm already adds required extensions, to avoid duplicates + } + implementation project(':BankingUiCommon') implementation project(':fints4kBankingClient') + implementation project(':BankFinder') + implementation project(':BankingPersistenceJson') implementation project(':LuceneBankingPersistence') diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/adapter/BankListAdapter.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/adapter/BankListAdapter.kt index 093e7473..7f018316 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/adapter/BankListAdapter.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/adapter/BankListAdapter.kt @@ -3,7 +3,7 @@ package net.dankito.banking.ui.android.adapter import android.view.View import net.dankito.banking.ui.android.R import net.dankito.banking.ui.android.adapter.viewholder.BankInfoViewHolder -import net.dankito.banking.fints.model.BankInfo +import net.dankito.banking.bankfinder.BankInfo import net.dankito.utils.android.extensions.setTintColor import net.dankito.utils.android.ui.adapter.ListRecyclerAdapter diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/adapter/presenter/BankInfoPresenter.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/adapter/presenter/BankInfoPresenter.kt index 48151dda..5341850a 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/adapter/presenter/BankInfoPresenter.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/adapter/presenter/BankInfoPresenter.kt @@ -6,7 +6,7 @@ import com.otaliastudios.autocomplete.RecyclerViewPresenter import kotlinx.coroutines.* import net.dankito.banking.ui.android.adapter.BankListAdapter import net.dankito.banking.ui.presenter.BankingPresenter -import net.dankito.banking.fints.model.BankInfo +import net.dankito.banking.bankfinder.BankInfo open class BankInfoPresenter(protected val presenter: BankingPresenter, context: Context) : RecyclerViewPresenter(context) { diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/di/BankingModule.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/di/BankingModule.kt index 944613ef..55466a9e 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/di/BankingModule.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/di/BankingModule.kt @@ -17,8 +17,8 @@ import net.dankito.banking.ui.IRouter import net.dankito.banking.ui.presenter.BankingPresenter import net.dankito.banking.util.BankIconFinder import net.dankito.banking.util.IBankIconFinder -import net.dankito.banking.fints.banks.IBankFinder -import net.dankito.banking.fints.banks.LuceneBankFinder +import net.dankito.banking.bankfinder.IBankFinder +import net.dankito.banking.bankfinder.LuceneBankFinder import net.dankito.utils.IThreadPool import net.dankito.utils.ThreadPool import net.dankito.utils.serialization.ISerializer diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/AddAccountDialog.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/AddAccountDialog.kt index bd7a40ae..9ae45dce 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/AddAccountDialog.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/AddAccountDialog.kt @@ -26,7 +26,7 @@ import net.dankito.banking.ui.android.extensions.closePopupOnBackButtonPress import net.dankito.banking.ui.android.util.StandardAutocompleteCallback import net.dankito.banking.ui.model.responses.AddAccountResponse import net.dankito.banking.ui.presenter.BankingPresenter -import net.dankito.banking.fints.model.BankInfo +import net.dankito.banking.bankfinder.BankInfo import net.dankito.utils.android.extensions.asActivity import javax.inject.Inject diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/TransferMoneyDialog.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/TransferMoneyDialog.kt index 88a34773..93ab0635 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/TransferMoneyDialog.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/dialogs/TransferMoneyDialog.kt @@ -31,7 +31,7 @@ import net.dankito.banking.ui.model.parameters.TransferMoneyData import net.dankito.banking.ui.model.responses.BankingClientResponse import net.dankito.banking.ui.presenter.BankingPresenter import net.dankito.banking.util.InputValidator -import net.dankito.banking.fints.model.BankInfo +import net.dankito.banking.bankfinder.BankInfo import net.dankito.utils.android.extensions.asActivity import java.math.BigDecimal import java.text.DecimalFormatSymbols diff --git a/ui/BankingJavaFxApp/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/mainwindow/MainWindow.kt b/ui/BankingJavaFxApp/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/mainwindow/MainWindow.kt index a5864c7e..62335dc1 100755 --- a/ui/BankingJavaFxApp/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/mainwindow/MainWindow.kt +++ b/ui/BankingJavaFxApp/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/mainwindow/MainWindow.kt @@ -9,7 +9,7 @@ import net.dankito.banking.ui.javafx.dialogs.mainwindow.controls.MainMenuBar import net.dankito.banking.ui.javafx.util.Base64ServiceJava8 import net.dankito.banking.ui.presenter.BankingPresenter import net.dankito.banking.util.BankIconFinder -import net.dankito.banking.fints.banks.LuceneBankFinder +import net.dankito.banking.bankfinder.LuceneBankFinder import net.dankito.banking.persistence.LuceneBankingPersistence import net.dankito.banking.search.LuceneRemitteeSearcher import net.dankito.utils.web.client.OkHttpWebClient diff --git a/ui/BankingJavaFxControls/build.gradle b/ui/BankingJavaFxControls/build.gradle index 16bd8f4c..4646902e 100644 --- a/ui/BankingJavaFxControls/build.gradle +++ b/ui/BankingJavaFxControls/build.gradle @@ -14,7 +14,11 @@ compileTestKotlin { dependencies { - api project(':BankingUiCommon') + api project(":BankingUiCommon") + + implementation project(":fints4k-jvm") + + api project(":BankFinder") api "net.dankito.utils:java-fx-utils:$javaFxUtilsVersion" } \ No newline at end of file diff --git a/ui/BankingJavaFxControls/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/AddAccountDialog.kt b/ui/BankingJavaFxControls/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/AddAccountDialog.kt index 8f20f6a4..05656c98 100755 --- a/ui/BankingJavaFxControls/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/AddAccountDialog.kt +++ b/ui/BankingJavaFxControls/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/AddAccountDialog.kt @@ -1,6 +1,5 @@ package net.dankito.banking.ui.javafx.dialogs -import com.sun.javafx.scene.traversal.Direction import javafx.beans.property.SimpleBooleanProperty import javafx.beans.property.SimpleStringProperty import javafx.geometry.Insets @@ -15,7 +14,7 @@ import javafx.scene.text.FontWeight import kotlinx.coroutines.* import net.dankito.banking.ui.model.responses.AddAccountResponse import net.dankito.banking.ui.presenter.BankingPresenter -import net.dankito.banking.fints.model.BankInfo +import net.dankito.banking.bankfinder.BankInfo import net.dankito.banking.ui.javafx.dialogs.addaccount.BankInfoListCellFragment import net.dankito.banking.ui.javafx.extensions.focusNextControl import net.dankito.utils.javafx.ui.controls.AutoCompletionSearchTextField diff --git a/ui/BankingJavaFxControls/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/addaccount/BankInfoListCellFragment.kt b/ui/BankingJavaFxControls/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/addaccount/BankInfoListCellFragment.kt index 7a75afb4..e1b8fb7c 100644 --- a/ui/BankingJavaFxControls/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/addaccount/BankInfoListCellFragment.kt +++ b/ui/BankingJavaFxControls/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/addaccount/BankInfoListCellFragment.kt @@ -1,14 +1,11 @@ package net.dankito.banking.ui.javafx.dialogs.addaccount import javafx.geometry.Pos -import javafx.scene.control.Labeled -import javafx.scene.effect.ColorAdjust import javafx.scene.image.Image import javafx.scene.image.ImageView import javafx.scene.layout.Priority -import javafx.scene.paint.Color import javafx.scene.text.Font -import net.dankito.banking.fints.model.BankInfo +import net.dankito.banking.bankfinder.BankInfo import tornadofx.* diff --git a/ui/BankingJavaFxControls/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/addaccount/BankInfoViewModel.kt b/ui/BankingJavaFxControls/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/addaccount/BankInfoViewModel.kt index 0830659f..5dfa4170 100644 --- a/ui/BankingJavaFxControls/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/addaccount/BankInfoViewModel.kt +++ b/ui/BankingJavaFxControls/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/addaccount/BankInfoViewModel.kt @@ -2,7 +2,7 @@ package net.dankito.banking.ui.javafx.dialogs.addaccount import javafx.beans.property.SimpleBooleanProperty import javafx.beans.property.SimpleStringProperty -import net.dankito.banking.fints.model.BankInfo +import net.dankito.banking.bankfinder.BankInfo import tornadofx.ItemViewModel diff --git a/ui/BankingJavaFxControls/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/cashtransfer/TransferMoneyDialog.kt b/ui/BankingJavaFxControls/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/cashtransfer/TransferMoneyDialog.kt index 860e22ae..bdb20e96 100644 --- a/ui/BankingJavaFxControls/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/cashtransfer/TransferMoneyDialog.kt +++ b/ui/BankingJavaFxControls/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/cashtransfer/TransferMoneyDialog.kt @@ -17,7 +17,7 @@ import net.dankito.banking.ui.model.parameters.TransferMoneyData import net.dankito.banking.ui.model.responses.BankingClientResponse import net.dankito.banking.ui.presenter.BankingPresenter import net.dankito.banking.util.InputValidator -import net.dankito.banking.fints.model.BankInfo +import net.dankito.banking.bankfinder.BankInfo import net.dankito.banking.search.Remittee import net.dankito.banking.ui.javafx.extensions.focusNextControl import net.dankito.utils.javafx.ui.controls.AutoCompletionSearchTextField diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/model/BankInfo.kt b/ui/BankingUiCommon/src/main/java/net/dankito/banking/bankfinder/BankInfo.kt similarity index 95% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/model/BankInfo.kt rename to ui/BankingUiCommon/src/main/java/net/dankito/banking/bankfinder/BankInfo.kt index bf4ba1ba..fe140e46 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/model/BankInfo.kt +++ b/ui/BankingUiCommon/src/main/java/net/dankito/banking/bankfinder/BankInfo.kt @@ -1,4 +1,4 @@ -package net.dankito.banking.fints.model +package net.dankito.banking.bankfinder open class BankInfo( diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/banks/IBankFinder.kt b/ui/BankingUiCommon/src/main/java/net/dankito/banking/bankfinder/IBankFinder.kt similarity index 71% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/banks/IBankFinder.kt rename to ui/BankingUiCommon/src/main/java/net/dankito/banking/bankfinder/IBankFinder.kt index a65c6817..036ccbad 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/banks/IBankFinder.kt +++ b/ui/BankingUiCommon/src/main/java/net/dankito/banking/bankfinder/IBankFinder.kt @@ -1,6 +1,4 @@ -package net.dankito.banking.fints.banks - -import net.dankito.banking.fints.model.BankInfo +package net.dankito.banking.bankfinder interface IBankFinder { diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/IBankingClientCreator.kt b/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/IBankingClientCreator.kt index dfeb7bf2..e19ef27b 100644 --- a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/IBankingClientCreator.kt +++ b/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/IBankingClientCreator.kt @@ -1,6 +1,6 @@ package net.dankito.banking.ui -import net.dankito.banking.fints.model.BankInfo +import net.dankito.banking.bankfinder.BankInfo import net.dankito.utils.IThreadPool import java.io.File diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/presenter/BankingPresenter.kt b/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/presenter/BankingPresenter.kt index 4ee646ed..2d9e7e86 100644 --- a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/presenter/BankingPresenter.kt +++ b/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/presenter/BankingPresenter.kt @@ -15,8 +15,8 @@ import net.dankito.banking.ui.model.tan.EnterTanResult import net.dankito.banking.ui.model.tan.TanChallenge import net.dankito.banking.ui.model.tan.TanGeneratorTanMedium import net.dankito.banking.util.IBankIconFinder -import net.dankito.banking.fints.banks.IBankFinder -import net.dankito.banking.fints.model.BankInfo +import net.dankito.banking.bankfinder.IBankFinder +import net.dankito.banking.bankfinder.BankInfo import net.dankito.banking.search.IRemitteeSearcher import net.dankito.banking.search.Remittee import net.dankito.banking.ui.model.parameters.GetTransactionsParameter diff --git a/ui/BankingUiCommon/src/test/kotlin/net/dankito/banking/util/BankIconFinderTest.kt b/ui/BankingUiCommon/src/test/kotlin/net/dankito/banking/util/BankIconFinderTest.kt index 45a2c110..3c1ef096 100644 --- a/ui/BankingUiCommon/src/test/kotlin/net/dankito/banking/util/BankIconFinderTest.kt +++ b/ui/BankingUiCommon/src/test/kotlin/net/dankito/banking/util/BankIconFinderTest.kt @@ -1,6 +1,6 @@ package net.dankito.banking.util -import net.dankito.banking.fints.banks.InMemoryBankFinder +import net.dankito.banking.bankfinder.InMemoryBankFinder import org.assertj.core.api.Assertions.assertThat import org.junit.Test diff --git a/ui/fints4kBankingClient/build.gradle b/ui/fints4kBankingClient/build.gradle index 553cbd7f..8c079173 100644 --- a/ui/fints4kBankingClient/build.gradle +++ b/ui/fints4kBankingClient/build.gradle @@ -16,8 +16,4 @@ compileTestKotlin { dependencies { api project(':BankingUiCommon') implementation project(':fints4k') - - - testImplementation "junit:junit:$junitVersion" - testImplementation "org.assertj:assertj-core:$assertJVersion" } \ No newline at end of file diff --git a/ui/fints4kBankingClient/src/main/kotlin/net/dankito/banking/extensions/BigDecimalExtensions.kt b/ui/fints4kBankingClient/src/main/kotlin/net/dankito/banking/extensions/BigDecimalExtensions.kt new file mode 100644 index 00000000..27d74d82 --- /dev/null +++ b/ui/fints4kBankingClient/src/main/kotlin/net/dankito/banking/extensions/BigDecimalExtensions.kt @@ -0,0 +1,24 @@ +package net.dankito.banking.extensions + +import com.ionspin.kotlin.bignum.integer.Sign +import net.dankito.banking.fints.model.Money +import java.math.BigDecimal + + +fun BigDecimal.toIonspinBigDecimal(): com.ionspin.kotlin.bignum.decimal.BigDecimal { + return com.ionspin.kotlin.bignum.decimal.BigDecimal.parseString(this.toString()) // TODO: couldn't figure out how to create BigDecimal from unscaledValue and scale +} + +fun com.ionspin.kotlin.bignum.decimal.BigDecimal.toJavaBigDecimal(): BigDecimal { + val converted = BigDecimal.valueOf(this.significand.longValue(), (this.precision - this.exponent - 1).toInt()) + + if (this.significand.sign == Sign.NEGATIVE) { + return converted.negate() + } + + return converted +} + +fun Money.toJavaBigDecimal(): BigDecimal { + return this.amount.toJavaBigDecimal() +} \ No newline at end of file diff --git a/ui/fints4kBankingClient/src/main/kotlin/net/dankito/banking/extensions/DateExtensions.kt b/ui/fints4kBankingClient/src/main/kotlin/net/dankito/banking/extensions/DateExtensions.kt new file mode 100644 index 00000000..1f0ff829 --- /dev/null +++ b/ui/fints4kBankingClient/src/main/kotlin/net/dankito/banking/extensions/DateExtensions.kt @@ -0,0 +1,21 @@ +package net.dankito.banking.extensions + +import com.soywiz.klock.jvm.toDate +import com.soywiz.klock.jvm.toDateTime +import java.text.SimpleDateFormat +import java.util.* + + +fun Date.toKlockDate(): com.soywiz.klock.Date { + return this.toDateTime().date +} + +fun com.soywiz.klock.Date.toJavaUtilDate(): Date { + try { + // there's a bug that some banks like Sparkasse return as date '190229' (= 29.02.2019), which simply doesn't exist + return this.dateTimeDayStart.toDate() + } catch (e: Exception) { // -> catch it and parse it manually, java.util.Date knows how to handle this + return SimpleDateFormat("yyyy-MM-dd").parse(String.format("%04d-%02d-%02d", this.year, this.month1, this.day)) + } + +} \ No newline at end of file diff --git a/ui/fints4kBankingClient/src/main/kotlin/net/dankito/banking/fints4kBankingClient.kt b/ui/fints4kBankingClient/src/main/kotlin/net/dankito/banking/fints4kBankingClient.kt index f6551818..4add3f33 100644 --- a/ui/fints4kBankingClient/src/main/kotlin/net/dankito/banking/fints4kBankingClient.kt +++ b/ui/fints4kBankingClient/src/main/kotlin/net/dankito/banking/fints4kBankingClient.kt @@ -1,5 +1,9 @@ package net.dankito.banking +import net.dankito.banking.extensions.toIonspinBigDecimal +import net.dankito.banking.extensions.toJavaBigDecimal +import com.soywiz.klock.jvm.toDate +import net.dankito.banking.extensions.toKlockDate import net.dankito.banking.ui.BankingClientCallback import net.dankito.banking.ui.IBankingClient import net.dankito.banking.ui.model.Account @@ -14,13 +18,15 @@ import net.dankito.banking.fints.FinTsClientForCustomer import net.dankito.banking.fints.callback.FinTsClientCallback import net.dankito.banking.fints.messages.datenelemente.implementierte.tan.TanGeneratorTanMedium import net.dankito.banking.fints.model.* -import net.dankito.banking.fints.model.mapper.BankDataMapper +import net.dankito.banking.mapper.BankDataMapper import net.dankito.banking.fints.util.IBase64Service -import net.dankito.utils.IThreadPool -import net.dankito.utils.ThreadPool +import net.dankito.banking.fints.util.PureKotlinBase64Service +import net.dankito.banking.fints.util.IThreadPool +import net.dankito.banking.fints.util.JavaThreadPool import net.dankito.utils.serialization.JacksonJsonSerializer -import net.dankito.utils.web.client.IWebClient -import net.dankito.utils.web.client.OkHttpWebClient +import net.dankito.banking.fints.webclient.IWebClient +import net.dankito.banking.fints.webclient.KtorWebClient +import net.dankito.banking.bankfinder.BankInfo import org.slf4j.LoggerFactory import java.io.File @@ -30,9 +36,9 @@ open class fints4kBankingClient( customerId: String, pin: String, protected val dataFolder: File, - webClient: IWebClient = OkHttpWebClient(), - base64Service: IBase64Service, - threadPool: IThreadPool = ThreadPool(), + webClient: IWebClient = KtorWebClient(), + base64Service: IBase64Service = PureKotlinBase64Service(), + threadPool: IThreadPool = JavaThreadPool(), callback: BankingClientCallback ) : IBankingClient { @@ -41,6 +47,11 @@ open class fints4kBankingClient( val fints4kClientDataFilename = "fints4kClientData.json" private val log = LoggerFactory.getLogger(fints4kBankingClient::class.java) + + + init { + net.dankito.banking.fints.util.log.LoggerFactory.loggerFactory = net.dankito.banking.fints.util.log.Slf4jLoggerFactory() + } } @@ -58,7 +69,7 @@ open class fints4kBankingClient( protected var account: Account = mapper.mapAccount(customer, bank) // temporary save temp account, we update with data from server response like BankAccounts later - protected val client = FinTsClientForCustomer(bank, customer, webClient, base64Service, threadPool, object : FinTsClientCallback { + protected val client = FinTsClientForCustomer(bank, customer, object : FinTsClientCallback { override fun askUserForTanProcedure(supportedTanProcedures: List, suggestedTanProcedure: TanProcedure?): TanProcedure? { // we simply return suggestedTanProcedure as even so it's not user's preferred TAN procedure she still can select it in EnterTanDialog @@ -81,11 +92,11 @@ open class fints4kBankingClient( return mapper.mapEnterTanGeneratorAtcResult(result) } - }) + }, webClient, base64Service, threadPool) override val messageLogWithoutSensitiveData: List - get() = client.messageLogWithoutSensitiveData.map { MessageLogEntry(it.message, it.time, account) } + get() = client.messageLogWithoutSensitiveData.map { MessageLogEntry(it.message, it.time.toDate(), account) } override fun addAccountAsync(callback: (AddAccountResponse) -> Unit) { @@ -106,7 +117,7 @@ open class fints4kBankingClient( callback(GetTransactionsResponse(bankAccount, false, "Cannot find account for ${bankAccount.identifier}")) // TODO: translate } else { - client.getTransactionsAsync(GetTransactionsParameter(parameter.alsoRetrieveBalance, parameter.fromDate, parameter.toDate, null, parameter.abortIfTanIsRequired, + client.getTransactionsAsync(GetTransactionsParameter(parameter.alsoRetrieveBalance, parameter.fromDate?.toKlockDate(), parameter.toDate?.toKlockDate(), null, parameter.abortIfTanIsRequired, { parameter.retrievedChunkListener?.invoke(mapper.mapTransactions(bankAccount, it)) } ), account) { response -> val mappedResponse = mapper.mapResponse(bankAccount, response) @@ -125,7 +136,7 @@ open class fints4kBankingClient( callback(BankingClientResponse(false, "Cannot find account for ${bankAccount.identifier}")) // TODO: translate } else { - val mappedData = BankTransferData(data.creditorName, data.creditorIban, data.creditorBic, data.amount, data.usage, data.instantPayment) + val mappedData = BankTransferData(data.creditorName, data.creditorIban, data.creditorBic, data.amount.toIonspinBigDecimal(), data.usage, data.instantPayment) client.doBankTransferAsync(mappedData, account) { response -> saveData() diff --git a/ui/fints4kBankingClient/src/main/kotlin/net/dankito/banking/fints4kBankingClientCreator.kt b/ui/fints4kBankingClient/src/main/kotlin/net/dankito/banking/fints4kBankingClientCreator.kt index ea22ca70..3120dca4 100644 --- a/ui/fints4kBankingClient/src/main/kotlin/net/dankito/banking/fints4kBankingClientCreator.kt +++ b/ui/fints4kBankingClient/src/main/kotlin/net/dankito/banking/fints4kBankingClientCreator.kt @@ -4,16 +4,15 @@ import net.dankito.banking.ui.BankingClientCallback import net.dankito.banking.ui.IBankingClient import net.dankito.banking.ui.IBankingClientCreator import net.dankito.banking.util.IBase64Service -import net.dankito.banking.util.UiCommonBase64ServiceWrapper -import net.dankito.banking.fints.model.BankInfo +import net.dankito.banking.bankfinder.BankInfo import net.dankito.utils.IThreadPool import net.dankito.utils.web.client.IWebClient import java.io.File open class fints4kBankingClientCreator( - protected val webClient: IWebClient, - protected val base64Service: IBase64Service + protected val webClient: IWebClient, // TODO: remove? + protected val base64Service: IBase64Service // TODO: remove? ) : IBankingClientCreator { override fun createClient( @@ -21,11 +20,11 @@ open class fints4kBankingClientCreator( customerId: String, pin: String, dataFolder: File, - threadPool: IThreadPool, + threadPool: IThreadPool, // TODO: remove? callback: BankingClientCallback ): IBankingClient { - return fints4kBankingClient(bankInfo, customerId, pin, dataFolder, webClient, UiCommonBase64ServiceWrapper(base64Service), threadPool, callback) + return fints4kBankingClient(bankInfo, customerId, pin, dataFolder, callback = callback) } } \ No newline at end of file diff --git a/fints4k/src/main/kotlin/net/dankito/banking/fints/model/mapper/BankDataMapper.kt b/ui/fints4kBankingClient/src/main/kotlin/net/dankito/banking/mapper/BankDataMapper.kt similarity index 90% rename from fints4k/src/main/kotlin/net/dankito/banking/fints/model/mapper/BankDataMapper.kt rename to ui/fints4kBankingClient/src/main/kotlin/net/dankito/banking/mapper/BankDataMapper.kt index 72533a23..eb3da535 100644 --- a/fints4k/src/main/kotlin/net/dankito/banking/fints/model/mapper/BankDataMapper.kt +++ b/ui/fints4kBankingClient/src/main/kotlin/net/dankito/banking/mapper/BankDataMapper.kt @@ -1,8 +1,8 @@ -package net.dankito.banking.fints.model.mapper +package net.dankito.banking.mapper import net.dankito.banking.fints.messages.datenelemente.abgeleiteteformate.Laenderkennzeichen import net.dankito.banking.fints.model.BankData -import net.dankito.banking.fints.model.BankInfo +import net.dankito.banking.bankfinder.BankInfo open class BankDataMapper { diff --git a/ui/fints4kBankingClient/src/main/kotlin/net/dankito/banking/mapper/fints4kModelMapper.kt b/ui/fints4kBankingClient/src/main/kotlin/net/dankito/banking/mapper/fints4kModelMapper.kt index a303167d..2b2caa33 100644 --- a/ui/fints4kBankingClient/src/main/kotlin/net/dankito/banking/mapper/fints4kModelMapper.kt +++ b/ui/fints4kBankingClient/src/main/kotlin/net/dankito/banking/mapper/fints4kModelMapper.kt @@ -1,5 +1,7 @@ package net.dankito.banking.mapper +import net.dankito.banking.extensions.toJavaBigDecimal +import net.dankito.banking.extensions.toJavaUtilDate import net.dankito.banking.ui.model.* import net.dankito.banking.ui.model.responses.AddAccountResponse import net.dankito.banking.ui.model.responses.BankingClientResponse @@ -10,6 +12,7 @@ import net.dankito.banking.fints.model.AccountData import net.dankito.banking.fints.model.AccountFeature import net.dankito.banking.fints.model.BankData import net.dankito.banking.fints.model.CustomerData +import net.dankito.banking.fints.model.Money import net.dankito.banking.fints.response.client.FinTsClientResponse import net.dankito.banking.fints.response.segments.AccountType import net.dankito.utils.exception.ExceptionHelper @@ -27,7 +30,8 @@ open class fints4kModelMapper { } open fun mapResponse(account: Account, response: net.dankito.banking.fints.response.client.AddAccountResponse): AddAccountResponse { - val balances = response.balances.mapKeys { findMatchingBankAccount(account, it.key) }.filter { it.key != null } as Map + val balances = response.balances.mapKeys { findMatchingBankAccount(account, it.key) }.filter { it.key != null } + .mapValues { (it.value as Money).toJavaBigDecimal() } as Map val bookedTransactions = response.bookedTransactions.associateBy { it.account } val mappedBookedTransactions = mutableMapOf>() @@ -52,7 +56,7 @@ open class fints4kModelMapper { return GetTransactionsResponse(bankAccount, response.isSuccessful, mapErrorToShowToUser(response), mapTransactions(bankAccount, response.bookedTransactions), listOf(), // TODO: map unbooked transactions - response.balance, + response.balance?.toJavaBigDecimal(), response.exception, response.userCancelledAction, response.tanRequiredButWeWereToldToAbortIfSo) } @@ -177,19 +181,19 @@ open class fints4kModelMapper { open fun mapTransaction(bankAccount: BankAccount, transaction: net.dankito.banking.fints.model.AccountTransaction): AccountTransaction { return AccountTransaction( bankAccount, - transaction.amount, - transaction.currency, + transaction.amount.toJavaBigDecimal(), + transaction.amount.currency.code, transaction.unparsedUsage, - transaction.bookingDate, + transaction.bookingDate.toJavaUtilDate(), transaction.otherPartyName, transaction.otherPartyBankCode, transaction.otherPartyAccountId, transaction.bookingText, - transaction.valueDate, + transaction.valueDate.toJavaUtilDate(), transaction.statementNumber, transaction.sequenceNumber, - transaction.openingBalance, - transaction.closingBalance, + transaction.openingBalance?.toJavaBigDecimal(), + transaction.closingBalance?.toJavaBigDecimal(), transaction.endToEndReference, transaction.customerReference, diff --git a/ui/hbci4jBankingClient/src/main/kotlin/net/dankito/banking/hbci4jBankingClient.kt b/ui/hbci4jBankingClient/src/main/kotlin/net/dankito/banking/hbci4jBankingClient.kt index 32c3a455..272f017a 100644 --- a/ui/hbci4jBankingClient/src/main/kotlin/net/dankito/banking/hbci4jBankingClient.kt +++ b/ui/hbci4jBankingClient/src/main/kotlin/net/dankito/banking/hbci4jBankingClient.kt @@ -12,7 +12,7 @@ import net.dankito.banking.ui.model.responses.BankingClientResponse import net.dankito.banking.ui.model.responses.GetTransactionsResponse import net.dankito.banking.util.AccountTransactionMapper import net.dankito.banking.util.hbci4jModelMapper -import net.dankito.banking.fints.model.BankInfo +import net.dankito.banking.bankfinder.BankInfo import net.dankito.utils.IThreadPool import net.dankito.utils.ThreadPool import org.kapott.hbci.GV.HBCIJob diff --git a/ui/hbci4jBankingClient/src/main/kotlin/net/dankito/banking/hbci4jBankingClientCreator.kt b/ui/hbci4jBankingClient/src/main/kotlin/net/dankito/banking/hbci4jBankingClientCreator.kt index b371ceae..e977f932 100644 --- a/ui/hbci4jBankingClient/src/main/kotlin/net/dankito/banking/hbci4jBankingClientCreator.kt +++ b/ui/hbci4jBankingClient/src/main/kotlin/net/dankito/banking/hbci4jBankingClientCreator.kt @@ -3,7 +3,7 @@ package net.dankito.banking import net.dankito.banking.ui.BankingClientCallback import net.dankito.banking.ui.IBankingClient import net.dankito.banking.ui.IBankingClientCreator -import net.dankito.banking.fints.model.BankInfo +import net.dankito.banking.bankfinder.BankInfo import net.dankito.utils.IThreadPool import java.io.File