Replaced atrium asserts with Kotlin test asserts

This commit is contained in:
dankito 2022-02-13 00:17:45 +01:00
parent 55881b5e79
commit 56f951314a
28 changed files with 588 additions and 566 deletions

View File

@ -11,11 +11,8 @@ ext {
/* Test */ /* Test */
junitVersion = '4.12'
junit5Version = '5.5.2' junit5Version = '5.5.2'
atriumVersion = "0.15.0"
assertJVersion = '3.12.2' assertJVersion = '3.12.2'
mockitoVersion = '2.22.0' mockitoVersion = '2.22.0'

View File

@ -56,8 +56,6 @@ kotlin {
commonTest { commonTest {
dependencies { dependencies {
implementation kotlin("test") implementation kotlin("test")
implementation "ch.tutteli.atrium:atrium-fluent-en_GB-common:$atriumVersion"
} }
} }
@ -76,8 +74,6 @@ kotlin {
implementation "org.assertj:assertj-core:$assertJVersion" implementation "org.assertj:assertj-core:$assertJVersion"
implementation "org.mockito:mockito-core:$mockitoVersion" implementation "org.mockito:mockito-core:$mockitoVersion"
implementation "ch.tutteli.atrium:atrium-fluent-en_GB:$atriumVersion"
// implementation project(":BankingUiCommon") // implementation project(":BankingUiCommon")
// implementation project(":BankFinder") // implementation project(":BankFinder")

View File

@ -0,0 +1,73 @@
package net.dankito.banking.fints.extensions
import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.contract
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
import kotlin.test.assertTrue
import kotlin.test.fail
fun assertEquals(expected: Any?, actual: Any?) {
assertEquals(expected, actual, "'$actual' should equal expected '$expected'")
}
fun assertFalse(actual: Boolean) {
kotlin.test.assertFalse(actual, "Value should be false but isn't")
}
fun assertTrue(actual: Boolean) {
assertTrue(actual, "Value should be true but isn't")
}
@OptIn(ExperimentalContracts::class)
fun assertNotNull(actual: Any?) {
contract { returns() implies (actual != null) }
assertNotNull(actual, "Value should not be null but is")
}
fun assertNull(actual: Any?) {
kotlin.test.assertNull(actual, "'$actual' is expected to be null")
}
fun assertEmpty(string: String) {
assertTrue(string.isEmpty())
}
fun assertContains(string: String, vararg args: String) {
args.forEach { arg ->
kotlin.test.assertContains(string, arg)
}
}
fun assertSize(size: Int, collection: Collection<*>) {
assertEquals(size, collection.size, "Collection should have size $size, but has ${collection.size} elements")
}
fun assertEmpty(collection: Collection<*>) {
assertTrue(collection.isEmpty())
}
fun <T : Any?> assertContainsExactly(collection: Collection<T>, vararg items: T) {
assertEquals(collection.size, items.size, "Size of collection is ${collection.size}, but that of expected arguments is ${items.size}")
assertContains(collection, *items)
}
fun <T : Any?> assertContains(collection: Collection<T>, vararg items: T) {
items.forEach { item ->
kotlin.test.assertContains(collection, item)
}
}
inline fun <reified T : Throwable> assertThrows(action: () -> Unit) {
try {
action()
fail("action() didn't throw any exception. Expected was ${T::class.qualifiedName}")
} catch (throwable: Throwable) {
println("Throwable is of type ${throwable::class.simpleName}: $throwable")
assertTrue(throwable is T)
}
}

View File

@ -1,9 +0,0 @@
package net.dankito.banking.fints.extensions
import ch.tutteli.atrium.creating.Expect
import ch.tutteli.atrium.domain.builders.ExpectImpl
fun <T : Boolean> Expect<T>.isTrue(): Expect<T> = addAssertion(ExpectImpl.any.toBe(this, true))
fun <T : Boolean> Expect<T>.isFalse(): Expect<T> = addAssertion(ExpectImpl.any.toBe(this, false))

View File

@ -1,8 +1,5 @@
package net.dankito.banking.fints.messages 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 kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDate
import kotlinx.datetime.LocalDateTime import kotlinx.datetime.LocalDateTime
import kotlinx.datetime.Month import kotlinx.datetime.Month
@ -15,9 +12,7 @@ import net.dankito.banking.fints.response.segments.JobParameters
import net.dankito.banking.fints.response.segments.PinInfo import net.dankito.banking.fints.response.segments.PinInfo
import net.dankito.banking.fints.response.segments.RetrieveAccountTransactionsParameters import net.dankito.banking.fints.response.segments.RetrieveAccountTransactionsParameters
import net.dankito.banking.fints.util.FinTsUtils import net.dankito.banking.fints.util.FinTsUtils
import kotlin.test.AfterTest import kotlin.test.*
import kotlin.test.Ignore
import kotlin.test.Test
class MessageBuilderTest : FinTsTestBase() { class MessageBuilderTest : FinTsTestBase() {
@ -55,7 +50,7 @@ class MessageBuilderTest : FinTsTestBase() {
val result = underTest.createAnonymousDialogInitMessage(context).createdMessage val result = underTest.createAnonymousDialogInitMessage(context).createdMessage
// then // then
expect(result).toBe( assertEquals(result,
"HNHBK:1:3+000000000125+300+0+1'" + "HNHBK:1:3+000000000125+300+0+1'" +
"HKIDN:2:2+280:12345678+${CustomerId}+0+0'" + "HKIDN:2:2+280:12345678+${CustomerId}+0+0'" +
"HKVVB:3:3+0+0+${Language.code}+$ProductName+$ProductVersion'" + "HKVVB:3:3+0+0+${Language.code}+$ProductName+$ProductVersion'" +
@ -74,7 +69,7 @@ class MessageBuilderTest : FinTsTestBase() {
val result = underTest.createAnonymousDialogEndMessage(context).createdMessage ?: "" val result = underTest.createAnonymousDialogEndMessage(context).createdMessage ?: ""
// then // then
expect(normalizeBinaryData(result)).toBe(normalizeBinaryData( assertEquals(normalizeBinaryData(result), normalizeBinaryData(
"HNHBK:1:3+000000000067+300+$dialogId+1'" + "HNHBK:1:3+000000000067+300+$dialogId+1'" +
"HKEND:2:1+$dialogId'" + "HKEND:2:1+$dialogId'" +
"HNHBS:3:1+1'" "HNHBS:3:1+1'"
@ -92,7 +87,7 @@ class MessageBuilderTest : FinTsTestBase() {
val result = underTest.createSynchronizeCustomerSystemIdMessage(context).createdMessage ?: "" val result = underTest.createSynchronizeCustomerSystemIdMessage(context).createdMessage ?: ""
// then // then
expect(normalizeBinaryData(result)).toBe(normalizeBinaryData( assertEquals(normalizeBinaryData(result), normalizeBinaryData(
"HNHBK:1:3+000000000397+300+0+1'" + "HNHBK:1:3+000000000397+300+0+1'" +
"HNVSK:998:3+PIN:2+998+1+1::0+1:$Date:$Time+2:2:13:@8@ :5:1+280:$BankCode:$CustomerId:V:0:0+0'" + "HNVSK:998:3+PIN:2+998+1+1::0+1:$Date:$Time+2:2:13:@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'" + "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'" +
@ -116,7 +111,7 @@ class MessageBuilderTest : FinTsTestBase() {
val result = underTest.createDialogEndMessage(context).createdMessage ?: "" val result = underTest.createDialogEndMessage(context).createdMessage ?: ""
// then // then
expect(normalizeBinaryData(result)).toBe(normalizeBinaryData( assertEquals(normalizeBinaryData(result), normalizeBinaryData(
"HNHBK:1:3+000000000309+300+$dialogId+1'" + "HNHBK:1:3+000000000309+300+$dialogId+1'" +
"HNVSK:998:3+PIN:2+998+1+1::0+1:$Date:$Time+2:2:13:@8@ :5:1+280:$BankCode:$CustomerId:V:0:0+0'" + "HNVSK:998:3+PIN:2+998+1+1::0+1:$Date:$Time+2:2:13:@8@ :5:1+280:$BankCode:$CustomerId:V:0:0+0'" +
"HNVSD:999:1+@140@" + "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'" + "HNVSD:999:1+@140@" + "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'" +
@ -137,7 +132,7 @@ class MessageBuilderTest : FinTsTestBase() {
val result = underTest.createGetTransactionsMessage(context, GetAccountTransactionsParameter(Bank, Account)) val result = underTest.createGetTransactionsMessage(context, GetAccountTransactionsParameter(Bank, Account))
// then // then
expect(result.isJobAllowed).toBe(false) assertFalse(result.isJobAllowed)
} }
@Test @Test
@ -156,8 +151,8 @@ class MessageBuilderTest : FinTsTestBase() {
val result = underTest.createGetTransactionsMessage(context, GetAccountTransactionsParameter(Bank, account)) val result = underTest.createGetTransactionsMessage(context, GetAccountTransactionsParameter(Bank, account))
// then // then
expect(result.isJobAllowed).toBe(true) assertTrue(result.isJobAllowed)
expect(result.isJobVersionSupported).toBe(false) assertFalse(result.isJobVersionSupported)
} }
@Test @Test
@ -180,9 +175,9 @@ class MessageBuilderTest : FinTsTestBase() {
val result = underTest.createGetTransactionsMessage(context, GetAccountTransactionsParameter(Bank, account, false, fromDate, toDate, maxCountEntries)) val result = underTest.createGetTransactionsMessage(context, GetAccountTransactionsParameter(Bank, account, false, fromDate, toDate, maxCountEntries))
// then // then
expect(result.createdMessage).notToBeNull() assertNotNull(result.createdMessage)
expect(normalizeBinaryData(result.createdMessage!!)).toBe(normalizeBinaryData( assertEquals(normalizeBinaryData(result.createdMessage!!), normalizeBinaryData(
"HNHBK:1:3+000000000361+300+0+1'" + "HNHBK:1:3+000000000361+300+0+1'" +
"HNVSK:998:3+PIN:2+998+1+1::0+1:$Date:$Time+2:2:13:@8@ :5:1+280:$BankCode:$CustomerId:V:0:0+0'" + "HNVSK:998:3+PIN:2+998+1+1::0+1:$Date:$Time+2:2:13:@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'" + "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'" +
@ -216,9 +211,9 @@ class MessageBuilderTest : FinTsTestBase() {
GetAccountTransactionsParameter(Bank, account, false, fromDate, toDate, maxCountEntries, false)) GetAccountTransactionsParameter(Bank, account, false, fromDate, toDate, maxCountEntries, false))
// then // then
expect(result.createdMessage).notToBeNull() assertNotNull(result.createdMessage)
expect(normalizeBinaryData(result.createdMessage!!)).toBe(normalizeBinaryData( assertEquals(normalizeBinaryData(result.createdMessage!!), normalizeBinaryData(
"HNHBK:1:3+000000000340+300+0+1'" + "HNHBK:1:3+000000000340+300+0+1'" +
"HNVSK:998:3+PIN:2+998+1+1::0+1:$Date:$Time+2:2:13:@8@ :5:1+280:$BankCode:$CustomerId:V:0:0+0'" + "HNVSK:998:3+PIN:2+998+1+1::0+1:$Date:$Time+2:2:13:@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'" + "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'" +

View File

@ -1,11 +1,10 @@
package net.dankito.banking.fints.messages.datenelemente.basisformate package net.dankito.banking.fints.messages.datenelemente.basisformate
import ch.tutteli.atrium.api.fluent.en_GB.toBe import net.dankito.banking.fints.extensions.assertThrows
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.Existenzstatus
import net.dankito.banking.fints.messages.datenelementgruppen.implementierte.signatur.SicherheitsidentifikationDetails import net.dankito.banking.fints.messages.datenelementgruppen.implementierte.signatur.SicherheitsidentifikationDetails
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals
class TextDatenelementTest { class TextDatenelementTest {
@ -30,9 +29,9 @@ class TextDatenelementTest {
val underTest = createTextDatenelement("α") val underTest = createTextDatenelement("α")
// when // when
expect { assertThrows<IllegalArgumentException> {
underTest.validate() underTest.validate()
}.toThrow<IllegalArgumentException>() }
} }
@Test @Test
@ -42,9 +41,9 @@ class TextDatenelementTest {
val underTest = createTextDatenelement("Я") val underTest = createTextDatenelement("Я")
// when // when
expect { assertThrows<IllegalArgumentException> {
underTest.validate() underTest.validate()
}.toThrow<IllegalArgumentException>() }
} }
@Test @Test
@ -54,9 +53,9 @@ class TextDatenelementTest {
val underTest = createTextDatenelement("") // is only allowed by ISO-8859-15, not by ISO-8859-1 val underTest = createTextDatenelement("") // is only allowed by ISO-8859-15, not by ISO-8859-1
// when // when
expect { assertThrows<IllegalArgumentException> {
underTest.validate() underTest.validate()
}.toThrow<IllegalArgumentException>() }
} }
@ -75,7 +74,7 @@ class TextDatenelementTest {
// then // then
expect(result).toBe(expected) assertEquals(expected, result)
} }
@Test @Test
@ -93,7 +92,7 @@ class TextDatenelementTest {
// then // then
expect(result).toBe(expected) assertEquals(expected, result)
} }
@Test @Test
@ -111,7 +110,7 @@ class TextDatenelementTest {
// then // then
expect(result).toBe(expected) assertEquals(expected, result)
} }
@Test @Test
@ -130,7 +129,7 @@ class TextDatenelementTest {
// then // then
expect(result).toBe(expected) assertEquals(expected, result)
} }

View File

@ -1,10 +1,9 @@
package net.dankito.banking.fints.messages.datenelemente.basisformate package net.dankito.banking.fints.messages.datenelemente.basisformate
import ch.tutteli.atrium.api.fluent.en_GB.toBe import net.dankito.banking.fints.extensions.assertThrows
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.Existenzstatus
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals
class ZiffernDatenelementTest { class ZiffernDatenelementTest {
@ -19,7 +18,7 @@ class ZiffernDatenelementTest {
val result = underTest.format() val result = underTest.format()
// then // then
expect(result).toBe("000001") assertEquals("000001", result)
} }
@ -56,9 +55,9 @@ class ZiffernDatenelementTest {
val underTest = createZiffernDatenelement(-1, 3) val underTest = createZiffernDatenelement(-1, 3)
// when // when
expect { assertThrows<IllegalArgumentException> {
underTest.validate() underTest.validate()
}.toThrow<IllegalArgumentException>() }
} }
@Test @Test
@ -68,9 +67,9 @@ class ZiffernDatenelementTest {
val underTest = createZiffernDatenelement(1000, 3) val underTest = createZiffernDatenelement(1000, 3)
// when // when
expect { assertThrows<IllegalArgumentException> {
underTest.validate() underTest.validate()
}.toThrow<IllegalArgumentException>() }
} }

View File

@ -1,10 +1,9 @@
package net.dankito.banking.fints.messages.datenelemente.implementierte package net.dankito.banking.fints.messages.datenelemente.implementierte
import ch.tutteli.atrium.api.fluent.en_GB.toBe import net.dankito.banking.fints.extensions.assertThrows
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.Existenzstatus
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals
class BPDVersionTest { class BPDVersionTest {
@ -19,7 +18,7 @@ class BPDVersionTest {
val result = underTest.format() val result = underTest.format()
// then // then
expect(result).toBe("3") assertEquals("3", result)
} }
@ -56,9 +55,9 @@ class BPDVersionTest {
val underTest = BPDVersion(-1, Existenzstatus.Mandatory) val underTest = BPDVersion(-1, Existenzstatus.Mandatory)
// when // when
expect { assertThrows<IllegalArgumentException> {
underTest.validate() underTest.validate()
}.toThrow<IllegalArgumentException>() }
} }
@Test @Test
@ -68,9 +67,9 @@ class BPDVersionTest {
val underTest = BPDVersion(1000, Existenzstatus.Mandatory) val underTest = BPDVersion(1000, Existenzstatus.Mandatory)
// when // when
expect { assertThrows<IllegalArgumentException> {
underTest.validate() underTest.validate()
}.toThrow<IllegalArgumentException>() }
} }
} }

View File

@ -1,7 +1,6 @@
package net.dankito.banking.fints.messages.datenelemente.implementierte package net.dankito.banking.fints.messages.datenelemente.implementierte
import ch.tutteli.atrium.api.fluent.en_GB.toThrow import net.dankito.banking.fints.extensions.assertThrows
import ch.tutteli.atrium.api.verbs.expect
import net.dankito.banking.fints.messages.Existenzstatus import net.dankito.banking.fints.messages.Existenzstatus
import kotlin.test.Test import kotlin.test.Test
@ -28,9 +27,9 @@ class ProduktbezeichnungTest {
val underTest = Produktbezeichnung("12345678901234567890123456", Existenzstatus.Mandatory) val underTest = Produktbezeichnung("12345678901234567890123456", Existenzstatus.Mandatory)
// when // when
expect { assertThrows<IllegalArgumentException> {
underTest.validate() underTest.validate()
}.toThrow<IllegalArgumentException>() }
} }
} }

View File

@ -1,11 +1,10 @@
package net.dankito.banking.fints.messages.datenelementgruppen package net.dankito.banking.fints.messages.datenelementgruppen
import ch.tutteli.atrium.api.fluent.en_GB.isEmpty import net.dankito.banking.fints.extensions.assertEmpty
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.Separators
import net.dankito.banking.fints.messages.datenelementgruppen.implementierte.signatur.BenutzerdefinierteSignatur import net.dankito.banking.fints.messages.datenelementgruppen.implementierte.signatur.BenutzerdefinierteSignatur
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals
class DatenelementgruppeTest { class DatenelementgruppeTest {
@ -22,7 +21,7 @@ class DatenelementgruppeTest {
val result = dataElementGroup.format() val result = dataElementGroup.format()
// then // then
expect(result).toBe(pin + Separators.DataElementsSeparator + tan) // ":" does not get written to output assertEquals(pin + Separators.DataElementsSeparator + tan, result) // ":" does not get written to output
} }
@Test @Test
@ -37,7 +36,7 @@ class DatenelementgruppeTest {
val result = dataElementGroup.format() val result = dataElementGroup.format()
// then // then
expect(result).toBe(pin) // ":" does not get written to output assertEquals(pin, result) // ":" does not get written to output
} }
@Test @Test
@ -52,7 +51,7 @@ class DatenelementgruppeTest {
val result = dataElementGroup.format() val result = dataElementGroup.format()
// then // then
expect(result).isEmpty() // ":" does not get written to output assertEmpty(result) // ":" does not get written to output
} }
} }

View File

@ -1,11 +1,10 @@
package net.dankito.banking.fints.messages.segmente 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.Existenzstatus
import net.dankito.banking.fints.messages.datenelemente.DatenelementBase import net.dankito.banking.fints.messages.datenelemente.DatenelementBase
import net.dankito.banking.fints.messages.datenelemente.basisformate.TextDatenelement import net.dankito.banking.fints.messages.datenelemente.basisformate.TextDatenelement
import ch.tutteli.atrium.api.verbs.expect
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals
class SegmentTest { class SegmentTest {
@ -32,7 +31,7 @@ class SegmentTest {
// then // then
// assert that empty data elements at end get cut but that the empty ones in the middle remain // assert that empty data elements at end get cut but that the empty ones in the middle remain
expect(result).toBe("DE1+DE2++++DE6++DE8") assertEquals("DE1+DE2++++DE6++DE8", result)
} }

View File

@ -1,10 +1,8 @@
package net.dankito.banking.fints.messages.segmente.implementierte 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.FinTsTestBase
import net.dankito.banking.fints.model.MessageBaseData
import ch.tutteli.atrium.api.verbs.expect
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals
class IdentifikationsSegmentTest : FinTsTestBase() { class IdentifikationsSegmentTest : FinTsTestBase() {
@ -19,7 +17,7 @@ class IdentifikationsSegmentTest : FinTsTestBase() {
val result = underTest.format() val result = underTest.format()
// then // then
expect(result).toBe("HKIDN:2:2+280:12345678+0987654321+0+0") assertEquals(result, "HKIDN:2:2+280:12345678+0987654321+0+0")
} }
} }

View File

@ -1,8 +1,7 @@
package net.dankito.banking.fints.messages.segmente.implementierte package net.dankito.banking.fints.messages.segmente.implementierte
import ch.tutteli.atrium.api.fluent.en_GB.toBe
import ch.tutteli.atrium.api.verbs.expect
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals
class SignaturabschlussTest { class SignaturabschlussTest {
@ -20,7 +19,7 @@ class SignaturabschlussTest {
val result = underTest.format() val result = underTest.format()
// then // then
expect(result).toBe("HNSHA:$segmentNumber:2+$controlReference++$pin") assertEquals(result, "HNSHA:$segmentNumber:2+$controlReference++$pin")
} }
} }

View File

@ -1,10 +1,9 @@
package net.dankito.banking.fints.messages.segmente.implementierte 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.FinTsTestBase
import net.dankito.banking.fints.model.MessageBaseData import net.dankito.banking.fints.model.MessageBaseData
import ch.tutteli.atrium.api.verbs.expect
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals
class SignaturkopfTest : FinTsTestBase() { class SignaturkopfTest : FinTsTestBase() {
@ -22,7 +21,7 @@ class SignaturkopfTest : FinTsTestBase() {
val result = underTest.format() val result = underTest.format()
// then // then
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") assertEquals(result, "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")
} }
} }

View File

@ -1,10 +1,9 @@
package net.dankito.banking.fints.messages.segmente.implementierte 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.FinTsTestBase
import net.dankito.banking.fints.model.MessageBaseData import net.dankito.banking.fints.model.MessageBaseData
import ch.tutteli.atrium.api.verbs.expect
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals
class VerschluesselungskopfTest : FinTsTestBase() { class VerschluesselungskopfTest : FinTsTestBase() {
@ -20,7 +19,7 @@ class VerschluesselungskopfTest : FinTsTestBase() {
val result = underTest.format() val result = underTest.format()
// then // then
expect(normalizeBinaryData(result)).toBe("HNVSK:998:3+PIN:2+998+1+1::0+1:$Date:$Time+2:2:13:@8@ :5:1+280:$BankCode:$CustomerId:V:0:0+0") assertEquals(normalizeBinaryData(result), "HNVSK:998:3+PIN:2+998+1+1::0+1:$Date:$Time+2:2:13:@8@ :5:1+280:$BankCode:$CustomerId:V:0:0+0")
} }
} }

View File

@ -1,7 +1,6 @@
package net.dankito.banking.fints.messages.segmente.implementierte.sepa package net.dankito.banking.fints.messages.segmente.implementierte.sepa
import ch.tutteli.atrium.api.fluent.en_GB.contains import net.dankito.banking.fints.extensions.assertContains
import ch.tutteli.atrium.api.verbs.expect
import net.dankito.banking.fints.messages.segmente.id.CustomerSegmentId import net.dankito.banking.fints.messages.segmente.id.CustomerSegmentId
import net.dankito.banking.fints.model.* import net.dankito.banking.fints.model.*
import kotlin.test.Test import kotlin.test.Test
@ -42,7 +41,7 @@ class SepaBankTransferBaseTest {
// then // then
expect(result).contains(debitorName, debitorIban, debitorBic, recipientName, recipientIban, recipientBic, assertContains(result, debitorName, debitorIban, debitorBic, recipientName, recipientIban, recipientBic,
amount.toString().replace(',', '.'), reference, "urn?:iso?:std?:iso?:20022?:tech?:xsd?:pain.001.001.03") amount.toString().replace(',', '.'), reference, "urn?:iso?:std?:iso?:20022?:tech?:xsd?:pain.001.001.03")
} }
@ -64,7 +63,7 @@ class SepaBankTransferBaseTest {
// then // then
expect(result).contains(debitorName, debitorIban, debitorBic, recipientName, recipientIban, recipientBic, assertContains(result, debitorName, debitorIban, debitorBic, recipientName, recipientIban, recipientBic,
amount.toString().replace(',', '.'), reference, "urn?:iso?:std?:iso?:20022?:tech?:xsd?:pain.001.003.03") amount.toString().replace(',', '.'), reference, "urn?:iso?:std?:iso?:20022?:tech?:xsd?:pain.001.003.03")
} }

View File

@ -1,9 +1,8 @@
package net.dankito.banking.fints.messages.segmente.implementierte.sepa package net.dankito.banking.fints.messages.segmente.implementierte.sepa
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 import kotlin.test.Test
import kotlin.test.assertFalse
import kotlin.test.assertTrue
class SepaMessageCreatorTest { class SepaMessageCreatorTest {
@ -18,7 +17,7 @@ class SepaMessageCreatorTest {
val result = underTest.containsOnlyAllowedCharacters("Marieke Musterfrau") val result = underTest.containsOnlyAllowedCharacters("Marieke Musterfrau")
// then // then
expect(result).isTrue() assertTrue(result)
} }
@Test @Test
@ -28,7 +27,7 @@ class SepaMessageCreatorTest {
val result = underTest.containsOnlyAllowedCharacters("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789,.?+-/()") val result = underTest.containsOnlyAllowedCharacters("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789,.?+-/()")
// then // then
expect(result).isTrue() assertTrue(result)
} }
@Test @Test
@ -38,7 +37,7 @@ class SepaMessageCreatorTest {
val result = underTest.containsOnlyAllowedCharacters(":") val result = underTest.containsOnlyAllowedCharacters(":")
// then // then
expect(result).isTrue() assertTrue(result)
} }
@Test @Test
@ -48,7 +47,7 @@ class SepaMessageCreatorTest {
val result = underTest.containsOnlyAllowedCharacters("!") val result = underTest.containsOnlyAllowedCharacters("!")
// then // then
expect(result).isFalse() assertFalse(result)
} }
@Test @Test
@ -58,17 +57,17 @@ class SepaMessageCreatorTest {
val result = underTest.containsOnlyAllowedCharacters("") val result = underTest.containsOnlyAllowedCharacters("")
// then // then
expect(result).isFalse() assertFalse(result)
} }
@Test @Test
fun `containsOnlyAllowedCharacters @ is an illegal character`() { fun `containsOnlyAllowedCharacters at sign is an illegal character`() {
// when // when
val result = underTest.containsOnlyAllowedCharacters("@") val result = underTest.containsOnlyAllowedCharacters("@")
// then // then
expect(result).isFalse() assertFalse(result)
} }
@Test @Test
@ -78,7 +77,7 @@ class SepaMessageCreatorTest {
val result = underTest.containsOnlyAllowedCharacters("ö") val result = underTest.containsOnlyAllowedCharacters("ö")
// then // then
expect(result).isFalse() assertFalse(result)
} }
} }

View File

@ -1,13 +1,12 @@
package net.dankito.banking.fints.messages.segmente.implementierte.tan 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.FinTsTestBase
import net.dankito.banking.fints.messages.datenelemente.implementierte.tan.TanGeneratorTanMedium 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.TanMediumKlasse
import net.dankito.banking.fints.messages.datenelemente.implementierte.tan.TanMediumStatus import net.dankito.banking.fints.messages.datenelemente.implementierte.tan.TanMediumStatus
import net.dankito.banking.fints.response.segments.ChangeTanMediaParameters import net.dankito.banking.fints.response.segments.ChangeTanMediaParameters
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals
class TanGeneratorTanMediumAnOderUmmeldenTest: FinTsTestBase() { class TanGeneratorTanMediumAnOderUmmeldenTest: FinTsTestBase() {
@ -50,7 +49,7 @@ class TanGeneratorTanMediumAnOderUmmeldenTest: FinTsTestBase() {
// then // then
expect(result).toBe("HKTAU:$SegmentNumber:1+G+$CardNumber") assertEquals(result, "HKTAU:$SegmentNumber:1+G+$CardNumber")
} }
@Test @Test
@ -67,7 +66,7 @@ class TanGeneratorTanMediumAnOderUmmeldenTest: FinTsTestBase() {
// then // then
expect(result).toBe("HKTAU:$SegmentNumber:1+G+$CardNumber+++$ATC+$TAN") assertEquals(result, "HKTAU:$SegmentNumber:1+G+$CardNumber+++$ATC+$TAN")
} }
@Test @Test
@ -84,7 +83,7 @@ class TanGeneratorTanMediumAnOderUmmeldenTest: FinTsTestBase() {
// then // then
expect(result).toBe("HKTAU:$SegmentNumber:1+G+$CardNumber+$CardSequenceNumber") assertEquals(result, "HKTAU:$SegmentNumber:1+G+$CardNumber+$CardSequenceNumber")
} }
@Test @Test
@ -101,7 +100,7 @@ class TanGeneratorTanMediumAnOderUmmeldenTest: FinTsTestBase() {
// then // then
expect(result).toBe("HKTAU:$SegmentNumber:1+G+$CardNumber+$CardSequenceNumber++$ATC+$TAN") assertEquals(result, "HKTAU:$SegmentNumber:1+G+$CardNumber+$CardSequenceNumber++$ATC+$TAN")
} }
@ -119,7 +118,7 @@ class TanGeneratorTanMediumAnOderUmmeldenTest: FinTsTestBase() {
// then // then
expect(result).toBe("HKTAU:$SegmentNumber:2+G+$CardNumber+++$CustomerId::$BankCountryCode:$BankCode") assertEquals(result, "HKTAU:$SegmentNumber:2+G+$CardNumber+++$CustomerId::$BankCountryCode:$BankCode")
} }
@Test @Test
@ -136,7 +135,7 @@ class TanGeneratorTanMediumAnOderUmmeldenTest: FinTsTestBase() {
// then // then
expect(result).toBe("HKTAU:$SegmentNumber:2+G+$CardNumber+++$CustomerId::$BankCountryCode:$BankCode++++$ATC+$TAN") assertEquals(result, "HKTAU:$SegmentNumber:2+G+$CardNumber+++$CustomerId::$BankCountryCode:$BankCode++++$ATC+$TAN")
} }
@Test @Test
@ -153,7 +152,7 @@ class TanGeneratorTanMediumAnOderUmmeldenTest: FinTsTestBase() {
// then // then
expect(result).toBe("HKTAU:$SegmentNumber:2+G+$CardNumber+$CardSequenceNumber++$CustomerId::$BankCountryCode:$BankCode") assertEquals(result, "HKTAU:$SegmentNumber:2+G+$CardNumber+$CardSequenceNumber++$CustomerId::$BankCountryCode:$BankCode")
} }
@Test @Test
@ -170,7 +169,7 @@ class TanGeneratorTanMediumAnOderUmmeldenTest: FinTsTestBase() {
// then // then
expect(result).toBe("HKTAU:$SegmentNumber:2+G+$CardNumber++$CardType+$CustomerId::$BankCountryCode:$BankCode") assertEquals(result, "HKTAU:$SegmentNumber:2+G+$CardNumber++$CardType+$CustomerId::$BankCountryCode:$BankCode")
} }
@Test @Test
@ -187,7 +186,7 @@ class TanGeneratorTanMediumAnOderUmmeldenTest: FinTsTestBase() {
// then // then
expect(result).toBe("HKTAU:$SegmentNumber:2+G+$CardNumber+$CardSequenceNumber+$CardType+$CustomerId::$BankCountryCode:$BankCode++++$ATC+$TAN") assertEquals(result, "HKTAU:$SegmentNumber:2+G+$CardNumber+$CardSequenceNumber+$CardType+$CustomerId::$BankCountryCode:$BankCode++++$ATC+$TAN")
} }
// TODO: may also test 'gueltig ab' and 'gueltig bis' // TODO: may also test 'gueltig ab' and 'gueltig bis'

