use of org.icij.datashare.batch.BatchDownload in project datashare by ICIJ.
the class BatchDownloadRunnerEncryptedIntTest method test_zip_with_password_should_encrypt_file_and_send_mail.
@Test
public void test_zip_with_password_should_encrypt_file_and_send_mail() throws Exception {
new IndexerHelper(es.client).indexFile("mydoc.txt", "content", fs);
BatchDownload batchDownload = createBatchDownload("*");
MailSender mailSender = mock(MailSender.class);
new BatchDownloadRunner(indexer, createProvider(), batchDownload, updateCallback, (uri) -> mailSender).call();
assertThat(new net.lingala.zip4j.ZipFile(batchDownload.filename.toFile()).isEncrypted()).isTrue();
ArgumentCaptor<Mail> mailCaptor = ArgumentCaptor.forClass(Mail.class);
verify(mailSender).send(mailCaptor.capture());
assertThat(mailCaptor.getValue().from).isEqualTo("engineering@icij.org");
assertThat(mailCaptor.getValue().toRecipientList).containsExactly("foo@bar.com");
assertThat(mailCaptor.getValue().subject).isEqualTo("[datashare] " + batchDownload.filename.getFileName());
}
use of org.icij.datashare.batch.BatchDownload in project datashare by ICIJ.
the class BatchDownloadRunnerIntTest method test_embedded_doc_with_not_found_embedded_should_not_interrupt_zip_creation.
@Test
public void test_embedded_doc_with_not_found_embedded_should_not_interrupt_zip_creation() throws Exception {
new IndexerHelper(es.client).indexEmbeddedFile("bad_project_name", "/docs/embedded_doc.eml");
BatchDownload batchDownload = createBatchDownload("*");
new BatchDownloadRunner(indexer, createProvider(), batchDownload, updateCallback).call();
assertThat(new ZipFile(batchDownload.filename.toFile()).size()).isEqualTo(1);
}
use of org.icij.datashare.batch.BatchDownload in project datashare by ICIJ.
the class BatchDownloadRunnerIntTest method test_one_result.
@Test
public void test_one_result() throws Exception {
String content = "The quick brown fox jumps over the lazy dog";
File file = new IndexerHelper(es.client).indexFile("mydoc.txt", content, fs);
BatchDownload bd = createBatchDownload("fox");
new BatchDownloadRunner(indexer, createProvider(), bd, updateCallback).call();
assertThat(bd.filename.toFile()).isFile();
assertThat(new ZipFile(bd.filename.toFile()).size()).isEqualTo(1);
assertThat(new ZipFile(bd.filename.toFile()).getEntry(file.toString().substring(1))).isNotNull();
assertThat(new ZipFile(bd.filename.toFile()).getEntry(file.toString().substring(1)).getSize()).isEqualTo(content.length());
verify(updateCallback).apply(any());
}
use of org.icij.datashare.batch.BatchDownload in project datashare by ICIJ.
the class BatchDownloadRunnerIntTest method test_empty_response.
@Test
public void test_empty_response() throws Exception {
BatchDownload bd = createBatchDownload("query");
new BatchDownloadRunner(indexer, createProvider(), bd, updateCallback).call();
assertThat(bd.filename.toFile()).doesNotExist();
verify(updateCallback, never()).apply(any());
}
use of org.icij.datashare.batch.BatchDownload in project datashare by ICIJ.
the class BatchDownloadRunnerIntTest method test_two_results.
@Test
public void test_two_results() 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("*");
new BatchDownloadRunner(indexer, createProvider(), bd, updateCallback).call();
assertThat(bd.filename.toFile()).isFile();
assertThat(new ZipFile(bd.filename.toFile()).size()).isEqualTo(2);
verify(updateCallback, times(2)).apply(any());
}
Aggregations