Search in sources :

Example 11 with Organisation

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

the class IncomingDocAsOrderViewModel_Test method double_order_check_works.

@Test
public void double_order_check_works() throws Exception {
    // given
    IncomingDocAsOrderViewModel incomingDocAsOrderViewModel = new IncomingDocAsOrderViewModel();
    incomingDocAsOrderViewModel.orderRepository = mockOrderRepository;
    Order newOrder = new Order();
    incomingDocAsOrderViewModel.setDomainObject(newOrder);
    String sellerOrderReference = "123-456-7";
    Organisation seller = new Organisation();
    LocalDate orderDate = new LocalDate(2017, 01, 01);
    Order existingOrder = new Order();
    // expect
    context.checking(new Expectations() {

        {
            oneOf(mockOrderRepository).findBySellerOrderReferenceAndSellerAndOrderDate(sellerOrderReference, seller, orderDate);
            will(returnValue(newOrder));
            oneOf(mockOrderRepository).findBySellerOrderReferenceAndSeller(sellerOrderReference, seller);
            will(returnValue(Arrays.asList(newOrder, existingOrder)));
        }
    });
    // when
    incomingDocAsOrderViewModel.setSellerOrderReference(sellerOrderReference);
    incomingDocAsOrderViewModel.setSeller(seller);
    incomingDocAsOrderViewModel.setOrderDate(orderDate);
    String message = incomingDocAsOrderViewModel.doubleOrderCheck();
    // then
    Assertions.assertThat(message).contains("WARNING: Orders with the same seller order reference of this seller are found");
    // and expect
    context.checking(new Expectations() {

        {
            oneOf(mockOrderRepository).findBySellerOrderReferenceAndSellerAndOrderDate(sellerOrderReference, seller, orderDate);
            will(returnValue(existingOrder));
        }
    });
    // when
    message = incomingDocAsOrderViewModel.doubleOrderCheck();
    // then
    Assertions.assertThat(message).isEqualTo("WARNING: There is already an order with the same seller order reference and order date for this seller. Please check.");
}
Also used : Order(org.estatio.module.capex.dom.order.Order) Expectations(org.jmock.Expectations) Organisation(org.estatio.module.party.dom.Organisation) LocalDate(org.joda.time.LocalDate) IncomingDocAsOrderViewModel(org.estatio.module.capex.app.order.IncomingDocAsOrderViewModel) Test(org.junit.Test)

Example 12 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_bankaccounts_and_one_for_property.

@Test
public void unique_Debtor_Account_To_Pay_works_when_bankaccounts_and_one_for_property() throws Exception {
    // given
    DebtorBankAccountService service = new DebtorBankAccountService();
    service.bankAccountRepository = mockBankAccountRepository;
    service.fixedAssetFinancialAccountRepository = mockFixedAssetFinancialAccountRepository;
    BankAccount bankAccount = new BankAccount();
    BankAccount bankAccountForProperty = new BankAccount();
    FixedAssetFinancialAccount fixedAssetFinancialAccount = new FixedAssetFinancialAccount();
    fixedAssetFinancialAccount.setFinancialAccount(bankAccountForProperty);
    List<BankAccount> bankAccounts = new ArrayList<>();
    bankAccounts.add(bankAccount);
    bankAccounts.add(bankAccountForProperty);
    IncomingInvoice invoice = new IncomingInvoice();
    Party debtor = new Organisation();
    invoice.setBuyer(debtor);
    Property property = new Property();
    invoice.setProperty(property);
    // expect
    context.checking(new Expectations() {

        {
            oneOf(mockBankAccountRepository).findBankAccountsByOwner(debtor);
            will(returnValue(bankAccounts));
            oneOf(mockFixedAssetFinancialAccountRepository).findByFixedAsset(property);
            will(returnValue(Arrays.asList(fixedAssetFinancialAccount)));
        }
    });
    // when, then
    assertThat(service.uniqueDebtorAccountToPay(invoice)).isEqualTo(bankAccountForProperty);
}
Also used : Expectations(org.jmock.Expectations) FixedAssetFinancialAccount(org.estatio.module.assetfinancial.dom.FixedAssetFinancialAccount) 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) Property(org.estatio.module.asset.dom.Property) Test(org.junit.Test)

Example 13 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_one_bankaccount_and_no_property.

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

        {
            oneOf(mockBankAccountRepository).findBankAccountsByOwner(debtor);
            will(returnValue(Arrays.asList(bankAccount)));
        }
    });
    // when, then
    assertThat(service.uniqueDebtorAccountToPay(invoice)).isEqualTo(bankAccount);
}
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) BankAccount(org.estatio.module.financial.dom.BankAccount) Test(org.junit.Test)

Example 14 with Organisation

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

the class OrderMenu_Test method filterOrFindBySeller_filter_works.

@Test
public void filterOrFindBySeller_filter_works() {
    OrderMenu.OrderFinder builder;
    // given
    builder = new OrderMenu.OrderFinder(mockOrderRepository, mockPartyRepository);
    Order order1 = new Order();
    Person personToBeFiltered = new Person();
    Organisation seller = new Organisation();
    order1.setSeller(seller);
    Order order2 = new Order();
    builder.setResult(Arrays.asList(order1, order2));
    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 : Order(org.estatio.module.capex.dom.order.Order) Expectations(org.jmock.Expectations) Organisation(org.estatio.module.party.dom.Organisation) Person(org.estatio.module.party.dom.Person) Test(org.junit.Test)

Example 15 with Organisation

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

the class OrderMenu_Test method filterOrFindBySeller_find_works.

@Test
public void filterOrFindBySeller_find_works() {
    OrderMenu.OrderFinder builder;
    // given
    builder = new OrderMenu.OrderFinder(mockOrderRepository, mockPartyRepository);
    Organisation seller = new Organisation();
    // expect
    context.checking(new Expectations() {

        {
            oneOf(mockPartyRepository).findParties("*abc*");
            will(returnValue(Arrays.asList(seller)));
            oneOf(mockOrderRepository).findBySeller(seller);
        }
    });
    // when
    builder.filterOrFindBySeller("abc");
}
Also used : Expectations(org.jmock.Expectations) Organisation(org.estatio.module.party.dom.Organisation) 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