View File

@ -1,9 +1,8 @@
package net.dankito.banking.fints.messages.segmente.implementierte.umsaetze 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 net.dankito.banking.fints.FinTsTestBase
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals
class SaldenabfrageVersion5Test : FinTsTestBase() { class SaldenabfrageVersion5Test : FinTsTestBase() {
@ -18,7 +17,7 @@ class SaldenabfrageVersion5Test : FinTsTestBase() {
val result = underTest.format() val result = underTest.format()
// then // then
expect(result).toBe("HKSAL:3:5+$CustomerId::280:$BankCode+N") assertEquals(result, "HKSAL:3:5+$CustomerId::280:$BankCode+N")
} }
@Test @Test
@ -31,7 +30,7 @@ class SaldenabfrageVersion5Test : FinTsTestBase() {
val result = underTest.format() val result = underTest.format()
// then // then
expect(result).toBe("HKSAL:3:5+$CustomerId::280:$BankCode+J") assertEquals(result, "HKSAL:3:5+$CustomerId::280:$BankCode+J")
} }
} }

View File

@ -1,9 +1,8 @@
package net.dankito.banking.fints.messages.segmente.implementierte.umsaetze 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 net.dankito.banking.fints.FinTsTestBase
import ch.tutteli.atrium.api.verbs.expect
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals
class SaldenabfrageVersion7Test : FinTsTestBase() { class SaldenabfrageVersion7Test : FinTsTestBase() {
@ -18,7 +17,7 @@ class SaldenabfrageVersion7Test : FinTsTestBase() {
val result = underTest.format() val result = underTest.format()
// then // then
expect(result).toBe("HKSAL:3:7+$Iban:$Bic:$CustomerId::280:$BankCode+N") assertEquals(result, "HKSAL:3:7+$Iban:$Bic:$CustomerId::280:$BankCode+N")
} }
@Test @Test
@ -31,7 +30,7 @@ class SaldenabfrageVersion7Test : FinTsTestBase() {
val result = underTest.format() val result = underTest.format()
// then // then
expect(result).toBe("HKSAL:3:7+$Iban:$Bic:$CustomerId::280:$BankCode+J") assertEquals(result, "HKSAL:3:7+$Iban:$Bic:$CustomerId::280:$BankCode+J")
} }
} }

