Fixed that credit card transactions list may is empty
This commit is contained in:
parent
d492b90321
commit
787b91f7a8
|
@ -685,7 +685,7 @@ open class ResponseParser(
|
||||||
|
|
||||||
protected open fun parseCreditCardTransactions(segment: String, dataElementGroups: List<String>): ReceivedCreditCardTransactionsAndBalance {
|
protected open fun parseCreditCardTransactions(segment: String, dataElementGroups: List<String>): ReceivedCreditCardTransactionsAndBalance {
|
||||||
val balance = parseBalance(dataElementGroups[3])
|
val balance = parseBalance(dataElementGroups[3])
|
||||||
val transactionsDataElementGroups = dataElementGroups.subList(6, dataElementGroups.size)
|
val transactionsDataElementGroups = if (dataElementGroups.size < 7) listOf() else dataElementGroups.subList(6, dataElementGroups.size)
|
||||||
|
|
||||||
return ReceivedCreditCardTransactionsAndBalance(
|
return ReceivedCreditCardTransactionsAndBalance(
|
||||||
balance,
|
balance,
|
||||||
|
|
|
@ -1119,6 +1119,31 @@ class ResponseParserTest : FinTsTestBase() {
|
||||||
?: run { fail("No segment of type ReceivedCreditCardTransactionsAndBalance found in ${result.receivedSegments}") }
|
?: run { fail("No segment of type ReceivedCreditCardTransactionsAndBalance found in ${result.receivedSegments}") }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun parseCreditCardAccountTransactionsWithEmptyTransactionsList() {
|
||||||
|
|
||||||
|
// given
|
||||||
|
val creditCardNumber = "4263540122107989"
|
||||||
|
val balance = "189,5"
|
||||||
|
val otherPartyName = "Bundesanzeiger Verlag Koeln 000"
|
||||||
|
val amount = "6,5"
|
||||||
|
|
||||||
|
// when
|
||||||
|
val result = underTest.parse("DIKKU:7:2:3+$creditCardNumber++C:$balance:EUR:20200923:021612'")
|
||||||
|
|
||||||
|
// then
|
||||||
|
assertSuccessfullyParsedSegment(result, InstituteSegmentId.CreditCardTransactions, 7, 2, 3)
|
||||||
|
|
||||||
|
result.getFirstSegmentById<ReceivedCreditCardTransactionsAndBalance>(InstituteSegmentId.CreditCardTransactions)?.let { segment ->
|
||||||
|
expect(segment.balance.amount.string).toBe(balance)
|
||||||
|
expect(segment.balance.date).toBe(Date(2020, 9, 23))
|
||||||
|
expect(segment.balance.time).notToBeNull()
|
||||||
|
|
||||||
|
expect(segment.transactions).isEmpty()
|
||||||
|
}
|
||||||
|
?: run { fail("No segment of type ReceivedCreditCardTransactionsAndBalance found in ${result.receivedSegments}") }
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun parseCreditCardAccountTransactionsParameters() {
|
fun parseCreditCardAccountTransactionsParameters() {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue