Source:
public void testDefaultRenditionOnContainer() throws Exception { DocumentModel folder1 = session.createDocumentModel("/", "dummy-folder", "Folder"); folder1 = session.createDocument(folder1); TestRenditionProvider.createBlobDoc(folder1.getPathAsString(), "dummy-file01", "dummy-file01.txt", "File", session); TestRenditionProvider.createBlobDoc(folder1.getPathAsString(), "dummy-file02", "dummy-file02.txt", "File", session); DocumentModel collection = session.createDocumentModel(folder1.getPathAsString(), "dummy-collection", "Collection"); collection = session.createDocument(collection); DocumentModel file11 = TestRenditionProvider.createBlobDoc("/", "dummy-file11", "dummy-file11.txt", "File", session); DocumentModel file12 = TestRenditionProvider.createBlobDoc("/", "dummy-file12", "dummy-file12.txt", "File", session); CollectionManager collectionManager = Framework.getService(CollectionManager.class); collectionManager.addToCollection(collection, file11, session); collectionManager.addToCollection(collection, file12, session); Rendition ren = renditionService.getDefaultRendition(folder1, "download", null); assertNotNull(ren); Blob resultBlob = ren.getBlob(); assertEquals("application/zip", resultBlob.getMimeType()); try (CloseableFile source = resultBlob.getCloseableFile()) { try (ZipFile zip = new ZipFile(source.getFile())) { assertEquals(3, zip.size()); ZipEntry z1 = zip.getEntry("dummy-collection.zip"); assertNotNull(z1); try (ZipInputStream zis = new ZipInputStream(zip.getInputStream(z1))) { ZipEntry entry; int i = 0; while ((entry = zis.getNextEntry()) != null) { i++; assertEquals("dummy-file1" + i + ".txt", entry.getName()); } ; assertEquals(2, i); } } } }

Target:
public void testDefaultRenditionOnContainer() throws Exception { DocumentModel folder01 = session.createDocumentModel("/", "dummy-folder", "Folder"); folder01 = session.createDocument(folder01); TestRenditionProvider.createBlobDoc(folder01.getPathAsString(), "dummy-file01", "dummy-file01.txt", "File", session); TestRenditionProvider.createBlobDoc(folder01.getPathAsString(), "dummy-file02", "dummy-file02.txt", "File", session); DocumentModel collection = session.createDocumentModel(folder01.getPathAsString(), "dummy-collection", "Collection"); collection = session.createDocument(collection); DocumentModel folder11 = session.createDocumentModel("/", "dummy-folder", "Folder"); folder11 = session.createDocument(folder01); DocumentModel file11 = TestRenditionProvider.createBlobDoc("/", "dummy-file11", "dummy-file11.txt", "File", session); DocumentModel file12 = TestRenditionProvider.createBlobDoc("/", "dummy-file12", "dummy-file12.txt", "File", session); CollectionManager collectionManager = Framework.getService(CollectionManager.class); collectionManager.addToCollection(collection, folder11, session); collectionManager.addToCollection(collection, file11, session); collectionManager.addToCollection(collection, file12, session); Rendition ren = renditionService.getDefaultRendition(folder01, "download", null); assertNotNull(ren); Blob resultBlob = ren.getBlob(); assertEquals("application/zip", resultBlob.getMimeType()); try (CloseableFile source = resultBlob.getCloseableFile()) { try (ZipFile zip = new ZipFile(source.getFile())) { assertEquals(3, zip.size()); ZipEntry z1 = zip.getEntry("dummy-collection.zip"); assertNotNull(z1); try (ZipInputStream zis = new ZipInputStream(zip.getInputStream(z1))) { ZipEntry entry; int i = 0; while ((entry = zis.getNextEntry()) != null) { i++; assertEquals("dummy-file1" + i + ".txt", entry.getName()); } assertEquals(2, i); } } } }