View File

@ -1,9 +1,8 @@
package net.dankito.banking.fints.tan 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 net.dankito.banking.fints.model.HHDVersion
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals
class FlickerCodeDecoderTest { class FlickerCodeDecoderTest {
@ -23,7 +22,7 @@ class FlickerCodeDecoderTest {
// then // then
expect(response.parsedDataSet).toBe("070520829019981A") assertEquals("070520829019981A", response.parsedDataSet)
} }
@ -39,7 +38,7 @@ class FlickerCodeDecoderTest {
// then // then
expect(response.parsedDataSet).toBe("100520829019981849453939424F46494B") assertEquals("100520829019981849453939424F46494B", response.parsedDataSet)
} }
@Test @Test
@ -52,7 +51,7 @@ class FlickerCodeDecoderTest {
val result = underTest.decodeChallenge(challenge, HHDVersion.HHD_1_3) val result = underTest.decodeChallenge(challenge, HHDVersion.HHD_1_3)
// then // then
expect(result.parsedDataSet).toBe("1204881696280598765432101533322C30303A") assertEquals("1204881696280598765432101533322C30303A", result.parsedDataSet)
} }
@Test @Test
@ -65,7 +64,7 @@ class FlickerCodeDecoderTest {
val result = underTest.decodeChallenge(challenge, HHDVersion.HHD_1_3) val result = underTest.decodeChallenge(challenge, HHDVersion.HHD_1_3)
// then // then
expect(result.parsedDataSet).toBe("0604800402430B") assertEquals("0604800402430B", result.parsedDataSet)
} }
@ -79,7 +78,7 @@ class FlickerCodeDecoderTest {
val result = underTest.decodeChallenge(challenge, HHDVersion.HHD_1_4) val result = underTest.decodeChallenge(challenge, HHDVersion.HHD_1_4)
// then // then
expect(result.parsedDataSet).toBe("1F85012392301246564445323631323334353637383039383736353433323175") assertEquals("1F85012392301246564445323631323334353637383039383736353433323175", result.parsedDataSet)
} }
@Test @Test
@ -92,7 +91,7 @@ class FlickerCodeDecoderTest {
val result = underTest.decodeChallenge(challenge, HHDVersion.HHD_1_4) val result = underTest.decodeChallenge(challenge, HHDVersion.HHD_1_4)
// then // then
expect(result.parsedDataSet).toBe("2584011093744F5644453236313233343536373830393837363534333231463130302C303008") assertEquals("2584011093744F5644453236313233343536373830393837363534333231463130302C303008", result.parsedDataSet)
} }
} }

