Search in sources :

Example 6 with BatchDownload

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

the class BatchDownloadRunnerIntTest method test_two_files_one_result.

@Test
public void test_two_files_one_result() throws Exception {
    new IndexerHelper(es.client).indexFile("doc1.txt", "The quick brown fox jumps over the lazy dog", fs);
    new IndexerHelper(es.client).indexFile("doc2.txt", "Portez ce vieux whisky au juge blond qui fume", fs);
    BatchDownload bd = createBatchDownload("juge");
    new BatchDownloadRunner(indexer, createProvider(), bd, updateCallback).call();
    assertThat(bd.filename.toFile()).isFile();
    assertThat(new ZipFile(bd.filename.toFile()).size()).isEqualTo(1);
}
Also used : BatchDownload(org.icij.datashare.batch.BatchDownload) ZipFile(java.util.zip.ZipFile)

Example 7 with BatchDownload

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

the class BatchDownloadLoopTestInt method test_batch_download_task_view_properties.

@Test(timeout = 1000)
public void test_batch_download_task_view_properties() {
    TaskFactory factory = mock(TaskFactory.class);
    when(factory.createDownloadRunner(any(), any())).thenReturn(mock(BatchDownloadRunner.class));
    BatchDownloadLoop batchDownloadLoop = new BatchDownloadLoop(new PropertiesProvider(), batchDownloadQueue, factory, taskManager);
    batchDownloadQueue.add(new BatchDownload(Project.project("prj"), User.local(), "foo"));
    batchDownloadLoop.enqueuePoison();
    batchDownloadLoop.run();
    assertThat(taskManager.get()).hasSize(1);
    assertThat(taskManager.get().get(0).properties).hasSize(1);
}
Also used : PropertiesProvider(org.icij.datashare.PropertiesProvider) BatchDownload(org.icij.datashare.batch.BatchDownload) Test(org.junit.Test)

Example 8 with BatchDownload

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

the class BatchDownloadRunnerIntTest method test_one_result_with_json_query.

@Test
public void test_one_result_with_json_query() throws Exception {
    String content = "The quick brown fox jumps over the lazy dog";
    new IndexerHelper(es.client).indexFile("mydoc.txt", content, fs);
    BatchDownload bd = createBatchDownload("{\"match_all\":{}}");
    new BatchDownloadRunner(indexer, createProvider(), bd, updateCallback).call();
    assertThat(bd.filename.toFile()).isFile();
    assertThat(new ZipFile(bd.filename.toFile()).size()).isEqualTo(1);
}
Also used : BatchDownload(org.icij.datashare.batch.BatchDownload) ZipFile(java.util.zip.ZipFile)

Example 9 with BatchDownload

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

the class BatchDownloadRunnerIntTest method test_to_string_contains_batch_download_uuid.

@Test
public void test_to_string_contains_batch_download_uuid() {
    BatchDownload batchDownload = createBatchDownload("*");
    BatchDownloadRunner batchDownloadRunner = new BatchDownloadRunner(indexer, createProvider(), batchDownload, updateCallback);
    assertThat(batchDownloadRunner.toString()).startsWith("org.icij.datashare.tasks.BatchDownloadRunner@");
    assertThat(batchDownloadRunner.toString()).contains(batchDownload.uuid);
}
Also used : BatchDownload(org.icij.datashare.batch.BatchDownload)

Example 10 with BatchDownload

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

the class BatchDownloadRunnerIntTest method test_update_batch_download_zip_size.

@Test
public void test_update_batch_download_zip_size() throws Exception {
    new IndexerHelper(es.client).indexFile("doc1.txt", "The quick brown fox jumps over the lazy dog", fs);
    new IndexerHelper(es.client).indexFile("doc2.txt", "Portez ce vieux whisky au juge blond qui fume", fs);
    BatchDownload bd = createBatchDownload("*");
    long sizeAtCreation = bd.zipSize;
    new BatchDownloadRunner(indexer, createProvider(), bd, updateCallback).call();
    assertThat(bd.zipSize).isGreaterThan(sizeAtCreation);
}
Also used : BatchDownload(org.icij.datashare.batch.BatchDownload)

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