Search in sources :

Example 6 with DocumentUploadChunk

use of org.kie.workbench.common.forms.jbpm.service.shared.documents.DocumentUploadChunk in project kie-wb-common by kiegroup.

the class UploadedDocumentServiceImplTest method testMergeWithError.

@Test
public void testMergeWithError() throws Exception {
    doThrow(new RuntimeException("Exception")).when(storage).merge(any());
    DocumentUploadChunk chunk = new DocumentUploadChunk(DOC_ID, DOC_NAME, 0, 1, Base64.getEncoder().encodeToString(PART_1.getBytes()));
    DocumentUploadResponse response = uploadedDocumentService.uploadContent(chunk);
    validateResponse(response, DocumentUploadResponse.DocumentUploadState.FINISH, false);
}
Also used : DocumentUploadResponse(org.kie.workbench.common.forms.jbpm.service.shared.documents.DocumentUploadResponse) DocumentUploadChunk(org.kie.workbench.common.forms.jbpm.service.shared.documents.DocumentUploadChunk) Test(org.junit.Test)

Example 7 with DocumentUploadChunk

use of org.kie.workbench.common.forms.jbpm.service.shared.documents.DocumentUploadChunk in project kie-wb-common by kiegroup.

the class UploadedDocumentServiceImplTest method testAbortUpload.

@Test
public void testAbortUpload() {
    DocumentUploadChunk chunk = new DocumentUploadChunk(DOC_ID, DOC_NAME, 0, 3, Base64.getEncoder().encodeToString(PART_1.getBytes()));
    DocumentUploadResponse response = uploadedDocumentService.uploadContent(chunk);
    validateResponse(response, DocumentUploadResponse.DocumentUploadState.UPLOADING, true);
    DocumentUploadSession session = uploadedDocumentService.getUploadSessions().get(DOC_ID);
    Assertions.assertThat(session).isNotNull();
    Assertions.assertThat(session.getChunks()).isNotNull().hasSize(1).containsExactly(chunk);
    checkParts(1);
    uploadedDocumentService.removeContent(DOC_ID);
    assertEquals(DocumentUploadSession.State.ABORTED, session.getState());
}
Also used : DocumentUploadResponse(org.kie.workbench.common.forms.jbpm.service.shared.documents.DocumentUploadResponse) DocumentUploadChunk(org.kie.workbench.common.forms.jbpm.service.shared.documents.DocumentUploadChunk) Test(org.junit.Test)

Aggregations

DocumentUploadChunk (org.kie.workbench.common.forms.jbpm.service.shared.documents.DocumentUploadChunk)7 Test (org.junit.Test)4 DocumentUploadResponse (org.kie.workbench.common.forms.jbpm.service.shared.documents.DocumentUploadResponse)4 File (java.io.File)2 FileReader (elemental2.dom.FileReader)1 BufferedOutputStream (java.io.BufferedOutputStream)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 ServletException (javax.servlet.ServletException)1 FileItem (org.apache.commons.fileupload.FileItem)1 ErrorCallback (org.jboss.errai.common.client.api.ErrorCallback)1 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)1 DocumentData (org.kie.workbench.common.forms.jbpm.model.document.DocumentData)1 DocumentUploadSession (org.kie.workbench.common.forms.jbpm.server.service.impl.documents.DocumentUploadSession)1