Search in sources :

Example 1 with EmailAddress

use of org.incode.module.communications.dom.impl.commchannel.EmailAddress in project estatio by estatio.

the class Document_sendByEmail method default0Act.

public EmailAddress default0Act() {
    final EmailAddress toDefault = determineEmailHeader().getToDefault();
    if (toDefault != null) {
        return toDefault;
    }
    final Set<EmailAddress> choices = choices0Act();
    return choices.isEmpty() ? null : choices.iterator().next();
}
Also used : EmailAddress(org.incode.module.communications.dom.impl.commchannel.EmailAddress)

Example 2 with EmailAddress

use of org.incode.module.communications.dom.impl.commchannel.EmailAddress 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 3 with EmailAddress

use of org.incode.module.communications.dom.impl.commchannel.EmailAddress in project estatio by estatio.

the class CommunicationChannelSubscription_Integtest method setUp.

@Before
public void setUp() throws Exception {
    // given
    fixtureScripts.runFixtureScript(new DemoObjectWithNotes_and_DemoInvoice_and_docs_and_comms_recreate(), null);
    transactionService.nextTransaction();
    // and so given customer with an email
    final DemoObjectWithNotes fred = customerMenu.findDemoObjectsWithNotesByName(DemoObjectWithNote_and_DemoInvoice_create3.FRED_HAS_EMAIL_AND_PHONE).get(0);
    final EmailAddress fredEmail = (EmailAddress) linkRepository.findByOwnerAndCommunicationChannelType(fred, CommunicationChannelType.EMAIL_ADDRESS).get(0).getCommunicationChannel();
}
Also used : DemoObjectWithNotes_and_DemoInvoice_and_docs_and_comms_recreate(org.incode.platform.dom.communications.integtests.dom.communications.fixture.DemoObjectWithNotes_and_DemoInvoice_and_docs_and_comms_recreate) EmailAddress(org.incode.module.communications.dom.impl.commchannel.EmailAddress) DemoObjectWithNotes(org.incode.platform.dom.communications.integtests.demo.dom.demowithnotes.DemoObjectWithNotes) Before(org.junit.Before)

Example 4 with EmailAddress

use of org.incode.module.communications.dom.impl.commchannel.EmailAddress in project estatio by estatio.

the class InvoiceSummaryForPropertyDueDateStatus_sendByEmailAbstract method $$.

@Action(semantics = SemanticsOf.NON_IDEMPOTENT_ARE_YOU_SURE)
@ActionLayout(contributed = Contributed.AS_ACTION)
public InvoiceSummaryForPropertyDueDateStatus $$() throws IOException {
    final List<InvoiceAndDocument> invoiceAndDocuments = invoiceAndDocumentsToSend();
    for (InvoiceAndDocument invoiceAndDocument : invoiceAndDocuments) {
        final Invoice invoice = invoiceAndDocument.getInvoice();
        final Document document = invoiceAndDocument.getDocument();
        final InvoiceForLease_sendByEmail invoice_sendByEmail = invoice_email(invoice);
        final EmailAddress emailAddress = invoice_sendByEmail.default1$$(document);
        final String cc = invoice_sendByEmail.default2$$(document);
        final String bcc = invoice_sendByEmail.default5$$(document);
        invoice_sendByEmail.$$(document, emailAddress, cc, null, null, bcc, null);
    }
    return this.invoiceSummary;
}
Also used : Invoice(org.estatio.module.invoice.dom.Invoice) InvoiceForLease_sendByEmail(org.estatio.module.lease.dom.invoicing.comms.InvoiceForLease_sendByEmail) Document(org.incode.module.document.dom.impl.docs.Document) EmailAddress(org.incode.module.communications.dom.impl.commchannel.EmailAddress) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 5 with EmailAddress

use of org.incode.module.communications.dom.impl.commchannel.EmailAddress in project estatio by estatio.

the class Smoke_IntegTest method can_send_email.

