use of org.estatio.module.financial.dom.BankAccountRepository in project estatio by estatio.
the class IncomingDocAsInvoiceViewModel_autoCompleteBankAccount_Test method autoCompleteBankAccount_works.
@Test
public void autoCompleteBankAccount_works() throws Exception {
List<BankAccount> result;
// given
IncomingDocAsInvoiceViewModel vm = new IncomingDocAsInvoiceViewModel() {
IncomingDocAsInvoiceViewModel setBankAccountRepository(BankAccountRepository bankAccountRepository) {
this.bankAccountRepository = bankAccountRepository;
return this;
}
}.setBankAccountRepository(mockBankAccountRepository);
BankAccount acc1 = new BankAccount();
BankAccount acc2 = new BankAccount();
Party owner = new Organisation();
acc2.setOwner(owner);
// expect
context.checking(new Expectations() {
{
allowing(mockBankAccountRepository).autoComplete(with(any(String.class)));
will(returnValue(Arrays.asList(acc1, acc2)));
oneOf(mockBankAccountRepository).findBankAccountsByOwner(owner);
will(returnValue(Arrays.asList(acc2)));
}
});
// when
result = vm.autoCompleteBankAccount("some searchstring");
// then
assertThat(result.size()).isEqualTo(2);
// and when seller is set
vm.setSeller(owner);
result = vm.autoCompleteBankAccount("3");
// then
assertThat(result.size()).isEqualTo(1);
assertThat(result.get(0)).isEqualTo(acc2);
}
Aggregations