use of org.estatio.module.capex.dom.project.ProjectItem 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);
}
use of org.estatio.module.capex.dom.project.ProjectItem in project estatio by estatio.
the class ProjectItem_InvoicedAmount_Test method invoicedAmount_works.
@Test
public void invoicedAmount_works() throws Exception {
// given
BigDecimal expectedTotalInvoicedNetAmountOnItems = new BigDecimal("100.00");
BigDecimal netAmountOnItem1 = new BigDecimal("55.00");
BigDecimal netAmountOnItem2 = new BigDecimal("45.00");
BigDecimal netAmountOnItem3_discarded = new BigDecimal("12345.67");
ProjectItem projectItem = new ProjectItem();
ProjectItem_InvoicedAmount mixin = new ProjectItem_InvoicedAmount(projectItem);
mixin.incomingInvoiceItemRepository = mockIncomingInvoiceItemRepository;
IncomingInvoiceItem item1 = new IncomingInvoiceItem();
item1.setInvoice(newIncomingInvoice());
item1.setNetAmount(netAmountOnItem1);
IncomingInvoiceItem item2 = new IncomingInvoiceItem();
item2.setInvoice(newIncomingInvoice());
item2.setNetAmount(netAmountOnItem2);
IncomingInvoiceItem item3_discarded = new IncomingInvoiceItem() {
@Override
public boolean isDiscarded() {
return true;
}
};
item3_discarded.setInvoice(newIncomingInvoice());
item3_discarded.setNetAmount(netAmountOnItem3_discarded);
// expect
context.checking(new Expectations() {
{
oneOf(mockIncomingInvoiceItemRepository).findByProjectAndCharge(null, null);
will(returnValue(Arrays.asList(item1, item2, item3_discarded)));
}
});
// when
BigDecimal orderedAmount = mixin.invoicedAmount();
// then
Assertions.assertThat(orderedAmount).isEqualTo(expectedTotalInvoicedNetAmountOnItems);
}
use of org.estatio.module.capex.dom.project.ProjectItem in project estatio by estatio.
the class OrderItemRepository_Test method orderItemsWithoutProjectItem_works.
@Test
public void orderItemsWithoutProjectItem_works() throws Exception {
// given
Project project = new Project();
ProjectItem item1 = new ProjectItem();
Charge chargeOnProjectItem = new Charge();
item1.setCharge(chargeOnProjectItem);
project.getItems().add(item1);
Charge chargeNOTOnProjectItem = new Charge();
OrderItem orderItemToBeFound = new OrderItem();
orderItemToBeFound.setCharge(chargeNOTOnProjectItem);
OrderItem orderItemNOTToBeFound = new OrderItem();
orderItemNOTToBeFound.setCharge(chargeOnProjectItem);
OrderItemRepository orderItemRepository = new OrderItemRepository() {
@Override
public List<OrderItem> findByProject(final Project project) {
return Arrays.asList(orderItemNOTToBeFound, orderItemToBeFound);
}
};
// when
List<OrderItem> result = orderItemRepository.orderItemsNotOnProjectItem(project);
// then
Assertions.assertThat(result.size()).isEqualTo(1);
Assertions.assertThat(result.get(0)).isEqualTo(orderItemToBeFound);
Assertions.assertThat(result.get(0).getCharge()).isEqualTo(chargeNOTOnProjectItem);
}
Aggregations