Search in sources :

Example 1 with MailSender

use of org.icij.datashare.com.mail.MailSender 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());
}
Also used : ElasticsearchRule(org.icij.datashare.test.ElasticsearchRule) MockitoAnnotations.initMocks(org.mockito.MockitoAnnotations.initMocks) PropertiesProvider(org.icij.datashare.PropertiesProvider) ElasticsearchIndexer(org.icij.datashare.text.indexing.elasticsearch.ElasticsearchIndexer) Mock(org.mockito.Mock) IOException(java.io.IOException) HashMap(java.util.HashMap) TEST_INDEX(org.icij.datashare.test.ElasticsearchRule.TEST_INDEX) Function(java.util.function.Function) File(java.io.File) Mockito.verify(org.mockito.Mockito.verify) ArgumentCaptor(org.mockito.ArgumentCaptor) Assertions.assertThat(org.fest.assertions.Assertions.assertThat) MailSender(org.icij.datashare.com.mail.MailSender) User(org.icij.datashare.user.User) Project.project(org.icij.datashare.text.Project.project) org.junit(org.junit) IMMEDIATE(org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE) BatchDownload(org.icij.datashare.batch.BatchDownload) NotNull(org.jetbrains.annotations.NotNull) Mail(org.icij.datashare.com.mail.Mail) TemporaryFolder(org.junit.rules.TemporaryFolder) Mockito.mock(org.mockito.Mockito.mock) BatchDownload(org.icij.datashare.batch.BatchDownload) Mail(org.icij.datashare.com.mail.Mail) MailSender(org.icij.datashare.com.mail.MailSender)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Function (java.util.function.Function)1 IMMEDIATE (org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE)1 Assertions.assertThat (org.fest.assertions.Assertions.assertThat)1 PropertiesProvider (org.icij.datashare.PropertiesProvider)1 BatchDownload (org.icij.datashare.batch.BatchDownload)1 Mail (org.icij.datashare.com.mail.Mail)1 MailSender (org.icij.datashare.com.mail.MailSender)1 ElasticsearchRule (org.icij.datashare.test.ElasticsearchRule)1 TEST_INDEX (org.icij.datashare.test.ElasticsearchRule.TEST_INDEX)1 Project.project (org.icij.datashare.text.Project.project)1 ElasticsearchIndexer (org.icij.datashare.text.indexing.elasticsearch.ElasticsearchIndexer)1 User (org.icij.datashare.user.User)1 NotNull (org.jetbrains.annotations.NotNull)1 org.junit (org.junit)1 TemporaryFolder (org.junit.rules.TemporaryFolder)1 ArgumentCaptor (org.mockito.ArgumentCaptor)1 Mock (org.mockito.Mock)1