Search in sources :

Example 6 with DocumentData

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);
}
Also used : DocumentData(org.kie.workbench.common.forms.dynamic.model.document.DocumentData) Test(org.junit.Test)

Example 7 with 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());
}
Also used : DocumentData(org.kie.workbench.common.forms.dynamic.model.document.DocumentData) HashMap(java.util.HashMap) Document(org.jbpm.document.Document) DocumentImpl(org.jbpm.document.service.impl.DocumentImpl) HashMap(java.util.HashMap) Map(java.util.Map) Date(java.util.Date) Test(org.junit.Test)

Example 8 with DocumentData

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());
}
Also used : DocumentData(org.kie.workbench.common.forms.dynamic.model.document.DocumentData) Document(org.jbpm.document.Document) Test(org.junit.Test)

Aggregations

DocumentData (org.kie.workbench.common.forms.dynamic.model.document.DocumentData)8 Test (org.junit.Test)5 Document (org.jbpm.document.Document)4 Date (java.util.Date)3 DocumentImpl (org.jbpm.document.service.impl.DocumentImpl)3 HashMap (java.util.HashMap)2 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)1 JSONObject (com.google.gwt.json.client.JSONObject)1 File (java.io.File)1 IOException (java.io.IOException)1 Map (java.util.Map)1 ServletException (javax.servlet.ServletException)1 FileItem (org.apache.commons.fileupload.FileItem)1