use of org.kie.workbench.common.forms.jbpm.model.document.DocumentData in project kie-wb-common by kiegroup.
the class DocumentCollectionFieldValueMarshallerTest method testAddingNewDocuments.
@Test
public void testAddingNewDocuments() {
Document doc = new DocumentImpl(DOCUMENT_ID, "docName", 1024, new Date(), "aLink");
documentCollection.addDocument(doc);
marshaller.init(documentCollection, field, form, context);
DocumentData data1 = new DocumentData(DOCUMENT_ID, doc.getName(), doc.getSize(), doc.getLink(), System.currentTimeMillis());
data1.setStatus(DocumentStatus.STORED);
DocumentData data2 = new DocumentData(DOCUMENT_ID2, DOCUMENT_ID2, 1024, "", System.currentTimeMillis());
DocumentData data3 = new DocumentData(DOCUMENT_ID3, DOCUMENT_ID3, 1024, "", System.currentTimeMillis());
DocumentCollection<Document> rawDocuments = marshaller.toRawValue(Arrays.asList(data1, data2, data3));
verify(documentStorage, times(2)).getContent(Mockito.<String>any());
verify(documentStorage, times(2)).removeContent(Mockito.<String>any());
Assertions.assertThat(rawDocuments).isNotSameAs(documentCollection).isInstanceOf(expectedType);
Assertions.assertThat(rawDocuments.getDocuments()).isNotNull().hasSize(3);
compareDoc(rawDocuments.getDocuments().get(0), data1);
compareDoc(rawDocuments.getDocuments().get(1), data2);
compareDoc(rawDocuments.getDocuments().get(2), data3);
}
use of org.kie.workbench.common.forms.jbpm.model.document.DocumentData in project kie-wb-common by kiegroup.
the class DocumentCollectionFieldValueMarshallerTest method testDocuments2FlatValueEmptyLinkPattern.
@Test
public void testDocuments2FlatValueEmptyLinkPattern() {
Document doc = new DocumentImpl(DOCUMENT_ID, "docName", 1024, new Date());
documentCollection.addDocument(doc);
marshaller.init(documentCollection, field, form, context);
Collection<DocumentData> documents = marshaller.toFlatValue();
Assertions.assertThat(documents).isNotNull().hasSize(1);
Assertions.assertThat(documents.iterator().next()).isNotNull().hasFieldOrPropertyWithValue("status", DocumentStatus.STORED).hasFieldOrPropertyWithValue("contentId", DOCUMENT_ID).hasFieldOrPropertyWithValue("fileName", doc.getName()).hasFieldOrPropertyWithValue("size", doc.getSize()).hasFieldOrPropertyWithValue("link", doc.getLink());
}
use of org.kie.workbench.common.forms.jbpm.model.document.DocumentData in project kie-wb-common by kiegroup.
the class DocumentFieldValueMarshallerTest method testDocument2FlatValueEmptyLinkPattern.
@Test
public void testDocument2FlatValueEmptyLinkPattern() {
Document doc = spy(new DocumentImpl(DOCUMENT_ID, "docName", 1024, new Date()));
marshaller.init(doc, field, form, context);
DocumentData documentData = marshaller.toFlatValue();
verify(doc).getLink();
assertNotNull(documentData);
assertEquals(doc.getName(), documentData.getFileName());
assertEquals(doc.getSize(), documentData.getSize());
assertEquals("", documentData.getLink());
}
Aggregations