Search in sources :

Example 26 with Organisation

use of org.estatio.module.party.dom.Organisation in project estatio by estatio.

the class DebtorBankAccountService_Test method unique_Debtor_Account_To_Pay_works_when_multiple_bankaccounts_one_preferred.

@Test
public void unique_Debtor_Account_To_Pay_works_when_multiple_bankaccounts_one_preferred() throws Exception {
    // given
    DebtorBankAccountService service = new DebtorBankAccountService();
    service.bankAccountRepository = mockBankAccountRepository;
    BankAccount bankAccount = new BankAccount();
    BankAccount preferredBankAccount = new BankAccount();
    preferredBankAccount.setPreferred(true);
    List<BankAccount> bankAccounts = new ArrayList<>();
    bankAccounts.add(bankAccount);
    bankAccounts.add(preferredBankAccount);
    IncomingInvoice invoice = new IncomingInvoice();
    Party debtor = new Organisation();
    invoice.setBuyer(debtor);
    // expect
    context.checking(new Expectations() {

        {
            oneOf(mockBankAccountRepository).findBankAccountsByOwner(debtor);
            will(returnValue(bankAccounts));
        }
    });
    // when, then
    assertThat(service.uniqueDebtorAccountToPay(invoice)).isEqualTo(preferredBankAccount);
}
Also used : Expectations(org.jmock.Expectations) Party(org.estatio.module.party.dom.Party) Organisation(org.estatio.module.party.dom.Organisation) ArrayList(java.util.ArrayList) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) BankAccount(org.estatio.module.financial.dom.BankAccount) Test(org.junit.Test)

Example 27 with Organisation

use of org.estatio.module.party.dom.Organisation in project estatio by estatio.

the class DebtorBankAccountService_Test method unique_Debtor_Account_To_Pay_works_when_no_bankaccount_and_no_property.

@Test
public void unique_Debtor_Account_To_Pay_works_when_no_bankaccount_and_no_property() throws Exception {
    // given
    DebtorBankAccountService service = new DebtorBankAccountService();
    service.bankAccountRepository = mockBankAccountRepository;
    IncomingInvoice invoice = new IncomingInvoice();
    Party debtor = new Organisation();
    invoice.setBuyer(debtor);
    // expect
    context.checking(new Expectations() {

        {
            oneOf(mockBankAccountRepository).findBankAccountsByOwner(debtor);
        }
    });
    // when, then
    assertThat(service.uniqueDebtorAccountToPay(invoice)).isNull();
}
Also used : Expectations(org.jmock.Expectations) Party(org.estatio.module.party.dom.Party) Organisation(org.estatio.module.party.dom.Organisation) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) Test(org.junit.Test)

Example 28 with Organisation

use of org.estatio.module.party.dom.Organisation in project estatio by estatio.

the class DebtorBankAccountService_Test method unique_Debtor_Account_To_Pay_works_when_multiple_bankaccounts_none_preferred.

@Test
public void unique_Debtor_Account_To_Pay_works_when_multiple_bankaccounts_none_preferred() throws Exception {
    // given
    DebtorBankAccountService service = new DebtorBankAccountService();
    service.bankAccountRepository = mockBankAccountRepository;
    BankAccount bankAccount1 = new BankAccount();
    BankAccount bankAccount2 = new BankAccount();
    List<BankAccount> bankAccounts = new ArrayList<>();
    bankAccounts.add(bankAccount1);
    bankAccounts.add(bankAccount2);
    IncomingInvoice invoice = new IncomingInvoice();
    Party debtor = new Organisation();
    invoice.setBuyer(debtor);
    // expect
    context.checking(new Expectations() {

        {
            oneOf(mockBankAccountRepository).findBankAccountsByOwner(debtor);
            will(returnValue(bankAccounts));
        }
    });
    // when, then
    assertThat(service.uniqueDebtorAccountToPay(invoice)).isNull();
}
Also used : Expectations(org.jmock.Expectations) Party(org.estatio.module.party.dom.Party) Organisation(org.estatio.module.party.dom.Organisation) ArrayList(java.util.ArrayList) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) BankAccount(org.estatio.module.financial.dom.BankAccount) Test(org.junit.Test)