View File

@ -1,21 +1,16 @@
package net.dankito.banking.fints.transactions 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.FinTsTestBase
import net.dankito.banking.fints.transactions.mt940.Mt940Parser 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.Balance
import net.dankito.banking.fints.transactions.mt940.model.InformationToAccountOwner import net.dankito.banking.fints.transactions.mt940.model.InformationToAccountOwner
import net.dankito.banking.fints.transactions.mt940.model.StatementLine import net.dankito.banking.fints.transactions.mt940.model.StatementLine
import ch.tutteli.atrium.api.verbs.expect
import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDate
import kotlin.test.Test import net.dankito.banking.fints.extensions.*
import net.dankito.banking.fints.extensions.isFalse
import net.dankito.banking.fints.extensions.isTrue
import net.dankito.banking.fints.model.Amount import net.dankito.banking.fints.model.Amount
import net.dankito.utils.multiplatform.DateFormatter import net.dankito.utils.multiplatform.extensions.toStringWithTwoDigits
import net.dankito.utils.multiplatform.extensions.format import kotlin.test.Test
import kotlin.test.assertContains
class Mt940ParserTest : FinTsTestBase() { class Mt940ParserTest : FinTsTestBase() {
@ -57,16 +52,16 @@ class Mt940ParserTest : FinTsTestBase() {
// then // then
expect(result).hasSize(1) assertSize(1, result)
val statement = result.first() val statement = result.first()
expect(statement.bankCodeBicOrIban).toBe(BankCode) assertEquals(BankCode, statement.bankCodeBicOrIban)
expect(statement.accountIdentifier).toBe(CustomerId) assertEquals(CustomerId, statement.accountIdentifier)
assertBalance(statement.openingBalance, true, AccountStatement1PreviousStatementBookingDate, AccountStatement1OpeningBalanceAmount) assertBalance(statement.openingBalance, true, AccountStatement1PreviousStatementBookingDate, AccountStatement1OpeningBalanceAmount)
assertBalance(statement.closingBalance, true, AccountStatement1BookingDate, AccountStatement1ClosingBalanceAmount) assertBalance(statement.closingBalance, true, AccountStatement1BookingDate, AccountStatement1ClosingBalanceAmount)
expect(statement.transactions).hasSize(1) assertSize(1, statement.transactions)
val transaction = statement.transactions.first() val transaction = statement.transactions.first()
assertTurnover(transaction.statementLine, AccountStatement1BookingDate, AccountStatement1Transaction1Amount) assertTurnover(transaction.statementLine, AccountStatement1BookingDate, AccountStatement1Transaction1Amount)
@ -87,19 +82,19 @@ class Mt940ParserTest : FinTsTestBase() {
// then // then
expect(result).hasSize(1) assertSize(1, result)
val statement = result.first() val statement = result.first()
expect(statement.bankCodeBicOrIban).toBe(BankCode) assertEquals(BankCode, statement.bankCodeBicOrIban)
expect(statement.accountIdentifier).toBe(CustomerId) assertEquals(CustomerId, statement.accountIdentifier)
expect(statement.statementNumber).toBe(0) assertEquals(0, statement.statementNumber)
expect(statement.sequenceNumber).toBe(null) assertNull(statement.sequenceNumber)
assertBalance(statement.openingBalance, true, bookingDate, Amount("0,00")) assertBalance(statement.openingBalance, true, bookingDate, Amount("0,00"))
assertBalance(statement.closingBalance, isCredit, bookingDate, amount) assertBalance(statement.closingBalance, isCredit, bookingDate, amount)
expect(statement.transactions).hasSize(1) assertSize(1, statement.transactions)
val transaction = statement.transactions.first() val transaction = statement.transactions.first()
assertTurnover(transaction.statementLine, bookingDate, amount, isCredit) assertTurnover(transaction.statementLine, bookingDate, amount, isCredit)
@ -114,16 +109,16 @@ class Mt940ParserTest : FinTsTestBase() {
// then // then
expect(result).hasSize(1) assertSize(1, result)
val statement = result.first() val statement = result.first()
expect(statement.bankCodeBicOrIban).toBe(BankCode) assertEquals(BankCode, statement.bankCodeBicOrIban)
expect(statement.accountIdentifier).toBe(CustomerId) assertEquals(CustomerId, statement.accountIdentifier)
assertBalance(statement.openingBalance, true, AccountStatement1PreviousStatementBookingDate, AccountStatement1OpeningBalanceAmount) assertBalance(statement.openingBalance, true, AccountStatement1PreviousStatementBookingDate, AccountStatement1OpeningBalanceAmount)
assertBalance(statement.closingBalance, true, AccountStatement1BookingDate, AccountStatement1With2TransactionsClosingBalanceAmount) assertBalance(statement.closingBalance, true, AccountStatement1BookingDate, AccountStatement1With2TransactionsClosingBalanceAmount)
expect(statement.transactions).hasSize(2) assertSize(2, statement.transactions)
val firstTransaction = statement.transactions.first() val firstTransaction = statement.transactions.first()
assertTurnover(firstTransaction.statementLine, AccountStatement1BookingDate, AccountStatement1Transaction1Amount) assertTurnover(firstTransaction.statementLine, AccountStatement1BookingDate, AccountStatement1Transaction1Amount)
@ -158,13 +153,17 @@ class Mt940ParserTest : FinTsTestBase() {
// then // then
expect(result).hasSize(1) assertSize(1, result)
expect(result.first().transactions).hasSize(2) assertSize(2, result.first().transactions)
expect(result.first().transactions[0].statementLine.bookingDate).toBe(LocalDate(2019, 12, 30)) result.first().transactions[0].statementLine.apply {
expect(result.first().transactions[0].statementLine.valueDate).toBe(LocalDate(2020, 1, 1)) assertEquals(LocalDate(2019, 12, 30), bookingDate)
expect(result.first().transactions[1].statementLine.bookingDate).toBe(LocalDate(2019, 12, 30)) assertEquals(LocalDate(2020, 1, 1), valueDate)
expect(result.first().transactions[1].statementLine.valueDate).toBe(LocalDate(2020, 1, 1)) }
result.first().transactions[1].statementLine.apply {
assertEquals(LocalDate(2019, 12, 30), bookingDate)
assertEquals(LocalDate(2020, 1, 1), valueDate)
}
} }
@Test @Test
@ -226,8 +225,8 @@ class Mt940ParserTest : FinTsTestBase() {
// then // then
expect(result).hasSize(3) assertSize(3, result)
expect(result.flatMap { it.transactions }).hasSize(7) assertSize(7, result.flatMap { it.transactions })
} }
@Test @Test
@ -265,22 +264,22 @@ class Mt940ParserTest : FinTsTestBase() {
// then // then
expect(result).hasSize(1) assertSize(1, result)
expect(result.flatMap { it.transactions }).hasSize(3) assertSize(3, result.flatMap { it.transactions })
result.flatMap { it.transactions }.forEach { transaction -> result.flatMap { it.transactions }.forEach { transaction ->
expect(transaction.information).notToBeNull() assertNotNull(transaction.information)
expect(transaction.information?.sepaReference).notToBeNull() assertNotNull(transaction.information?.sepaReference)
if (transaction.information?.unparsedReference?.contains("KREF+") == true) { if (transaction.information?.unparsedReference?.contains("KREF+") == true) {
expect(transaction.information?.customerReference).notToBeNull() assertNotNull(transaction.information?.customerReference)
} }
} }
} }
@Test @Test
fun `Fix that ?, gets detected as field code`() { fun `Fix that questionmark, gets detected as field code`() {
val transactionsString = """ val transactionsString = """
:20:STARTUMS :20:STARTUMS
:25:$BankCode/$CustomerId :25:$BankCode/$CustomerId
@ -302,43 +301,45 @@ class Mt940ParserTest : FinTsTestBase() {
// then // then
expect(result).hasSize(1) assertSize(1, result)
expect(result.first().transactions).hasSize(1) assertSize(1, result.first().transactions)
expect(result.first().transactions[0].information?.bookingText).toBe("BASISLASTSCHRIFT") result.first().transactions[0].information?.apply {
expect(result.first().transactions[0].information?.otherPartyBankCode).toBe("TUBDDEDD") assertEquals("BASISLASTSCHRIFT", bookingText)
expect(result.first().transactions[0].information?.otherPartyAccountId).toBe("DE87300308801234567890") assertEquals("TUBDDEDD", otherPartyBankCode)
expect(result.first().transactions[0].information?.endToEndReference).toBe("6MKL2OT30QENNLIU") assertEquals("DE87300308801234567890", otherPartyAccountId)
expect(result.first().transactions[0].information?.mandateReference).toBe("?,3SQNdUbxm9z7dB)+gKYDJAKzCM0G") assertEquals("6MKL2OT30QENNLIU", endToEndReference)
expect(result.first().transactions[0].information?.sepaReference?.contains("IBAN: DE87300308801234567890 BIC: TUBDDEDD") ?: false).isTrue() assertEquals("?,3SQNdUbxm9z7dB)+gKYDJAKzCM0G", mandateReference)
assertContains(sepaReference ?: "", "IBAN: DE87300308801234567890 BIC: TUBDDEDD")
}
} }
private fun assertBalance(balance: Balance, isCredit: Boolean, bookingDate: LocalDate, amount: Amount) { private fun assertBalance(balance: Balance, isCredit: Boolean, bookingDate: LocalDate, amount: Amount) {
expect(balance.isCredit).toBe(isCredit) assertEquals(isCredit, balance.isCredit)
expect(balance.bookingDate).toBe(bookingDate) assertEquals(bookingDate, balance.bookingDate)
expect(balance.amount).toBe(amount) assertEquals(amount, balance.amount)
expect(balance.currency).toBe(Currency) assertEquals(Currency, balance.currency)
} }
private fun assertTurnover(statementLine: StatementLine, valueDate: LocalDate, amount: Amount, isCredit: Boolean = true, private fun assertTurnover(statementLine: StatementLine, valueDate: LocalDate, amount: Amount, isCredit: Boolean = true,
bookingDate: LocalDate? = valueDate) { bookingDate: LocalDate? = valueDate) {
expect(statementLine.isCredit).toBe(isCredit) assertEquals(isCredit, statementLine.isCredit)
expect(statementLine.isReversal).isFalse() assertFalse(statementLine.isReversal)
expect(statementLine.valueDate).toBe(valueDate) assertEquals(valueDate, statementLine.valueDate)
expect(statementLine.bookingDate).toBe(bookingDate) assertEquals(bookingDate, statementLine.bookingDate)
expect(statementLine.amount).toBe(amount) assertEquals(amount, statementLine.amount)
} }
private fun assertTransactionDetails(details: InformationToAccountOwner?, otherPartyName: String, private fun assertTransactionDetails(details: InformationToAccountOwner?, otherPartyName: String,
otherPartyBankCode: String, otherPartyAccountId: String) { otherPartyBankCode: String, otherPartyAccountId: String) {
expect(details).notToBeNull() assertNotNull(details)
expect(details?.otherPartyName).toBe(otherPartyName) assertEquals(otherPartyName, details.otherPartyName)
expect(details?.otherPartyBankCode).toBe(otherPartyBankCode) assertEquals(otherPartyBankCode, details.otherPartyBankCode)
expect(details?.otherPartyAccountId).toBe(otherPartyAccountId) assertEquals(otherPartyAccountId, details.otherPartyAccountId)
} }

View File

@ -1,12 +1,9 @@
package net.dankito.banking.fints.util 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 net.dankito.utils.multiplatform.extensions.randomWithSeed import net.dankito.utils.multiplatform.extensions.randomWithSeed
import kotlin.random.Random import kotlin.random.Random
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals
class Base64Test { class Base64Test {
@ -31,7 +28,7 @@ class Base64Test {
private fun testEncode(input: String, expectedOutput: String) { private fun testEncode(input: String, expectedOutput: String) {
val actualOutput = underTest.encode(input) val actualOutput = underTest.encode(input)
expect(actualOutput).toBe(expectedOutput) assertEquals(expectedOutput, actualOutput)
} }
@ -52,12 +49,11 @@ class Base64Test {
private fun testDecode(input: String, expectedOutput: String) { private fun testDecode(input: String, expectedOutput: String) {
val actualOutput = underTest.decode(input) val actualOutput = underTest.decode(input)
expect(actualOutput).toBe(expectedOutput) assertEquals(expectedOutput, actualOutput)
} }
@Test @Test
@ExperimentalWithOptions
fun testRandomStrings() { fun testRandomStrings() {
val steps = 1000000 val steps = 1000000
val random = randomWithSeed() val random = randomWithSeed()
@ -74,7 +70,7 @@ class Base64Test {
// then // then
expect(decoded).withRepresentation { "Decoded string '$decoded' should actually be '$original'" }.toBe(original) assertEquals(original, decoded, "Decoded string '$decoded' should actually be '$original'")
} }
} }

View File

@ -1,11 +1,10 @@
package net.dankito.banking.fints.util package net.dankito.banking.fints.util
import ch.tutteli.atrium.api.fluent.en_GB.toBe
import ch.tutteli.atrium.api.verbs.expect
import kotlinx.datetime.LocalDate import kotlinx.datetime.LocalDate
import kotlinx.datetime.LocalDateTime import kotlinx.datetime.LocalDateTime
import net.dankito.utils.multiplatform.extensions.of import net.dankito.utils.multiplatform.extensions.of
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals
class FinTsUtilsTest { class FinTsUtilsTest {
@ -22,7 +21,7 @@ class FinTsUtilsTest {
val result = underTest.formatDate(date) val result = underTest.formatDate(date)
// then // then
expect(result).toBe("19880327") assertEquals("19880327", result)
} }
@Test @Test
@ -35,7 +34,7 @@ class FinTsUtilsTest {
val result = underTest.formatDateAsInt(date) val result = underTest.formatDateAsInt(date)
// then // then
expect(result).toBe(19880327) assertEquals(19880327, result)
} }
@ -49,7 +48,7 @@ class FinTsUtilsTest {
val result = underTest.formatTime(time) val result = underTest.formatTime(time)
// then // then
expect(result).toBe("080201") assertEquals("080201", result)
} }
@Test @Test
@ -62,7 +61,7 @@ class FinTsUtilsTest {
val result = underTest.formatTime(time) val result = underTest.formatTime(time)
// then // then
expect(result).toBe("182251") assertEquals("182251", result)
} }
@Test @Test
@ -75,7 +74,7 @@ class FinTsUtilsTest {
val result = underTest.formatTimeAsInt(time) val result = underTest.formatTimeAsInt(time)
// then // then
expect(result).toBe(80201) assertEquals(80201, result)
} }
@Test @Test
@ -88,7 +87,7 @@ class FinTsUtilsTest {
val result = underTest.formatTimeAsInt(time) val result = underTest.formatTimeAsInt(time)
// then // then
expect(result).toBe(182251) assertEquals(182251, result)
} }
} }

