Search in sources :

Example 26 with Party

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);
}
Also used : Party(org.estatio.module.party.dom.Party) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel) EmailAddress(org.incode.module.communications.dom.impl.commchannel.EmailAddress) Test(org.junit.Test)

Example 27 with Party

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;
    }
}
Also used : Party(org.estatio.module.party.dom.Party) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 28 with Party

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;
    }
}
Also used : Order(org.estatio.module.capex.dom.order.Order) Party(org.estatio.module.party.dom.Party) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 29 with Party

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);
}
Also used : Expectations(org.jmock.Expectations) Party(org.estatio.module.party.dom.Party) Organisation(org.estatio.module.party.dom.Organisation) BankAccount(org.estatio.module.financial.dom.BankAccount) BankAccountRepository(org.estatio.module.financial.dom.BankAccountRepository) Test(org.junit.Test)

Example 30 with Party

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();
}
Also used : Expectations(org.jmock.Expectations) Party(org.estatio.module.party.dom.Party) Organisation(org.estatio.module.party.dom.Organisation) ArrayList(java.util.ArrayList) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) BankAccount(org.estatio.module.financial.dom.BankAccount) Test(org.junit.Test)

Aggregations

Party (org.estatio.module.party.dom.Party)51 Programmatic (org.apache.isis.applib.annotation.Programmatic)22 Test (org.junit.Test)15 Property (org.estatio.module.asset.dom.Property)13 BankAccount (org.estatio.module.financial.dom.BankAccount)13 Organisation (org.estatio.module.party.dom.Organisation)13 IncomingInvoice (org.estatio.module.capex.dom.invoice.IncomingInvoice)10 Expectations (org.jmock.Expectations)10 AgreementRole (org.estatio.module.agreement.dom.AgreementRole)8 ArrayList (java.util.ArrayList)7 AgreementRoleType (org.estatio.module.agreement.dom.role.AgreementRoleType)7 Lease (org.estatio.module.lease.dom.Lease)6 CommunicationChannel (org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)6 List (java.util.List)5 Inject (javax.inject.Inject)4 Action (org.apache.isis.applib.annotation.Action)4 Country (org.incode.module.country.dom.impl.Country)4 LocalDate (org.joda.time.LocalDate)4 Optional (java.util.Optional)3 SortedSet (java.util.SortedSet)3