Search in sources :

Example 1 with DisabledException

use of org.apache.isis.applib.services.wrapper.DisabledException in project estatio by estatio.

the class InvoiceSummaryAbstract method validate0InvoiceAll.

public String validate0InvoiceAll(final LocalDate invoiceDate) {
    for (Invoice invoice : getInvoices()) {
        try {
            final InvoiceForLease._invoice mixin = mixin(InvoiceForLease._invoice.class, invoice);
            wrapperFactory.wrapNoExecute(mixin).$$(invoiceDate);
        } catch (InvalidException ex) {
            final String reasonMessage = ex.getInteractionEvent() != null ? ex.getInteractionEvent().getReason() : null;
            return titleService.titleOf(invoice) + ": " + (reasonMessage != null ? reasonMessage : ex.getMessage());
        } catch (HiddenException | DisabledException ex) {
        // ignore
        }
    }
    return null;
}
Also used : Invoice(org.estatio.module.invoice.dom.Invoice) InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) DisabledException(org.apache.isis.applib.services.wrapper.DisabledException) InvalidException(org.apache.isis.applib.services.wrapper.InvalidException) HiddenException(org.apache.isis.applib.services.wrapper.HiddenException)

Example 2 with DisabledException

use of org.apache.isis.applib.services.wrapper.DisabledException in project estatio by estatio.

the class IncomingInvoiceApprovalState_IntegTest method complete_should_fail_when_not_having_appropriate_role_type_test.

@Test
public void complete_should_fail_when_not_having_appropriate_role_type_test() {
    Exception error = new Exception();
    // given
    Person personEmmaWithNoRoleAsPropertyManager = (Person) partyRepository.findPartyByReference(Person_enum.EmmaTreasurerGb.getRef());
    SortedSet<PartyRole> rolesforEmma = personEmmaWithNoRoleAsPropertyManager.getRoles();
    assertThat(rolesforEmma.size()).isEqualTo(1);
    assertThat(rolesforEmma.first().getRoleType()).isEqualTo(partyRoleTypeRepository.findByKey(PartyRoleTypeEnum.TREASURER.getKey()));
    // when
    try {
        // workaround: clear MeService#me cache
        queryResultsCache.resetForNextTransaction();
        sudoService.sudo(Person_enum.EmmaTreasurerGb.getRef().toLowerCase(), (Runnable) () -> wrap(mixin(IncomingInvoice_complete.class, incomingInvoice)).act("PROPERTY_MANAGER", null, null));
    } catch (DisabledException e) {
        error = e;
    }
    assertThat(error.getMessage()).isNotNull();
    assertThat(error.getMessage()).contains("Reason: Task assigned to 'PROPERTY_MANAGER' role");
}
Also used : PartyRole(org.estatio.module.party.dom.role.PartyRole) DisabledException(org.apache.isis.applib.services.wrapper.DisabledException) Person(org.estatio.module.party.dom.Person) DisabledException(org.apache.isis.applib.services.wrapper.DisabledException) Test(org.junit.Test)

Example 3 with DisabledException

use of org.apache.isis.applib.services.wrapper.DisabledException in project estatio by estatio.

the class IncomingInvoiceApprovalState_IntegTest method complete_works_when_having_appropriate_role_type_test.

@Test
public void complete_works_when_having_appropriate_role_type_test() {
    Exception error = new Exception();
    // given
    Person personEmma = (Person) partyRepository.findPartyByReference(Person_enum.EmmaTreasurerGb.getRef());
    PartyRoleType roleAsPropertyManager = partyRoleTypeRepository.findByKey("PROPERTY_MANAGER");
    personEmma.addRole(roleAsPropertyManager);
    transactionService.nextTransaction();
    SortedSet<PartyRole> rolesforEmma = personEmma.getRoles();
    assertThat(rolesforEmma.size()).isEqualTo(2);
    assertThat(rolesforEmma.first().getRoleType()).isEqualTo(partyRoleTypeRepository.findByKey("PROPERTY_MANAGER"));
    // when
    try {
        // workaround: clear MeService#me cache
        queryResultsCache.resetForNextTransaction();
        sudoService.sudo(Person_enum.EmmaTreasurerGb.getRef().toLowerCase(), (Runnable) () -> wrap(mixin(IncomingInvoice_complete.class, incomingInvoice)).act("PROPERTY_MANAGER", null, null));
    } catch (DisabledException e) {
        error = e;
    }
    assertThat(error.getMessage()).isNull();
    assertThat(incomingInvoice.getApprovalState()).isEqualTo(IncomingInvoiceApprovalState.COMPLETED);
}
Also used : PartyRole(org.estatio.module.party.dom.role.PartyRole) DisabledException(org.apache.isis.applib.services.wrapper.DisabledException) PartyRoleType(org.estatio.module.party.dom.role.PartyRoleType) Person(org.estatio.module.party.dom.Person) DisabledException(org.apache.isis.applib.services.wrapper.DisabledException) Test(org.junit.Test)

Aggregations

DisabledException (org.apache.isis.applib.services.wrapper.DisabledException)3 Person (org.estatio.module.party.dom.Person)2 PartyRole (org.estatio.module.party.dom.role.PartyRole)2 Test (org.junit.Test)2 HiddenException (org.apache.isis.applib.services.wrapper.HiddenException)1 InvalidException (org.apache.isis.applib.services.wrapper.InvalidException)1 Invoice (org.estatio.module.invoice.dom.Invoice)1 InvoiceForLease (org.estatio.module.lease.dom.invoicing.InvoiceForLease)1 PartyRoleType (org.estatio.module.party.dom.role.PartyRoleType)1