use of org.kie.workbench.common.forms.dynamic.model.document.DocumentData in project kie-wb-common by kiegroup.
the class DocumentFieldValueProcessorTest method testNull2FlatValue.
@Test
public void testNull2FlatValue() {
DocumentData documentData = processor.toFlatValue(field, null, context);
assertNull("DocumentData must be null!", documentData);
}
use of org.kie.workbench.common.forms.dynamic.model.document.DocumentData in project kie-wb-common by kiegroup.
the class DocumentFieldValueProcessorTest method testDocument2FlatValue.
@Test
public void testDocument2FlatValue() {
Document doc = spy(new DocumentImpl(DOCUMENT_ID, "docName", 1024, new Date()));
Map result = new HashMap();
result.put(DocumentFieldValueProcessor.SERVER_TEMPLATE_ID, SERVER_TEMPLATE_ID);
when(context.getAttributes()).thenReturn(result);
DocumentData documentData = processor.toFlatValue(field, doc, context);
verify(doc, never()).getLink();
assertNotNull(documentData);
assertEquals(doc.getName(), documentData.getFileName());
assertEquals(doc.getSize(), documentData.getSize());
assertEquals(EXPECTED_DOWNLOAD_LINK, documentData.getLink());
}
use of org.kie.workbench.common.forms.dynamic.model.document.DocumentData in project kie-wb-common by kiegroup.
the class DocumentFieldValueProcessorTest method testNewFlatValue2Document.
@Test
public void testNewFlatValue2Document() {
DocumentData data = new DocumentData(DOCUMENT_ID, 1024, null);
data.setContentId("content");
Document doc = processor.toRawValue(field, data, null, context);
verify(uploadedDocumentManager).getFile(anyString());
verify(uploadedDocumentManager).removeFile(anyString());
assertNotNull("Document cannot be null!", doc);
assertEquals("Names are not equal", data.getFileName(), doc.getName());
assertEquals("Sizes are not equal", data.getSize(), doc.getSize());
}
Aggregations