Added DialogEnde und MessageBuilder.createDialogEndMessage()
This commit is contained in:
parent
d90ec3a888
commit
bf70706f9c
|
@ -36,26 +36,39 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg
|
||||||
*
|
*
|
||||||
* Bei anonymen Dialogen werden Nachrichten weder signiert, noch können sie verschlüsselt und komprimiert werden.
|
* Bei anonymen Dialogen werden Nachrichten weder signiert, noch können sie verschlüsselt und komprimiert werden.
|
||||||
*/
|
*/
|
||||||
open fun createAnonymousDialogInitMessage(bank: BankData, product: ProductData): String {
|
open fun createAnonymousDialogInitMessage(bank: BankData, product: ProductData, dialogData: DialogData): String {
|
||||||
|
|
||||||
/**
|
|
||||||
* Wenn eine Synchronisierung der Kundensystem-ID durchgeführt wird, ist als Identifizierung der Partei ‚0’ einzustellen.
|
|
||||||
*/
|
|
||||||
|
|
||||||
val customer = CustomerData.Anonymous
|
val customer = CustomerData.Anonymous
|
||||||
|
|
||||||
return createMessage(false, false, bank, customer, DialogData.DialogInitDialogData, listOf(
|
return createMessage(false, false, bank, customer, dialogData, listOf(
|
||||||
IdentifikationsSegment(generator.resetSegmentNumber(1), bank, customer),
|
IdentifikationsSegment(generator.resetSegmentNumber(1), bank, customer),
|
||||||
Verarbeitungsvorbereitung(generator.getNextSegmentNumber(), bank, customer, product)
|
Verarbeitungsvorbereitung(generator.getNextSegmentNumber(), bank, customer, product)
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun createDialogInitMessage(bank: BankData, customer: CustomerData, product: ProductData): String {
|
open fun createAnonymousDialogEndMessage(bank: BankData, dialogData: DialogData): String {
|
||||||
|
|
||||||
return createMessage(true, true, bank, customer, DialogData.DialogInitDialogData, listOf(
|
val customer = CustomerData.Anonymous
|
||||||
|
|
||||||
|
return createMessage(false, false, bank, customer, dialogData, listOf(
|
||||||
|
Dialogende(generator.resetSegmentNumber(1), dialogData)
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
open fun createDialogInitMessage(bank: BankData, customer: CustomerData, product: ProductData, dialogData: DialogData): String {
|
||||||
|
|
||||||
|
return createMessage(true, true, bank, customer, dialogData, listOf(
|
||||||
IdentifikationsSegment(generator.resetSegmentNumber(2), bank, customer),
|
IdentifikationsSegment(generator.resetSegmentNumber(2), bank, customer),
|
||||||
Verarbeitungsvorbereitung(generator.getNextSegmentNumber(), bank, customer, product),
|
Verarbeitungsvorbereitung(generator.getNextSegmentNumber(), bank, customer, product),
|
||||||
ZweiSchrittTanEinreichung(generator.getNextSegmentNumber(), TanProcess.TanProcess4, "HKIDN")
|
ZweiSchrittTanEinreichung(generator.getNextSegmentNumber(), TanProcess.TanProcess4, "HKIDN") // TODO: make job reference referencable, don't hard code
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
open fun createDialogEndMessage(bank: BankData, customer: CustomerData, dialogData: DialogData): String {
|
||||||
|
|
||||||
|
return createMessage(true, true, bank, customer, dialogData, listOf(
|
||||||
|
Dialogende(generator.resetSegmentNumber(2), dialogData)
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package net.dankito.fints.messages.segmente.implementierte
|
||||||
|
|
||||||
|
import net.dankito.fints.messages.Existenzstatus
|
||||||
|
import net.dankito.fints.messages.datenelemente.implementierte.DialogId
|
||||||
|
import net.dankito.fints.messages.datenelementgruppen.implementierte.Segmentkopf
|
||||||
|
import net.dankito.fints.messages.segmente.Segment
|
||||||
|
import net.dankito.fints.model.DialogData
|
||||||
|
|
||||||
|
|
||||||
|
class Dialogende(
|
||||||
|
segmentNumber: Int,
|
||||||
|
dialogData: DialogData
|
||||||
|
|
||||||
|
) : Segment(listOf(
|
||||||
|
Segmentkopf("HKEND", 1, segmentNumber),
|
||||||
|
DialogId(dialogData.dialogId)
|
||||||
|
), Existenzstatus.Mandatory)
|
|
@ -4,6 +4,7 @@ import net.dankito.fints.messages.datenelemente.abgeleiteteformate.Laenderkennze
|
||||||
import net.dankito.fints.messages.datenelemente.implementierte.Dialogsprache
|
import net.dankito.fints.messages.datenelemente.implementierte.Dialogsprache
|
||||||
import net.dankito.fints.messages.datenelemente.implementierte.signatur.Sicherheitsfunktion
|
import net.dankito.fints.messages.datenelemente.implementierte.signatur.Sicherheitsfunktion
|
||||||
import net.dankito.fints.model.*
|
import net.dankito.fints.model.*
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
|
||||||
abstract class FinTsTestBase {
|
abstract class FinTsTestBase {
|
||||||
|
@ -37,6 +38,10 @@ abstract class FinTsTestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected open fun createDialogId(): String {
|
||||||
|
return UUID.randomUUID().toString().replace("-", "")
|
||||||
|
}
|
||||||
|
|
||||||
protected open fun normalizeBinaryData(message: String): String {
|
protected open fun normalizeBinaryData(message: String): String {
|
||||||
return message.replace(0.toChar(), ' ')
|
return message.replace(0.toChar(), ' ')
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.dankito.fints.messages
|
package net.dankito.fints.messages
|
||||||
|
|
||||||
import net.dankito.fints.FinTsTestBase
|
import net.dankito.fints.FinTsTestBase
|
||||||
|
import net.dankito.fints.model.DialogData
|
||||||
import net.dankito.fints.util.FinTsUtils
|
import net.dankito.fints.util.FinTsUtils
|
||||||
import org.assertj.core.api.Assertions.assertThat
|
import org.assertj.core.api.Assertions.assertThat
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
@ -23,11 +24,8 @@ class MessageBuilderTest : FinTsTestBase() {
|
||||||
@Test
|
@Test
|
||||||
fun createAnonymousDialogInitMessage() {
|
fun createAnonymousDialogInitMessage() {
|
||||||
|
|
||||||
// given
|
|
||||||
val underTest = underTest.createAnonymousDialogInitMessage(Bank, Product)
|
|
||||||
|
|
||||||
// when
|
// when
|
||||||
val result = underTest.format()
|
val result = underTest.createAnonymousDialogInitMessage(Bank, Product, DialogData.DialogInitDialogData)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result).isEqualTo(
|
assertThat(result).isEqualTo(
|
||||||
|
@ -39,13 +37,29 @@ class MessageBuilderTest : FinTsTestBase() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun createDialogInitMessage() {
|
fun createAnonymousDialogEndMessage() {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
val underTest = underTest.createDialogInitMessage(Bank, Customer, Product)
|
val dialogId = createDialogId()
|
||||||
|
val dialogData = DialogData(dialogId)
|
||||||
|
|
||||||
// when
|
// when
|
||||||
val result = underTest.format()
|
val result = underTest.createAnonymousDialogEndMessage(Bank, dialogData)
|
||||||
|
|
||||||
|
// then
|
||||||
|
assertThat(normalizeBinaryData(result)).isEqualTo(normalizeBinaryData(
|
||||||
|
"HNHBK:1:3+000000000086+300+$dialogId+1'" +
|
||||||
|
"HKEND:2:1+$dialogId'" +
|
||||||
|
"HNHBS:3:1+1'"
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun createDialogInitMessage() {
|
||||||
|
|
||||||
|
// when
|
||||||
|
val result = underTest.createDialogInitMessage(Bank, Customer, Product, DialogData.DialogInitDialogData)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(normalizeBinaryData(result)).isEqualTo(normalizeBinaryData(
|
assertThat(normalizeBinaryData(result)).isEqualTo(normalizeBinaryData(
|
||||||
|
@ -60,4 +74,25 @@ class MessageBuilderTest : FinTsTestBase() {
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun createDialogEndMessage() {
|
||||||
|
|
||||||
|
// given
|
||||||
|
val dialogId = createDialogId()
|
||||||
|
val dialogData = DialogData(dialogId)
|
||||||
|
|
||||||
|
// when
|
||||||
|
val result = underTest.createDialogEndMessage(Bank, Customer, dialogData)
|
||||||
|
|
||||||
|
// then
|
||||||
|
assertThat(normalizeBinaryData(result)).isEqualTo(normalizeBinaryData(
|
||||||
|
"HNHBK:1:3+000000000340+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+@177@" + "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'" +
|
||||||
|
"HNSHA:3:2+$ControlReference++$Pin''" +
|
||||||
|
"HKEND:4:1+$dialogId'" +
|
||||||
|
"HNHBS:5:1+1'"
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue