use of org.jbpm.document.Document in project jbpm by kiegroup.
the class DocumentStorageServiceImplTest method testListDocumentsLessThanPageSize.
@Test
public void testListDocumentsLessThanPageSize() {
byte[] content = "yet another document content".getBytes();
Document document = documentStorageService.buildDocument("mydoc", content.length, new Date(), new HashMap<String, String>());
assertNotNull(document.getIdentifier());
documentStorageService.saveDocument(document, content);
List<Document> docs = documentStorageService.listDocuments(0, 5);
assertNotNull(docs);
assertEquals(1, docs.size());
assertEquals("mydoc", docs.get(0).getName());
}
use of org.jbpm.document.Document in project jbpm by kiegroup.
the class DocumentStorageServiceImplTest method testSaveAndDeleteDocument.
@Test
public void testSaveAndDeleteDocument() {
byte[] content = "another document content".getBytes();
Document document = documentStorageService.buildDocument("mydoc", content.length, new Date(), new HashMap<String, String>());
assertNotNull(document.getIdentifier());
documentStorageService.saveDocument(document, content);
Document fromStorage = documentStorageService.getDocument(document.getIdentifier());
assertNotNull(fromStorage);
assertEquals(document.getIdentifier(), fromStorage.getIdentifier());
assertEquals(document.getName(), fromStorage.getName());
assertEquals(content.length, fromStorage.getContent().length);
documentStorageService.deleteDocument(fromStorage);
fromStorage = documentStorageService.getDocument(document.getIdentifier());
assertNull(fromStorage);
}
use of org.jbpm.document.Document in project jbpm by kiegroup.
the class DocumentStorageServiceImplTest method testSaveAndListDocuments.
@Test
public void testSaveAndListDocuments() {
long lastModified = System.currentTimeMillis() - 10000;
for (int i = 0; i < 10; i++) {
byte[] content = (i + " another document content").getBytes();
Document document = documentStorageService.buildDocument("mydoc" + i, content.length, new Date(lastModified + i * 1000), new HashMap<String, String>());
assertNotNull(document.getIdentifier());
documentStorageService.saveDocument(document, content);
}
List<Document> docs = documentStorageService.listDocuments(0, 5);
assertNotNull(docs);
assertEquals(5, docs.size());
assertEquals("mydoc" + 0, docs.get(0).getName());
assertEquals("mydoc" + 1, docs.get(1).getName());
assertEquals("mydoc" + 2, docs.get(2).getName());
assertEquals("mydoc" + 3, docs.get(3).getName());
assertEquals("mydoc" + 4, docs.get(4).getName());
docs = documentStorageService.listDocuments(1, 5);
assertNotNull(docs);
assertEquals(5, docs.size());
assertEquals("mydoc" + 5, docs.get(0).getName());
assertEquals("mydoc" + 6, docs.get(1).getName());
assertEquals("mydoc" + 7, docs.get(2).getName());
assertEquals("mydoc" + 8, docs.get(3).getName());
assertEquals("mydoc" + 9, docs.get(4).getName());
docs = documentStorageService.listDocuments(1, 2);
assertNotNull(docs);
assertEquals(2, docs.size());
assertEquals("mydoc" + 2, docs.get(0).getName());
assertEquals("mydoc" + 3, docs.get(1).getName());
}
use of org.jbpm.document.Document in project jbpm by kiegroup.
the class DocumentStorageServiceImplTest method testListDocumentsNonexistentDocsFolder.
@Test
public void testListDocumentsNonexistentDocsFolder() {
// Delete document storage contents AND the dir itself
File docsDir = new File(STORAGE_PATH_TEST);
deleteFolder(docsDir);
docsDir.delete();
List<Document> docs = documentStorageService.listDocuments(0, 10);
assertTrue("When documents directory doesn't exist, empty doc list should be returned", docs.isEmpty());
}
use of org.jbpm.document.Document in project jbpm by kiegroup.
the class DocumentImplTest method testConstructorWithoutIdentifier.
@Test
public void testConstructorWithoutIdentifier() {
Document document = new DocumentImpl(NAME, SIZE, LAST_MODIFIED);
Assertions.assertThat(document.getIdentifier()).isNotNull();
Assertions.assertThat(document.getName()).isNotNull().isEqualTo(NAME);
Assertions.assertThat(document.getSize()).isEqualTo(SIZE);
Assertions.assertThat(document.getLastModified()).isEqualTo(LAST_MODIFIED);
}
Aggregations