Search in sources :

Example 21 with BatchDownload

use of org.icij.datashare.batch.BatchDownload in project datashare by ICIJ.

the class BatchDownloadRunnerTest method test_max_default_results.

@Test
public void test_max_default_results() throws Exception {
    Document[] documents = IntStream.range(0, 3).mapToObj(i -> createDoc("doc" + i).with(createFile(i)).build()).toArray(Document[]::new);
    mockSearch.willReturn(2, documents);
    File zip = new BatchDownloadRunner(indexer, new PropertiesProvider(new HashMap<String, String>() {

        {
            put(BATCH_DOWNLOAD_MAX_NB_FILES, "3");
            put(SCROLL_SIZE, "3");
        }
    }), new BatchDownload(project("test-datashare"), User.local(), "query"), updater).call();
    assertThat(new ZipFile(zip).size()).isEqualTo(3);
}
Also used : IntStream(java.util.stream.IntStream) MockitoAnnotations.initMocks(org.mockito.MockitoAnnotations.initMocks) Mock(org.mockito.Mock) HashMap(java.util.HashMap) Function(java.util.function.Function) Assertions.assertThat(org.fest.assertions.Assertions.assertThat) DatashareCliOptions(org.icij.datashare.cli.DatashareCliOptions) ElasticsearchStatusException(org.elasticsearch.ElasticsearchStatusException) User(org.icij.datashare.user.User) ZipFile(java.util.zip.ZipFile) Project.project(org.icij.datashare.text.Project.project) BatchDownload(org.icij.datashare.batch.BatchDownload) Path(java.nio.file.Path) Before(org.junit.Before) PropertiesProvider(org.icij.datashare.PropertiesProvider) Files(java.nio.file.Files) DocumentBuilder.createDoc(org.icij.datashare.text.DocumentBuilder.createDoc) Indexer(org.icij.datashare.text.indexing.Indexer) Test(org.junit.Test) IOException(java.io.IOException) Document(org.icij.datashare.text.Document) File(java.io.File) StandardCharsets(java.nio.charset.StandardCharsets) Rule(org.junit.Rule) String.valueOf(java.lang.String.valueOf) RestStatus(org.elasticsearch.rest.RestStatus) TemporaryFolder(org.junit.rules.TemporaryFolder) PropertiesProvider(org.icij.datashare.PropertiesProvider) BatchDownload(org.icij.datashare.batch.BatchDownload) ZipFile(java.util.zip.ZipFile) Document(org.icij.datashare.text.Document) ZipFile(java.util.zip.ZipFile) File(java.io.File) Test(org.junit.Test)

Aggregations

BatchDownload (org.icij.datashare.batch.BatchDownload)21 ZipFile (java.util.zip.ZipFile)9 PropertiesProvider (org.icij.datashare.PropertiesProvider)8 File (java.io.File)7 Test (org.junit.Test)7 Path (java.nio.file.Path)5 IOException (java.io.IOException)4 HashMap (java.util.HashMap)4 ElasticsearchStatusException (org.elasticsearch.ElasticsearchStatusException)4 Function (java.util.function.Function)3 Assertions.assertThat (org.fest.assertions.Assertions.assertThat)3 Project.project (org.icij.datashare.text.Project.project)3 Indexer (org.icij.datashare.text.indexing.Indexer)3 User (org.icij.datashare.user.User)3 TemporaryFolder (org.junit.rules.TemporaryFolder)3 Mock (org.mockito.Mock)3 MockitoAnnotations.initMocks (org.mockito.MockitoAnnotations.initMocks)3 String.valueOf (java.lang.String.valueOf)2 StandardCharsets (java.nio.charset.StandardCharsets)2 Files (java.nio.file.Files)2