Search in sources :

Example 1 with BankAccountRepository

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);
}
Also used : Expectations(org.jmock.Expectations) Party(org.estatio.module.party.dom.Party) Organisation(org.estatio.module.party.dom.Organisation) BankAccount(org.estatio.module.financial.dom.BankAccount) BankAccountRepository(org.estatio.module.financial.dom.BankAccountRepository) Test(org.junit.Test)

Aggregations

BankAccount (org.estatio.module.financial.dom.BankAccount)1 BankAccountRepository (org.estatio.module.financial.dom.BankAccountRepository)1 Organisation (org.estatio.module.party.dom.Organisation)1 Party (org.estatio.module.party.dom.Party)1 Expectations (org.jmock.Expectations)1 Test (org.junit.Test)1