View File

@ -88,7 +88,7 @@
// underTest.getAnonymousBankInfo(BankDataAnonymous) { result -> // underTest.getAnonymousBankInfo(BankDataAnonymous) { result ->
// //
// // then // // then
// expect(result.successful).isTrue() // assertTrue(result.successful)
// expect(BankDataAnonymous.supportedHbciVersions).isNotEmpty() // expect(BankDataAnonymous.supportedHbciVersions).isNotEmpty()
// expect(BankDataAnonymous.tanMethodsSupportedByBank).isNotEmpty() // expect(BankDataAnonymous.tanMethodsSupportedByBank).isNotEmpty()
// expect(BankDataAnonymous.supportedJobs).isNotEmpty() // expect(BankDataAnonymous.supportedJobs).isNotEmpty()
@ -117,9 +117,9 @@
// countDownLatch.await(30, TimeUnit.SECONDS) // countDownLatch.await(30, TimeUnit.SECONDS)
// val result = response.get() // val result = response.get()
// //
// expect(result.successful).isTrue() // assertTrue(result.successful)
// //
// expect(didAskUserForTanMethod).isFalse() // assertFalse(didAskUserForTanMethod)
// //
// expect(Bank.bankName).isNotEmpty() // expect(Bank.bankName).isNotEmpty()
// expect(Bank.supportedJobs).isNotEmpty() // supported jobs are now known // expect(Bank.supportedJobs).isNotEmpty() // supported jobs are now known
@ -131,7 +131,7 @@
// expect(Bank.tanMethodsAvailableForUser).isNotEmpty() // expect(Bank.tanMethodsAvailableForUser).isNotEmpty()
// expect(Bank.selectedLanguage).notToBe(Dialogsprache.Default) // language is set now // expect(Bank.selectedLanguage).notToBe(Dialogsprache.Default) // language is set now
// expect(Bank.customerSystemId).notToBe(KundensystemStatus.SynchronizingCustomerSystemId.code) // customer system id is now set // expect(Bank.customerSystemId).notToBe(KundensystemStatus.SynchronizingCustomerSystemId.code) // customer system id is now set
// expect(Bank.customerSystemStatus).toBe(KundensystemStatusWerte.Benoetigt) // customerSystemStatus is set now // assertEquals(KundensystemStatusWerte.Benoetigt, Bank.customerSystemStatus) // customerSystemStatus is set now
// expect(Bank.accounts).isNotEmpty() // accounts are now known // expect(Bank.accounts).isNotEmpty() // accounts are now known
// expect(Bank.accounts.first().allowedJobs).isNotEmpty() // allowed jobs are now known // expect(Bank.accounts.first().allowedJobs).isNotEmpty() // allowed jobs are now known
// } // }
@ -205,7 +205,7 @@
// countDownLatch.await(30, TimeUnit.SECONDS) // countDownLatch.await(30, TimeUnit.SECONDS)
// val result = response.get() // val result = response.get()
// //
// expect(result.successful).isTrue() // assertTrue(result.successful)
// //
// expect(result.tanMediaList).notToBeNull() // expect(result.tanMediaList).notToBeNull()
// expect(result.tanMediaList!!.usageOption).toBe(TanEinsatzOption.KundeKannGenauEinMediumZuEinerZeitNutzen) // TODO: may adjust to your value // expect(result.tanMediaList!!.usageOption).toBe(TanEinsatzOption.KundeKannGenauEinMediumZuEinerZeitNutzen) // TODO: may adjust to your value
@ -263,7 +263,7 @@
// countDownLatch.await(30, TimeUnit.SECONDS) // countDownLatch.await(30, TimeUnit.SECONDS)
// val result = response.get() // val result = response.get()
// //
// expect(result.successful).isTrue() // assertTrue(result.successful)
// //
// } // }
// //

