Search in sources :

Example 56 with Document

use of org.incode.module.document.dom.impl.docs.Document in project estatio by estatio.

the class Order_2_IntegTest method orderFixtureLoadedProperly.

@Test
public void orderFixtureLoadedProperly() throws Exception {
    assertThat(orderRepository.listAll().size()).isEqualTo(1);
    List<Document> unclassifiedIncomingOrders = incomingDocumentRepository.findUnclassifiedIncomingOrders();
    assertThat(unclassifiedIncomingOrders.size()).isEqualTo(0);
    final String documentName = Order_enum.fakeOrder2Pdf.getDocument_d().findUsing(serviceRegistry).getName();
    Document document = incomingDocumentRepository.findAllIncomingDocumentsByName(documentName).get(0);
    List<IncomingDocumentCategorisationStateTransition> transitions = mixin(Document_categorisationTransitions.class, document).coll();
    assertThat(transitions.size()).isEqualTo(2);
}
Also used : Document_categorisationTransitions(org.estatio.module.capex.dom.documents.categorisation.transitions.Document_categorisationTransitions) IncomingDocumentCategorisationStateTransition(org.estatio.module.capex.dom.documents.categorisation.IncomingDocumentCategorisationStateTransition) Document(org.incode.module.document.dom.impl.docs.Document) Test(org.junit.Test)

Example 57 with Document

use of org.incode.module.document.dom.impl.docs.Document in project estatio by estatio.

the class DocumentMenu_Upload_IntegTest method happy_case.

@Test
public void happy_case() throws Exception {
    // given
    List<Document> incomingDocumentsBefore = repository.findIncomingDocuments();
    assertThat(incomingDocumentsBefore).isEmpty();
    // when
    final String fileName = "1020100123.pdf";
    final byte[] pdfBytes = Resources.toByteArray(Resources.getResource(DocumentMenu_Upload_IntegTest.class, fileName));
    final Blob blob = new Blob(fileName, "application/pdf", pdfBytes);
    wrap(documentMenu).upload(blob);
    transactionService.nextTransaction();
    // then
    List<Document> incomingDocumentsAfter = repository.findAllIncomingDocuments();
    assertThat(incomingDocumentsAfter).hasSize(1);
    final Document document = incomingDocumentsAfter.get(0);
    final Blob documentBlob = document.getBlob();
    assertThat(documentBlob.getName()).isEqualTo(blob.getName());
    assertThat(documentBlob.getMimeType().getBaseType()).isEqualTo(blob.getMimeType().getBaseType());
    assertThat(documentBlob.getBytes()).isEqualTo(blob.getBytes());
    assertThat(JDOHelper.getVersion(document)).isEqualTo(1L);
    assertThat(paperclipRepository.findByDocument(document).size()).isEqualTo(0);
    // and then also
    final List<IncomingDocumentCategorisationStateTransition> transitions = stateTransitionRepository.findByDomainObject(document);
    assertThat(transitions).hasSize(2);
    assertTransition(transitions.get(0), NEW, CATEGORISE, null);
    assertTransition(transitions.get(1), null, INSTANTIATE, NEW);
    // and when
    final String fileName2 = "1020100123-altered.pdf";
    final byte[] pdfBytes2 = Resources.toByteArray(Resources.getResource(DocumentMenu_Upload_IntegTest.class, fileName2));
    final Blob similarNamedBlob = new Blob(fileName, "application/pdf", pdfBytes2);
    wrap(documentMenu).upload(similarNamedBlob);
    transactionService.nextTransaction();
    // then
    incomingDocumentsAfter = repository.findAllIncomingDocuments();
    assertThat(incomingDocumentsAfter).hasSize(2);
    assertThat(incomingDocumentsAfter.get(0).getName()).isEqualTo(fileName);
    assertThat(incomingDocumentsAfter.get(0).getBlobBytes()).isEqualTo(similarNamedBlob.getBytes());
    assertThat(JDOHelper.getVersion(incomingDocumentsAfter.get(0))).isEqualTo(2L);
    assertThat(paperclipRepository.findByDocument(incomingDocumentsAfter.get(0)).size()).isEqualTo(1);
    // has prefix arch-[date time indication]-
    assertThat(incomingDocumentsAfter.get(1).getName()).contains(fileName);
    assertThat(incomingDocumentsAfter.get(1).getBlobBytes()).isEqualTo(documentBlob.getBytes());
    assertThat(JDOHelper.getVersion(incomingDocumentsAfter.get(1))).isEqualTo(1L);
    assertThat(paperclipRepository.findByDocument(incomingDocumentsAfter.get(1)).size()).isEqualTo(0);
}
Also used : Blob(org.apache.isis.applib.value.Blob) IncomingDocumentCategorisationStateTransition(org.estatio.module.capex.dom.documents.categorisation.IncomingDocumentCategorisationStateTransition) Document(org.incode.module.document.dom.impl.docs.Document) Test(org.junit.Test)

Aggregations

Document (org.incode.module.document.dom.impl.docs.Document)57 Action (org.apache.isis.applib.annotation.Action)23 ActionLayout (org.apache.isis.applib.annotation.ActionLayout)22 Programmatic (org.apache.isis.applib.annotation.Programmatic)8 Blob (org.apache.isis.applib.value.Blob)7 IncomingInvoice (org.estatio.module.capex.dom.invoice.IncomingInvoice)7 DocumentAbstract (org.incode.module.document.dom.impl.docs.DocumentAbstract)7 MemberOrder (org.apache.isis.applib.annotation.MemberOrder)5 Paperclip (org.incode.module.document.dom.impl.paperclips.Paperclip)5 IncomingDocumentCategorisationStateTransition (org.estatio.module.capex.dom.documents.categorisation.IncomingDocumentCategorisationStateTransition)4 Bookmark (org.apache.isis.applib.services.bookmark.Bookmark)3 BuyerFinder (org.estatio.module.capex.dom.documents.BuyerFinder)3 Communication (org.incode.module.communications.dom.impl.comms.Communication)3 DocumentTemplate (org.incode.module.document.dom.impl.docs.DocumentTemplate)3 Expectations (org.jmock.Expectations)3 TitleBuffer (org.apache.isis.applib.util.TitleBuffer)2 IncomingDocAsOrderViewModel (org.estatio.module.capex.app.order.IncomingDocAsOrderViewModel)2 Order (org.estatio.module.capex.dom.order.Order)2 BankAccount (org.estatio.module.financial.dom.BankAccount)2 DocumentTypeData (org.estatio.module.invoice.dom.DocumentTypeData)2