Search in sources :

Example 46 with PropertiesProvider

use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.

the class ElasticsearchSpewerTest method test_get_max_content_length_is_limited_to_2G.

@Test
public void test_get_max_content_length_is_limited_to_2G() {
    assertThat(spewer.getMaxContentLength(new PropertiesProvider(new HashMap<String, String>() {

        {
            put("maxContentLength", "20");
        }
    }))).isEqualTo(20);
    assertThat((long) spewer.getMaxContentLength(new PropertiesProvider(new HashMap<String, String>() {

        {
            put("maxContentLength", "2G");
        }
    }))).isEqualTo(// Integer.MAX_VALUE
    HumanReadableSize.parse("2G") - 1);
}
Also used : PropertiesProvider(org.icij.datashare.PropertiesProvider) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 47 with PropertiesProvider

use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.

the class ApiKeyResourceTest method setUp.

@Before
public void setUp() {
    initMocks(this);
    configure(routes -> routes.add(new ApiKeyResource(taskFactory)).filter(new LocalUserFilter(new PropertiesProvider())));
}
Also used : PropertiesProvider(org.icij.datashare.PropertiesProvider) LocalUserFilter(org.icij.datashare.session.LocalUserFilter) Before(org.junit.Before)

Example 48 with PropertiesProvider

use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.

the class BatchDownloadLoopTest method test_loop.

@Test
public void test_loop() throws Exception {
    BatchDownloadCleaner batchDownloadCleaner = mock(BatchDownloadCleaner.class);
    BatchDownloadLoop app = new BatchDownloadLoop(new PropertiesProvider(), batchDownloadQueue, factory, manager) {

        @Override
        public BatchDownloadCleaner createDownloadCleaner(Path downloadDir, int ttlHour) {
            return batchDownloadCleaner;
        }
    };
    batchDownloadQueue.add(new BatchDownload(project("prj"), User.local(), "query"));
    app.enqueuePoison();
    app.run();
    verify(batchRunner).call();
    verify(manager).save(argCaptor.capture());
    verify(batchDownloadCleaner, times(2)).run();
    assertThat(argCaptor.getValue().getState()).isEqualTo(TaskView.State.DONE);
}
Also used : PropertiesProvider(org.icij.datashare.PropertiesProvider) Path(java.nio.file.Path) BatchDownload(org.icij.datashare.batch.BatchDownload) Test(org.junit.Test)

Example 49 with PropertiesProvider

use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.

the class BatchDownloadLoopTest method test_ttl_property.

@Test
public void test_ttl_property() {
    BatchDownloadCleaner batchDownloadCleaner = mock(BatchDownloadCleaner.class);
    PropertiesProvider propertiesProvider = new PropertiesProvider(new HashMap<String, String>() {

        {
            put(BATCH_DOWNLOAD_ZIP_TTL, "15");
        }
    });
    BatchDownloadLoop app = new BatchDownloadLoop(propertiesProvider, batchDownloadQueue, factory, manager) {

        @Override
        public BatchDownloadCleaner createDownloadCleaner(Path downloadDir, int ttlHour) {
            assertThat(ttlHour).isEqualTo(15);
            return batchDownloadCleaner;
        }
    };
    app.enqueuePoison();
    app.run();
}
Also used : PropertiesProvider(org.icij.datashare.PropertiesProvider) Path(java.nio.file.Path) Test(org.junit.Test)

Example 50 with PropertiesProvider

use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.

the class BatchDownloadLoopTest method test_elasticsearch_exception__should_not_be_serialized.

@Test
public void test_elasticsearch_exception__should_not_be_serialized() throws Exception {
    when(batchRunner.call()).thenThrow(new ElasticsearchStatusException("error", RestStatus.BAD_REQUEST, new RuntimeException()));
    BatchDownloadCleaner batchDownloadCleaner = mock(BatchDownloadCleaner.class);
    BatchDownloadLoop app = new BatchDownloadLoop(new PropertiesProvider(), batchDownloadQueue, factory, manager) {

        @Override
        public BatchDownloadCleaner createDownloadCleaner(Path downloadDir, int ttlHour) {
            return batchDownloadCleaner;
        }
    };
    batchDownloadQueue.add(new BatchDownload(project("prj"), User.local(), "query"));
    app.enqueuePoison();
    app.run();
    verify(manager).save(argCaptor.capture());
    assertThat(argCaptor.getValue().getState()).isEqualTo(TaskView.State.ERROR);
    assertThat(argCaptor.getValue().error.getClass()).isNotEqualTo(ElasticsearchStatusException.class);
}
Also used : PropertiesProvider(org.icij.datashare.PropertiesProvider) Path(java.nio.file.Path) BatchDownload(org.icij.datashare.batch.BatchDownload) ElasticsearchStatusException(org.elasticsearch.ElasticsearchStatusException) Test(org.junit.Test)

Aggregations

PropertiesProvider (org.icij.datashare.PropertiesProvider)73 Test (org.junit.Test)44 HashMap (java.util.HashMap)27 Document (org.icij.datashare.text.Document)18 BatchSearch (org.icij.datashare.batch.BatchSearch)17 LocalUserFilter (org.icij.datashare.session.LocalUserFilter)15 AbstractProdWebServerTest (org.icij.datashare.web.testhelpers.AbstractProdWebServerTest)15 Path (java.nio.file.Path)11 Before (org.junit.Before)10 BatchDownload (org.icij.datashare.batch.BatchDownload)9 Publisher (org.icij.datashare.com.Publisher)8 Indexer (org.icij.datashare.text.indexing.Indexer)7 User (org.icij.datashare.user.User)7 Date (java.util.Date)6 Properties (java.util.Properties)6 RestAssert (net.codestory.rest.RestAssert)5 PipelineRegistry (org.icij.datashare.extension.PipelineRegistry)5 DocumentFactory (org.icij.extract.document.DocumentFactory)5 TikaDocument (org.icij.extract.document.TikaDocument)5 FieldNames (org.icij.spewer.FieldNames)5