2019-10-12 23:12:37 +00:00
|
|
|
package net.dankito.fints
|
|
|
|
|
|
|
|
import net.dankito.fints.messages.datenelemente.abgeleiteteformate.Laenderkennzeichen
|
|
|
|
import net.dankito.fints.messages.datenelemente.implementierte.Dialogsprache
|
|
|
|
import net.dankito.fints.messages.datenelemente.implementierte.KundensystemStatus
|
|
|
|
import net.dankito.fints.messages.datenelemente.implementierte.KundensystemStatusWerte
|
2019-10-15 18:05:01 +00:00
|
|
|
import net.dankito.fints.messages.datenelemente.implementierte.signatur.Sicherheitsfunktion
|
2019-10-12 23:12:37 +00:00
|
|
|
import net.dankito.fints.model.*
|
2019-10-13 16:54:12 +00:00
|
|
|
import net.dankito.fints.response.client.FinTsClientResponse
|
2019-10-12 23:12:37 +00:00
|
|
|
import net.dankito.fints.util.Java8Base64Service
|
|
|
|
import org.assertj.core.api.Assertions.assertThat
|
|
|
|
import org.junit.Ignore
|
|
|
|
import org.junit.Test
|
2019-10-15 16:23:03 +00:00
|
|
|
import java.util.*
|
2019-10-12 23:12:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
@Ignore // not an automatic test, supply your settings below
|
|
|
|
class FinTsClientTest {
|
|
|
|
|
2019-10-15 16:23:03 +00:00
|
|
|
private val callback = object : FinTsClientCallback {
|
2019-10-13 16:54:12 +00:00
|
|
|
|
2019-10-15 16:23:03 +00:00
|
|
|
override fun askUserForTanProcedure(supportedTanProcedures: List<TanProcedure>): TanProcedure? {
|
|
|
|
// TODO: if entering TAN is required select your tan procedure here
|
|
|
|
return supportedTanProcedures.first()
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private val underTest = object : FinTsClient(callback, Java8Base64Service()) {
|
|
|
|
|
|
|
|
fun testSynchronizeCustomerSystemId(bank: BankData, customer: CustomerData): FinTsClientResponse {
|
2019-10-13 16:54:12 +00:00
|
|
|
return synchronizeCustomerSystemId(bank, customer)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-10-12 23:12:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
private val BankDataAnonymous = BankData("10070000", Laenderkennzeichen.Germany, "https://fints.deutsche-bank.de/")
|
|
|
|
|
|
|
|
// TODO: add your settings here:
|
|
|
|
private val Bank = BankData("", Laenderkennzeichen.Germany, "", bic = "")
|
|
|
|
private val Customer = CustomerData("", "", name = "", iban = "",
|
|
|
|
selectedTanProcedure = TanProcedure("", Sicherheitsfunktion.PIN_TAN_911, TanProcedureType.ChipTan))
|
|
|
|
|
|
|
|
// transfer 1 cent to yourself. Transferring money to oneself also doesn't require to enter a TAN according to PSD2
|
|
|
|
private val BankTransferData = BankTransferData(Customer.name, Customer.iban!!, Bank.bic!!, 0.01.toBigDecimal(), "Give it to me baby")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
fun getAnonymousBankInfo() {
|
|
|
|
|
|
|
|
// when
|
2019-10-13 15:24:47 +00:00
|
|
|
val result = underTest.getAnonymousBankInfo(BankDataAnonymous)
|
2019-10-12 23:12:37 +00:00
|
|
|
|
|
|
|
// then
|
2019-10-13 17:44:16 +00:00
|
|
|
assertThat(result.isSuccessful).isTrue()
|
2019-10-12 23:12:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
fun synchronizeCustomerSystemId() {
|
|
|
|
|
|
|
|
// when
|
2019-10-15 16:23:03 +00:00
|
|
|
val result = underTest.testSynchronizeCustomerSystemId(Bank, Customer)
|
2019-10-12 23:12:37 +00:00
|
|
|
|
|
|
|
// then
|
2019-10-13 17:44:16 +00:00
|
|
|
assertThat(result.isSuccessful).isTrue()
|
2019-10-12 23:12:37 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
fun getTransactions() {
|
|
|
|
|
2019-10-13 18:12:04 +00:00
|
|
|
// when
|
|
|
|
|
2019-10-12 23:12:37 +00:00
|
|
|
// some banks support retrieving account transactions of last 90 days without TAN
|
2019-10-13 18:12:04 +00:00
|
|
|
val result = underTest.tryGetTransactionsOfLast90DaysWithoutTan(Bank, Customer)
|
2019-10-12 23:12:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
// then
|
2019-10-13 17:44:16 +00:00
|
|
|
assertThat(result.isSuccessful).isTrue()
|
2019-10-13 16:08:42 +00:00
|
|
|
assertThat(result.bookedTransactions).isNotEmpty()
|
2019-10-12 23:12:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
fun testBankTransfer() {
|
|
|
|
|
|
|
|
// when
|
2019-10-13 15:24:47 +00:00
|
|
|
val result = underTest.doBankTransfer(BankTransferData, Bank, Customer)
|
2019-10-12 23:12:37 +00:00
|
|
|
|
|
|
|
// then
|
2019-10-13 17:44:16 +00:00
|
|
|
assertThat(result.isSuccessful).isTrue()
|
2019-10-12 23:12:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|