use of org.estatio.module.party.dom.Party in project estatio by estatio.
the class CommunicationChannelContributions_NewEmail_IntegTest method happyCase.
@Test
public void happyCase() throws Exception {
final Party party = fs.getObject();
// given
final SortedSet<CommunicationChannel> before = communicationChannelContributions.communicationChannels(party);
Assertions.assertThat(before).isEmpty();
// when
final String emailAddress = "bar@foo.com";
wrap(communicationChannelContributions).newEmail(party, CommunicationChannelType.EMAIL_ADDRESS, emailAddress);
// then
final SortedSet<CommunicationChannel> after = communicationChannelContributions.communicationChannels(party);
Assertions.assertThat(after).hasSize(1);
final CommunicationChannel communicationChannel = after.first();
Assertions.assertThat(communicationChannel).isInstanceOf(EmailAddress.class);
Assertions.assertThat(((EmailAddress) communicationChannel).getEmailAddress()).isEqualTo(emailAddress);
}
use of org.estatio.module.party.dom.Party in project estatio by estatio.
the class PartySubscriptionsForOrders method on.
@Programmatic
@com.google.common.eventbus.Subscribe
@org.axonframework.eventhandling.annotation.EventHandler
public void on(final Party.FixEvent ev) {
switch(ev.getEventPhase()) {
case EXECUTING:
Party sourceParty = ev.getSource();
if (orderRepository.findBySellerParty(sourceParty).size() > 0) {
sourceParty.addRole(Constants.InvoiceRoleTypeEnum.SELLER);
sourceParty.addRole(IncomingInvoiceRoleTypeEnum.SUPPLIER);
}
break;
default:
break;
}
}
use of org.estatio.module.party.dom.Party in project estatio by estatio.
the class PartySubscriptionsForOrders method on.
@Programmatic
@com.google.common.eventbus.Subscribe
@org.axonframework.eventhandling.annotation.EventHandler
public void on(final Party.DeleteEvent ev) {
Party sourceParty = (Party) ev.getSource();
Party replacementParty = ev.getReplacement();
switch(ev.getEventPhase()) {
case VALIDATE:
if (replacementParty == null && orderRepository.findBySellerParty(sourceParty).size() > 0) {
ev.invalidate("Party is in use as seller in an order. Provide replacement");
}
break;
case EXECUTING:
if (replacementParty != null) {
for (Order order : orderRepository.findBySellerParty(sourceParty)) {
order.setSeller(replacementParty);
}
}
break;
default:
break;
}
}
use of org.estatio.module.party.dom.Party in project estatio by estatio.
the class IncomingDocAsInvoiceViewModel_autoCompleteBankAccount_Test method autoCompleteBankAccount_works.
@Test
public void autoCompleteBankAccount_works() throws Exception {
List<BankAccount> result;
// given
IncomingDocAsInvoiceViewModel vm = new IncomingDocAsInvoiceViewModel() {
IncomingDocAsInvoiceViewModel setBankAccountRepository(BankAccountRepository bankAccountRepository) {
this.bankAccountRepository = bankAccountRepository;
return this;
}
}.setBankAccountRepository(mockBankAccountRepository);
BankAccount acc1 = new BankAccount();
BankAccount acc2 = new BankAccount();
Party owner = new Organisation();
acc2.setOwner(owner);
// expect
context.checking(new Expectations() {
{
allowing(mockBankAccountRepository).autoComplete(with(any(String.class)));
will(returnValue(Arrays.asList(acc1, acc2)));
oneOf(mockBankAccountRepository).findBankAccountsByOwner(owner);
will(returnValue(Arrays.asList(acc2)));
}
});
// when
result = vm.autoCompleteBankAccount("some searchstring");
// then
assertThat(result.size()).isEqualTo(2);
// and when seller is set
vm.setSeller(owner);
result = vm.autoCompleteBankAccount("3");
// then
assertThat(result.size()).isEqualTo(1);
assertThat(result.get(0)).isEqualTo(acc2);
}
use of org.estatio.module.party.dom.Party in project estatio by estatio.
the class DebtorBankAccountService_Test method unique_Debtor_Account_To_Pay_works_when_multiple_bankaccounts_multiple_preferred.
@Test
public void unique_Debtor_Account_To_Pay_works_when_multiple_bankaccounts_multiple_preferred() throws Exception {
// given
DebtorBankAccountService service = new DebtorBankAccountService();
service.bankAccountRepository = mockBankAccountRepository;
BankAccount bankAccount1 = new BankAccount();
bankAccount1.setPreferred(true);
BankAccount bankAccount2 = new BankAccount();
bankAccount2.setPreferred(true);
List<BankAccount> bankAccounts = new ArrayList<>();
bankAccounts.add(bankAccount1);
bankAccounts.add(bankAccount2);
IncomingInvoice invoice = new IncomingInvoice();
Party debtor = new Organisation();
invoice.setBuyer(debtor);
// expect
context.checking(new Expectations() {
{
oneOf(mockBankAccountRepository).findBankAccountsByOwner(debtor);
will(returnValue(bankAccounts));
}
});
// when, then
assertThat(service.uniqueDebtorAccountToPay(invoice)).isNull();
}
Aggregations