Search in sources :

Example 1 with ProjectItem_OrderedAmount

use of org.estatio.module.capex.dom.order.contributions.ProjectItem_OrderedAmount in project estatio by estatio.

the class ProjectItem_OrderedAmount_Test method orderedAmount_works.

@Test
public void orderedAmount_works() throws Exception {
    // given
    BigDecimal expectedTotalNetAmountOnItems = new BigDecimal("100.00");
    BigDecimal netAmountOnItem1 = new BigDecimal("55.00");
    BigDecimal netAmountOnItem2 = new BigDecimal("45.00");
    BigDecimal netAmountOnItem3 = null;
    ProjectItem projectItem = new ProjectItem();
    ProjectItem_OrderedAmount mixin = new ProjectItem_OrderedAmount(projectItem);
    mixin.orderItemRepository = mockOrderItemRepository;
    OrderItem orderItem1 = new OrderItem();
    orderItem1.setNetAmount(netAmountOnItem1);
    OrderItem orderItem2 = new OrderItem();
    orderItem2.setNetAmount(netAmountOnItem2);
    OrderItem orderItem3 = new OrderItem();
    orderItem3.setNetAmount(netAmountOnItem3);
    // expect
    context.checking(new Expectations() {

        {
            oneOf(mockOrderItemRepository).findByProjectAndCharge(null, null);
            will(returnValue(Arrays.asList(orderItem1, orderItem2, orderItem3)));
        }
    });
    // when
    BigDecimal orderedAmount = mixin.orderedAmount();
    // then
    Assertions.assertThat(orderedAmount).isEqualTo(expectedTotalNetAmountOnItems);
}
Also used : Expectations(org.jmock.Expectations) ProjectItem(org.estatio.module.capex.dom.project.ProjectItem) OrderItem(org.estatio.module.capex.dom.order.OrderItem) ProjectItem_OrderedAmount(org.estatio.module.capex.dom.order.contributions.ProjectItem_OrderedAmount) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

BigDecimal (java.math.BigDecimal)1 OrderItem (org.estatio.module.capex.dom.order.OrderItem)1 ProjectItem_OrderedAmount (org.estatio.module.capex.dom.order.contributions.ProjectItem_OrderedAmount)1 ProjectItem (org.estatio.module.capex.dom.project.ProjectItem)1 Expectations (org.jmock.Expectations)1 Test (org.junit.Test)1