Example 29 with Organisation

use of org.estatio.module.party.dom.Organisation in project estatio by estatio.

the class IncomingInvoiceMenu_Test method filterOrFindBySeller_filter_works.

@Test
public void filterOrFindBySeller_filter_works() {
    IncomingInvoiceMenu.IncomingInvoiceFinder builder;
    // given
    builder = new IncomingInvoiceMenu.IncomingInvoiceFinder(mockInvoiceRepository, mockIncomingInvoiceRepository, mockPartyRepository);
    IncomingInvoice invoice1 = new IncomingInvoice();
    Person personToBeFiltered = new Person();
    Organisation seller = new Organisation();
    invoice1.setSeller(seller);
    IncomingInvoice invoice2 = new IncomingInvoice();
    builder.setResult(Arrays.asList(invoice1, invoice2));
    Assertions.assertThat(builder.getResult().size()).isEqualTo(2);
    // expect
    context.checking(new Expectations() {

        {
            oneOf(mockPartyRepository).findParties("*abc*");
            will(returnValue(Arrays.asList(seller, personToBeFiltered)));
        }
    });
    // when
    builder.filterOrFindBySeller("abc");
    // then
    Assertions.assertThat(builder.getResult().size()).isEqualTo(1);
}
Also used : Expectations(org.jmock.Expectations) IncomingInvoiceMenu(org.estatio.module.capex.app.IncomingInvoiceMenu) Organisation(org.estatio.module.party.dom.Organisation) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) Person(org.estatio.module.party.dom.Person) Test(org.junit.Test)

Example 30 with Organisation

use of org.estatio.module.party.dom.Organisation in project estatio by estatio.

the class Order_Test method minimalRequiredDataToComplete_consitent_dimensions_for_property_project.

@Test
public void minimalRequiredDataToComplete_consitent_dimensions_for_property_project() throws Exception {
    // given
    Order order = new Order();
    OrderItem item1 = new OrderItem();
    order.getItems().add(item1);
    order.setOrderNumber("123");
    order.setBuyer(new Organisation());
    order.setSeller(new Organisation());
    item1.setNetAmount(new BigDecimal("100"));
    item1.setDescription("blah");
    item1.setGrossAmount(BigDecimal.ZERO);
    item1.setCharge(new Charge());
    item1.setStartDate(new LocalDate());
    item1.setEndDate(new LocalDate());
    // when
    item1.setProject(new Project());
    String result = order.reasonIncomplete();
    // then
    assertThat(result).isEqualTo("(on item) when project filled in then property required");
}
Also used : Project(org.estatio.module.capex.dom.project.Project) Organisation(org.estatio.module.party.dom.Organisation) Charge(org.estatio.module.charge.dom.Charge) LocalDate(org.joda.time.LocalDate) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

Organisation (org.estatio.module.party.dom.Organisation)37 Test (org.junit.Test)26 Expectations (org.jmock.Expectations)18 Party (org.estatio.module.party.dom.Party)13 IncomingInvoice (org.estatio.module.capex.dom.invoice.IncomingInvoice)9 BankAccount (org.estatio.module.financial.dom.BankAccount)7 LocalDate (org.joda.time.LocalDate)7 Action (org.apache.isis.applib.annotation.Action)6 Property (org.estatio.module.asset.dom.Property)5 BigDecimal (java.math.BigDecimal)4 ArrayList (java.util.ArrayList)4 Charge (org.estatio.module.charge.dom.Charge)4 Order (org.estatio.module.capex.dom.order.Order)3 Person (org.estatio.module.party.dom.Person)3 ActionLayout (org.apache.isis.applib.annotation.ActionLayout)2 BudgetItem (org.estatio.module.budget.dom.budgetitem.BudgetItem)2 IncomingInvoiceMenu (org.estatio.module.capex.app.IncomingInvoiceMenu)2 Project (org.estatio.module.capex.dom.project.Project)2 Country (org.incode.module.country.dom.impl.Country)2 MemberOrder (org.apache.isis.applib.annotation.MemberOrder)1