Search in sources :

Example 1 with Communication_downloadPdfForPosting

use of org.incode.module.communications.dom.impl.comms.Communication_downloadPdfForPosting in project estatio by estatio.

the class Smoke_IntegTest method can_create_postal_address.

@Test
public void can_create_postal_address() 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 mary = customerMenu.findDemoObjectsWithNotesByName(DemoObjectWithNote_and_DemoInvoice_create3.MARY_HAS_PHONE_AND_POST).get(0);
    final PostalAddress maryPost = (PostalAddress) linkRepository.findByOwnerAndCommunicationChannelType(mary, CommunicationChannelType.POSTAL_ADDRESS).get(0).getCommunicationChannel();
    // and with an invoice
    final DemoInvoice fredInvoice = invoiceRepository.findByCustomer(mary).get(0);
    // that has an attached document
    final Paperclip paperclip = paperclipRepository.findByAttachedTo(fredInvoice).get(0);
    final DocumentAbstract document = paperclip.getDocument();
    // when
    final Document_sendByPost documentPrint = mixin(Document_sendByPost.class, document);
    final Set<PostalAddress> postalAddresses = documentPrint.choices0Act();
    // then
    assertThat(postalAddresses).contains(maryPost);
    // and when
    final Communication comm = wrap(documentPrint).act(maryPost);
    // then
    assertThat(comm).isNotNull();
    assertThat(comm.getState()).isEqualTo(CommunicationState.PENDING);
    // same as emails
    assertThat(comm.getCreatedAt()).isNotNull();
    assertThat(comm.getType()).isEqualTo(CommunicationChannelType.POSTAL_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(maryPost);
    // when
    final Communication_downloadPdfForPosting mixin = mixin(Communication_downloadPdfForPosting.class, comm);
    wrap(mixin).act(mixin.default0Act());
    // then
    assertThat(comm.getState()).isEqualTo(CommunicationState.SENT);
    assertThat(comm.getSentAt()).isNotNull();
}
Also used : Paperclip(org.incode.module.document.dom.impl.paperclips.Paperclip) DocumentAbstract(org.incode.module.document.dom.impl.docs.DocumentAbstract) DemoInvoice(org.incode.platform.dom.communications.integtests.demo.dom.invoice.DemoInvoice) CommChannelRole(org.incode.module.communications.dom.impl.comms.CommChannelRole) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel) DemoObjectWithNotes(org.incode.platform.dom.communications.integtests.demo.dom.demowithnotes.DemoObjectWithNotes) Communication_downloadPdfForPosting(org.incode.module.communications.dom.impl.comms.Communication_downloadPdfForPosting) PostalAddress(org.incode.module.communications.dom.impl.commchannel.PostalAddress) Document_sendByPost(org.incode.module.communications.dom.mixins.Document_sendByPost) 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) Communication(org.incode.module.communications.dom.impl.comms.Communication) Test(org.junit.Test)

Aggregations

CommunicationChannel (org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)1 PostalAddress (org.incode.module.communications.dom.impl.commchannel.PostalAddress)1 CommChannelRole (org.incode.module.communications.dom.impl.comms.CommChannelRole)1 Communication (org.incode.module.communications.dom.impl.comms.Communication)1 Communication_downloadPdfForPosting (org.incode.module.communications.dom.impl.comms.Communication_downloadPdfForPosting)1 Document_sendByPost (org.incode.module.communications.dom.mixins.Document_sendByPost)1 DocumentAbstract (org.incode.module.document.dom.impl.docs.DocumentAbstract)1 Paperclip (org.incode.module.document.dom.impl.paperclips.Paperclip)1 DemoObjectWithNotes (org.incode.platform.dom.communications.integtests.demo.dom.demowithnotes.DemoObjectWithNotes)1 DemoInvoice (org.incode.platform.dom.communications.integtests.demo.dom.invoice.DemoInvoice)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 Test (org.junit.Test)1