From fdb8545d6b9181e7b8d5d9c285c898e251c55b08 Mon Sep 17 00:00:00 2001 From: dankl Date: Sun, 20 Oct 2019 16:46:53 +0200 Subject: [PATCH] Renamed SupportedJob to JobParameters --- .../main/kotlin/net/dankito/fints/FinTsClient.kt | 8 ++++---- .../kotlin/net/dankito/fints/model/AccountData.kt | 4 ++-- .../kotlin/net/dankito/fints/model/BankData.kt | 4 ++-- .../kotlin/net/dankito/fints/response/Response.kt | 6 +++--- .../net/dankito/fints/response/ResponseParser.kt | 14 +++++++------- .../segments/{SupportedJob.kt => JobParameters.kt} | 2 +- .../net/dankito/fints/response/segments/TanInfo.kt | 8 ++++---- .../dankito/fints/response/ResponseParserTest.kt | 2 +- 8 files changed, 24 insertions(+), 24 deletions(-) rename fints4javaLib/src/main/kotlin/net/dankito/fints/response/segments/{SupportedJob.kt => JobParameters.kt} (92%) diff --git a/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt b/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt index c379bc4f..6db79f05 100644 --- a/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt +++ b/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt @@ -591,8 +591,8 @@ open class FinTsClient @JvmOverloads constructor( return bank.supportedTanProcedures.firstOrNull { it.securityFunction == securityFunction } } - protected open fun setAllowedJobsForAccount(account: AccountData, supportedJobs: List) { - val allowedJobsForAccount = mutableListOf() + protected open fun setAllowedJobsForAccount(account: AccountData, supportedJobs: List) { + val allowedJobsForAccount = mutableListOf() for (job in supportedJobs) { if (isJobSupported(account, job)) { @@ -643,9 +643,9 @@ open class FinTsClient @JvmOverloads constructor( } } - protected open fun isJobSupported(account: AccountData, job: SupportedJob): Boolean { + protected open fun isJobSupported(account: AccountData, supportedJob: JobParameters): Boolean { for (allowedJobName in account.allowedJobNames) { - if (allowedJobName == job.jobName) { + if (allowedJobName == supportedJob.jobName) { return true } } diff --git a/fints4javaLib/src/main/kotlin/net/dankito/fints/model/AccountData.kt b/fints4javaLib/src/main/kotlin/net/dankito/fints/model/AccountData.kt index 10967dae..29e037f2 100644 --- a/fints4javaLib/src/main/kotlin/net/dankito/fints/model/AccountData.kt +++ b/fints4javaLib/src/main/kotlin/net/dankito/fints/model/AccountData.kt @@ -1,7 +1,7 @@ package net.dankito.fints.model import net.dankito.fints.response.segments.AccountType -import net.dankito.fints.response.segments.SupportedJob +import net.dankito.fints.response.segments.JobParameters open class AccountData( @@ -17,7 +17,7 @@ open class AccountData( val productName: String?, val accountLimit: String?, val allowedJobNames: List, - var allowedJobs: List = listOf() + var allowedJobs: List = listOf() ) { override fun toString(): String { diff --git a/fints4javaLib/src/main/kotlin/net/dankito/fints/model/BankData.kt b/fints4javaLib/src/main/kotlin/net/dankito/fints/model/BankData.kt index ebc7b3b9..a1d393fc 100644 --- a/fints4javaLib/src/main/kotlin/net/dankito/fints/model/BankData.kt +++ b/fints4javaLib/src/main/kotlin/net/dankito/fints/model/BankData.kt @@ -3,7 +3,7 @@ package net.dankito.fints.model import net.dankito.fints.messages.datenelemente.implementierte.BPDVersion import net.dankito.fints.messages.datenelemente.implementierte.Dialogsprache import net.dankito.fints.messages.datenelemente.implementierte.HbciVersion -import net.dankito.fints.response.segments.SupportedJob +import net.dankito.fints.response.segments.JobParameters open class BankData( @@ -23,7 +23,7 @@ open class BankData( var supportedHbciVersions: List = listOf(), var supportedTanProcedures: List = listOf(), var supportedLanguages: List = listOf(), - var supportedJobs: List = listOf() + var supportedJobs: List = listOf() ) { diff --git a/fints4javaLib/src/main/kotlin/net/dankito/fints/response/Response.kt b/fints4javaLib/src/main/kotlin/net/dankito/fints/response/Response.kt index 40db16bb..70baf3fd 100644 --- a/fints4javaLib/src/main/kotlin/net/dankito/fints/response/Response.kt +++ b/fints4javaLib/src/main/kotlin/net/dankito/fints/response/Response.kt @@ -67,13 +67,13 @@ open class Response constructor( /** - * Returns an empty list of response didn't contain any allowed jobs. + * Returns an empty list of response didn't contain any job parameters. * * Returns all jobs bank supports otherwise. This does not necessarily mean that they are also allowed for * customer / account, see [net.dankito.fints.model.AccountData.allowedJobNames]. */ - open val supportedJobs: List - get() = receivedSegments.mapNotNull { it as? SupportedJob } + open val supportedJobs: List + get() = receivedSegments.mapNotNull { it as? JobParameters } open val supportedTanProceduresForUser: List get() = segmentFeedbacks.flatMap { it.feedbacks } diff --git a/fints4javaLib/src/main/kotlin/net/dankito/fints/response/ResponseParser.kt b/fints4javaLib/src/main/kotlin/net/dankito/fints/response/ResponseParser.kt index 8fedd2c6..f428b435 100644 --- a/fints4javaLib/src/main/kotlin/net/dankito/fints/response/ResponseParser.kt +++ b/fints4javaLib/src/main/kotlin/net/dankito/fints/response/ResponseParser.kt @@ -32,7 +32,7 @@ open class ResponseParser @JvmOverloads constructor( val EncryptionDataSegmentHeaderPattern = Pattern.compile("${MessageSegmentId.EncryptionData.id}:\\d{1,3}:\\d{1,3}\\+") - val AllowedJobSegmentPattern = Pattern.compile("HI[A-Z]{3}S") + val JobParametersSegmentPattern = Pattern.compile("HI[A-Z]{3}S") val FeedbackParametersSeparator = "; " @@ -96,8 +96,8 @@ open class ResponseParser @JvmOverloads constructor( InstituteSegmentId.AccountTransactionsMt940.id -> parseMt940AccountTransactions(segment, dataElementGroups) else -> { - if (AllowedJobSegmentPattern.matcher(segmentId).matches()) { - return parseAllowedJob(segment, segmentId, dataElementGroups) + if (JobParametersSegmentPattern.matcher(segmentId).matches()) { + return parseJobParameters(segment, segmentId, dataElementGroups) } UnparsedSegment(segment) @@ -267,7 +267,7 @@ open class ResponseParser @JvmOverloads constructor( } - protected open fun parseAllowedJob(segment: String, segmentId: String, dataElementGroups: List): SupportedJob { + protected open fun parseJobParameters(segment: String, segmentId: String, dataElementGroups: List): JobParameters { var jobName = segmentId.substring(0, 5) // cut off last 'S' (which stands for 'parameter') jobName = jobName.replaceFirst("HI", "HK") @@ -277,14 +277,14 @@ open class ResponseParser @JvmOverloads constructor( // Bei aelteren Version fehlt das Datenelement 'Sicherheitsklasse'. Ist fuer PIN/TAN eh zu ignorieren val securityClass = if (dataElementGroups.size > 3) parseNullableInt(dataElementGroups[3]) else null - return SupportedJob(jobName, maxCountJobs, minimumCountSignatures, securityClass, segment) + return JobParameters(jobName, maxCountJobs, minimumCountSignatures, securityClass, segment) } protected open fun parseTanInfo(segment: String, segmentId: String, dataElementGroups: List): TanInfo { - val allowedJob = parseAllowedJob(segment, segmentId, dataElementGroups) + val jobParameters = parseJobParameters(segment, segmentId, dataElementGroups) - return TanInfo(allowedJob, parseTwoStepTanProcedureParameters(dataElementGroups[4])) + return TanInfo(jobParameters, parseTwoStepTanProcedureParameters(dataElementGroups[4])) } protected open fun parseTwoStepTanProcedureParameters(tanProcedures: String): TwoStepTanProcedureParameters { diff --git a/fints4javaLib/src/main/kotlin/net/dankito/fints/response/segments/SupportedJob.kt b/fints4javaLib/src/main/kotlin/net/dankito/fints/response/segments/JobParameters.kt similarity index 92% rename from fints4javaLib/src/main/kotlin/net/dankito/fints/response/segments/SupportedJob.kt rename to fints4javaLib/src/main/kotlin/net/dankito/fints/response/segments/JobParameters.kt index 0f45d7d1..857be2c5 100644 --- a/fints4javaLib/src/main/kotlin/net/dankito/fints/response/segments/SupportedJob.kt +++ b/fints4javaLib/src/main/kotlin/net/dankito/fints/response/segments/JobParameters.kt @@ -1,7 +1,7 @@ package net.dankito.fints.response.segments -open class SupportedJob( +open class JobParameters( val jobName: String, val maxCountJobs: Int, val minimumCountSignatures: Int, diff --git a/fints4javaLib/src/main/kotlin/net/dankito/fints/response/segments/TanInfo.kt b/fints4javaLib/src/main/kotlin/net/dankito/fints/response/segments/TanInfo.kt index 35e2fae5..446c8260 100644 --- a/fints4javaLib/src/main/kotlin/net/dankito/fints/response/segments/TanInfo.kt +++ b/fints4javaLib/src/main/kotlin/net/dankito/fints/response/segments/TanInfo.kt @@ -10,10 +10,10 @@ open class TanInfo( segmentString: String ) - : SupportedJob(jobName, maxCountJobs, minimumCountSignatures, securityClass, segmentString) { + : JobParameters(jobName, maxCountJobs, minimumCountSignatures, securityClass, segmentString) { - constructor(supportedJob: SupportedJob, tanProcedureParameters: TwoStepTanProcedureParameters) - : this(supportedJob.jobName, supportedJob.maxCountJobs, supportedJob.minimumCountSignatures, - supportedJob.securityClass, tanProcedureParameters, supportedJob.segmentString) + constructor(parameters: JobParameters, tanProcedureParameters: TwoStepTanProcedureParameters) + : this(parameters.jobName, parameters.maxCountJobs, parameters.minimumCountSignatures, + parameters.securityClass, tanProcedureParameters, parameters.segmentString) } \ No newline at end of file diff --git a/fints4javaLib/src/test/kotlin/net/dankito/fints/response/ResponseParserTest.kt b/fints4javaLib/src/test/kotlin/net/dankito/fints/response/ResponseParserTest.kt index db7d749f..483ba75a 100644 --- a/fints4javaLib/src/test/kotlin/net/dankito/fints/response/ResponseParserTest.kt +++ b/fints4javaLib/src/test/kotlin/net/dankito/fints/response/ResponseParserTest.kt @@ -552,7 +552,7 @@ class ResponseParserTest : FinTsTestBase() { assertThat(result.receivedSegments).hasSize(92) for (segment in result.receivedSegments) { - assertThat(segment is SupportedJob).describedAs("$segment should be of type AllowedJob").isTrue() + assertThat(segment is JobParameters).describedAs("$segment should be of type JobParameters").isTrue() } }