View File

@ -54,8 +54,6 @@ kotlin {
dependencies { dependencies {
implementation kotlin("test-common") implementation kotlin("test-common")
implementation kotlin("test-annotations-common") implementation kotlin("test-annotations-common")
implementation "ch.tutteli.atrium:atrium-fluent-en_GB-common:$atriumVersion"
} }
} }
@ -76,11 +74,6 @@ kotlin {
implementation "org.junit.jupiter:junit-jupiter:$junit5Version" implementation "org.junit.jupiter:junit-jupiter:$junit5Version"
runtimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit5Version" runtimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit5Version"
implementation "org.assertj:assertj-core:$assertJVersion"
implementation "org.mockito:mockito-core:$mockitoVersion"
implementation "ch.tutteli.atrium:atrium-fluent-en_GB:$atriumVersion"
implementation "org.slf4j:slf4j-simple:$slf4jVersion" implementation "org.slf4j:slf4j-simple:$slf4jVersion"
} }

View File

@ -21,7 +21,7 @@ dependencies {
implementation 'org.docx4j:docx4j-JAXB-ReferenceImpl:8.1.3' implementation 'org.docx4j:docx4j-JAXB-ReferenceImpl:8.1.3'
testImplementation "junit:junit:$junitVersion" testImplementation "junit:junit:4.12"
testImplementation "org.assertj:assertj-core:$assertJVersion" testImplementation "org.assertj:assertj-core:$assertJVersion"
testImplementation "ch.qos.logback:logback-core:$logbackVersion" testImplementation "ch.qos.logback:logback-core:$logbackVersion"