Search in sources :

Example 16 with Organisation

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

the class IncomingInvoiceMenu_Test method filterOrFindBySeller_find_works.

@Test
public void filterOrFindBySeller_find_works() {
    IncomingInvoiceMenu.IncomingInvoiceFinder builder;
    // given
    builder = new IncomingInvoiceMenu.IncomingInvoiceFinder(mockInvoiceRepository, mockIncomingInvoiceRepository, mockPartyRepository);
    Organisation seller = new Organisation();
    // expect
    context.checking(new Expectations() {

        {
            oneOf(mockPartyRepository).findParties("*abc*");
            will(returnValue(Arrays.asList(seller)));
            oneOf(mockInvoiceRepository).findBySeller(seller);
        }
    });
    // when
    builder.filterOrFindBySeller("abc");
}
Also used : Expectations(org.jmock.Expectations) IncomingInvoiceMenu(org.estatio.module.capex.app.IncomingInvoiceMenu) Organisation(org.estatio.module.party.dom.Organisation) Test(org.junit.Test)

Example 17 with Organisation

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

the class OrderRepository_Test method upsert_when_already_exists.

@Test
public void upsert_when_already_exists() throws Exception {
    // given
    OrderRepository orderRepository = new OrderRepository() {

        @Override
        public Order findByOrderNumber(final String orderNumber) {
            return order;
        }
    };
    String number = "some number";
    String sellerOrderReference = "ref";
    LocalDate entryDate = new LocalDate(2017, 1, 1);
    LocalDate orderDate = new LocalDate(2017, 1, 2);
    Party seller = new Organisation();
    Party buyer = new Organisation();
    Property property = new Property();
    String atPath = "atPath";
    OrderApprovalState approvalState = OrderApprovalState.APPROVED;
    assertThat(order.getOrderNumber()).isNull();
    // when
    orderRepository.upsert(property, number, sellerOrderReference, entryDate, orderDate, seller, buyer, atPath, approvalState);
    // then
    assertThat(order.getOrderNumber()).isNull();
    assertThat(order.getSellerOrderReference()).isEqualTo(sellerOrderReference);
    assertThat(order.getEntryDate()).isEqualTo(entryDate);
    assertThat(order.getOrderDate()).isEqualTo(orderDate);
    assertThat(order.getSeller()).isEqualTo(seller);
    assertThat(order.getBuyer()).isEqualTo(buyer);
    assertThat(order.getProperty()).isEqualTo(property);
    assertThat(order.getAtPath()).isEqualTo(atPath);
    // is ignored.
    assertThat(order.getApprovalState()).isNull();
}
Also used : Party(org.estatio.module.party.dom.Party) Organisation(org.estatio.module.party.dom.Organisation) LocalDate(org.joda.time.LocalDate) Property(org.estatio.module.asset.dom.Property) OrderApprovalState(org.estatio.module.capex.dom.order.approval.OrderApprovalState) Test(org.junit.Test)

Example 18 with Organisation

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

the class Order_Test method minimalRequiredDataToComplete.

@Test
public void minimalRequiredDataToComplete() throws Exception {
    // given
    Order order = new Order();
    OrderItem item1 = new OrderItem();
    order.getItems().add(item1);
    // when
    String result = order.reasonIncomplete();
    // then
    assertThat(result).isEqualTo("order number, buyer, seller, (on item) description, charge, start date, end date, net amount, gross amount required");
    // and when
    order.setOrderNumber("123");
    item1.setNetAmount(new BigDecimal("100"));
    result = order.reasonIncomplete();
    // then
    assertThat(result).isEqualTo("buyer, seller, (on item) description, charge, start date, end date, gross amount required");
    // and when
    order.setBuyer(new Organisation());
    order.setSeller(new Organisation());
    item1.setDescription("blah");
    item1.setGrossAmount(BigDecimal.ZERO);
    item1.setCharge(new Charge());
    item1.setStartDate(new LocalDate());
    item1.setEndDate(new LocalDate());
    result = order.reasonIncomplete();
    // then
    assertThat(result).isNull();
}
Also used : 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)

Example 19 with Organisation

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

the class PaymentBatch_Test method newOrganisation.

Organisation newOrganisation(final String reference, final String applicationTenancyPath) {
    final Organisation organisation = new Organisation() {

        @Override
        public String getAtPath() {
            return applicationTenancyPath;
        }
    };
    organisation.setReference(reference);
    organisation.setName(reference + " Organisation");
    organisation.setApplicationTenancyPath(applicationTenancyPath);
    return organisation;
}
Also used : Organisation(org.estatio.module.party.dom.Organisation)

Example 20 with Organisation

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

the class BankAccountRepository_Test method findBankAccountsByOwner_filters_deprecated.

@Test
public void findBankAccountsByOwner_filters_deprecated() throws Exception {
    // given
    BankAccountRepository repo = new BankAccountRepository();
    repo.financialAccountRepository = mockFARepo;
    Party party = new Organisation();
    BankAccount account1 = new BankAccount();
    BankAccount account2 = new BankAccount();
    // expect
    context.checking(new Expectations() {

        {
            oneOf(mockFARepo).findAccountsByTypeOwner(FinancialAccountType.BANK_ACCOUNT, party);
            will(returnValue(Arrays.asList(account1, account2)));
        }
    });
    // when
    List<BankAccount> result = repo.findBankAccountsByOwner(party);
    Assertions.assertThat(result.size()).isEqualTo(2);
    Assertions.assertThat(result).contains(account1);
    Assertions.assertThat(result).contains(account2);
    // and given
    account2.setDeprecated(true);
    // expect
    context.checking(new Expectations() {

        {
            oneOf(mockFARepo).findAccountsByTypeOwner(FinancialAccountType.BANK_ACCOUNT, party);
            will(returnValue(Arrays.asList(account1, account2)));
        }
    });
    // when
    result = repo.findBankAccountsByOwner(party);
    Assertions.assertThat(result.size()).isEqualTo(1);
    Assertions.assertThat(result).contains(account1);
    Assertions.assertThat(result).doesNotContain(account2);
}
Also used : Expectations(org.jmock.Expectations) Party(org.estatio.module.party.dom.Party) 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