Я хочу использовать assertj для проверки данных в массиве, содержащем другой массив.
accounts: [class AccountResource {
resourceId: 010001781LV
bicFi: null
accountId: null
name: Livret A Rosalie
details: LIVRET A
linkedAccount: null
usage: PRIV
cashAccountType: null
product: LVA
currency: EUR
balances: [class BalanceResource {
name: null
balanceAmount: class AmountType {
currency: EUR
amount: 10000
}
balanceType: CLBD
lastChangeDateTime: null
referenceDate: 2018-05-31
lastCommittedTransaction: null
}, class BalanceResource {
name: null
balanceAmount: class AmountType {
currency: EUR
amount: 10000
}
balanceType: XPCD
lastChangeDateTime: null
referenceDate: 2018-05-31
lastCommittedTransaction: null
}]
psuStatus: Account Holder
links: null
}
Мои 2 первых тестовых случая в порядке.Я фильтрую по 'resourceId = 010001781LV' и проверяю account.currency = EUR.Я фильтрую по 'resourceId = 010001781LV' и проверяю account.balances.size () = 2.
assertThat(halAccounts.getAccounts())
.filteredOn(account -> account.getResourceId().equals("010001781LV"))
.extracting(account -> account.getCurrency())
.containsExactly("EUR");
assertThat(halAccounts.getAccounts())
.filteredOn(account -> account.getResourceId().equals("010001781LV"))
.extracting(account -> account.getBalances().size())
.containsExactly(2);
, но хочу фильтровать по 'resourceId = 010001781LV' и фильтровать по сальдо (foreach) .balanceType= CLBD 'и проверьте balanceAmount = 10000.
Я пытаюсь лямбда в другой лямбде , но мне нужна помощь :
assertThat(halAccounts.getAccounts())
.filteredOn(account -> account.getResourceId().equals("010001781LV"))
.filteredOn(account -> account.getBalances().forEach(balance -> {
balance.getBalanceAmount().getAmount().equals("10000");
}))
.extracting(balance -> balance.getBalanceAmount().getAmount())
.contains("1000");
У меня эта ошибка на 2-м filteredOn
:
Multiple markers at this line
- The target type of this expression must be a functional interface
- The method filteredOn(Condition<? super AccountResource>) in the type AbstractIterableAssert<ListAssert<AccountResource>,List<?
extends AccountResource>,AccountResource,ObjectAssert<AccountResource>> is not applicable for the arguments ((<no type> account) -> {})