@Test
public void can_send_email() throws Exception {
    // given
    fixtureScripts.runFixtureScript(new CommandDomModule().getTeardownFixtureWillDelete(), null);
    fixtureScripts.runFixtureScript(new DemoObjectWithNotes_and_DemoInvoice_and_docs_and_comms_create(), null);
    transactionService.nextTransaction();
    // and so given customer with an email
    final DemoObjectWithNotes fred = customerMenu.findDemoObjectsWithNotesByName(DemoObjectWithNote_and_DemoInvoice_create3.FRED_HAS_EMAIL_AND_PHONE).get(0);
    final EmailAddress fredEmail = (EmailAddress) linkRepository.findByOwnerAndCommunicationChannelType(fred, CommunicationChannelType.EMAIL_ADDRESS).get(0).getCommunicationChannel();
    // and with an invoice
    final DemoInvoice fredInvoice = invoiceRepository.findByCustomer(fred).get(0);
    // that has an attached document
    final Paperclip paperclip = paperclipRepository.findByAttachedTo(fredInvoice).get(0);
    final DocumentAbstract document = paperclip.getDocument();
    // when
    final Document_sendByEmail documentEmail = mixin(Document_sendByEmail.class, document);
    final Set<EmailAddress> emailAddresses = documentEmail.choices0Act();
    // then
    assertThat(emailAddresses).contains(fredEmail);
    // and when
    // REVIEW: should be wrapped, however the DocumentCommunicationSupportForDocumentsAttachedToInvoiceForLease
    // vetoes this, and there is current no way to exclude classes that are not part of the "effective" module
    // final Communication comm = wrap(documentEmail).act(fredEmail, null, null, null, null, null);
    final Communication comm = documentEmail.act(fredEmail, null, null, null, null, null);
    // then
    assertThat(comm).isNotNull();
    assertThat(comm.getState()).isEqualTo(CommunicationState.PENDING);
    assertThat(comm.getCreatedAt()).isNotNull();
    assertThat(comm.getType()).isEqualTo(CommunicationChannelType.EMAIL_ADDRESS);
    assertThat(comm.getSubject()).isNotNull();
    assertThat(comm.getSentAt()).isNull();
    final List<CommunicationChannel> correspondentChannels = Lists.newArrayList(comm.getCorrespondents()).stream().map(CommChannelRole::getChannel).filter(Objects::nonNull).collect(Collectors.toList());
    assertThat(correspondentChannels).contains(fredEmail);
    List<EmailMessage> emailMessages = fakeEmailService.listSentEmails();
    assertThat(emailMessages).isEmpty();
    List<CommandJdo> commands = backgroundCommandRepository.findBackgroundCommandsNotYetStarted();
    assertThat(commands.size()).isEqualTo(1);
    // when
    fakeScheduler.runBackgroundCommands(5000);
    // then
    assertThat(comm.getState()).isEqualTo(CommunicationState.SENT);
    assertThat(comm.getSentAt()).isNotNull();
    emailMessages = fakeEmailService.listSentEmails();
    assertThat(emailMessages).isNotEmpty();
}
Also used : Paperclip(org.incode.module.document.dom.impl.paperclips.Paperclip) DocumentAbstract(org.incode.module.document.dom.impl.docs.DocumentAbstract) EmailMessage(org.incode.platform.dom.communications.integtests.app.services.fakeemail.EmailMessage) CommandJdo(org.isisaddons.module.command.dom.CommandJdo) DemoInvoice(org.incode.platform.dom.communications.integtests.demo.dom.invoice.DemoInvoice) CommChannelRole(org.incode.module.communications.dom.impl.comms.CommChannelRole) EmailAddress(org.incode.module.communications.dom.impl.commchannel.EmailAddress) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel) DemoObjectWithNotes(org.incode.platform.dom.communications.integtests.demo.dom.demowithnotes.DemoObjectWithNotes) Document_sendByEmail(org.incode.module.communications.dom.mixins.Document_sendByEmail) CommandDomModule(org.isisaddons.module.command.dom.CommandDomModule) DemoObjectWithNotes_and_DemoInvoice_and_docs_and_comms_create(org.incode.platform.dom.communications.integtests.dom.communications.fixture.DemoObjectWithNotes_and_DemoInvoice_and_docs_and_comms_create) Communication(org.incode.module.communications.dom.impl.comms.Communication) Test(org.junit.Test)

Aggregations

EmailAddress (org.incode.module.communications.dom.impl.commchannel.EmailAddress)5 CommunicationChannel (org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)2 DemoObjectWithNotes (org.incode.platform.dom.communications.integtests.demo.dom.demowithnotes.DemoObjectWithNotes)2 Test (org.junit.Test)2 Action (org.apache.isis.applib.annotation.Action)1 ActionLayout (org.apache.isis.applib.annotation.ActionLayout)1 Invoice (org.estatio.module.invoice.dom.Invoice)1 InvoiceForLease_sendByEmail (org.estatio.module.lease.dom.invoicing.comms.InvoiceForLease_sendByEmail)1 Party (org.estatio.module.party.dom.Party)1 CommChannelRole (org.incode.module.communications.dom.impl.comms.CommChannelRole)1 Communication (org.incode.module.communications.dom.impl.comms.Communication)1 Document_sendByEmail (org.incode.module.communications.dom.mixins.Document_sendByEmail)1 Document (org.incode.module.document.dom.impl.docs.Document)1 DocumentAbstract (org.incode.module.document.dom.impl.docs.DocumentAbstract)1 Paperclip (org.incode.module.document.dom.impl.paperclips.Paperclip)1 EmailMessage (org.incode.platform.dom.communications.integtests.app.services.fakeemail.EmailMessage)1 DemoInvoice (org.incode.platform.dom.communications.integtests.demo.dom.invoice.DemoInvoice)1 DemoObjectWithNotes_and_DemoInvoice_and_docs_and_comms_create (org.incode.platform.dom.communications.integtests.dom.communications.fixture.DemoObjectWithNotes_and_DemoInvoice_and_docs_and_comms_create)1 DemoObjectWithNotes_and_DemoInvoice_and_docs_and_comms_recreate (org.incode.platform.dom.communications.integtests.dom.communications.fixture.DemoObjectWithNotes_and_DemoInvoice_and_docs_and_comms_recreate)1 CommandDomModule (org.isisaddons.module.command.dom.CommandDomModule)1