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.");
}
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);
}
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);
}
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);
}
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");
}
Aggregations