Search in sources :

Example 66 with PropertiesProvider

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

the class BatchSearchRunnerIntTest method test_search_phrase_matches_with_slop.

@Test
public void test_search_phrase_matches_with_slop() throws Exception {
    // with phrase match a permutation (they call it transposition) is 2 slop
    // https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase.html
    Document mydoc = createDoc("docId").with("mydoc find").build();
    indexer.add(TEST_INDEX, mydoc);
    BatchSearch search = new BatchSearch(project(TEST_INDEX), "name", "desc", asSet("find mydoc"), User.local(), false, null, null, 2, true);
    new BatchSearchRunner(indexer, new PropertiesProvider(), search, resultConsumer).call();
    verify(resultConsumer).apply(search.uuid, "find mydoc", singletonList(mydoc));
}
Also used : PropertiesProvider(org.icij.datashare.PropertiesProvider) BatchSearch(org.icij.datashare.batch.BatchSearch) Document(org.icij.datashare.text.Document)

Example 67 with PropertiesProvider

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

the class BatchSearchRunnerIntTest method test_search_with_file_types_ko.

@Test
public void test_search_with_file_types_ko() throws Exception {
    Document mydoc = createDoc("mydoc").build();
    indexer.add(TEST_INDEX, mydoc);
    BatchSearch searchKo = new BatchSearch(project(TEST_INDEX), "name", "desc", asSet("mydoc"), User.local(), false, singletonList("application/pdf"), null, 0);
    new BatchSearchRunner(indexer, new PropertiesProvider(), searchKo, resultConsumer).call();
    verify(resultConsumer, never()).apply(eq(searchKo.uuid), eq("mydoc"), anyList());
}
Also used : PropertiesProvider(org.icij.datashare.PropertiesProvider) BatchSearch(org.icij.datashare.batch.BatchSearch) Document(org.icij.datashare.text.Document)

Example 68 with PropertiesProvider

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

the class IndexTaskTest method test_index_task_uses_users_index_name.

@Test
public void test_index_task_uses_users_index_name() {
    ElasticsearchSpewer spewer = mock(ElasticsearchSpewer.class);
    new IndexTask(spewer, mock(Publisher.class), mock(DocumentCollectionFactory.class), local(), "queueName", new PropertiesProvider(new HashMap<String, String>() {

        {
            put("redisAddress", "redis://redis:6379");
        }
    }).getProperties());
    Mockito.verify(spewer).withIndex("local-datashare");
}
Also used : PropertiesProvider(org.icij.datashare.PropertiesProvider) ElasticsearchSpewer(org.icij.datashare.text.indexing.elasticsearch.ElasticsearchSpewer) Publisher(org.icij.datashare.com.Publisher) Test(org.junit.Test)

Example 69 with PropertiesProvider

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

the class IndexTaskTest method test_index_task_with_null_user_and_null_index_name.

@Test
public void test_index_task_with_null_user_and_null_index_name() {
    ElasticsearchSpewer spewer = mock(ElasticsearchSpewer.class);
    new IndexTask(spewer, mock(Publisher.class), mock(DocumentCollectionFactory.class), local(), "queueName", new PropertiesProvider(new HashMap<String, String>() {

        {
            put("redisAddress", "redis://redis:6379");
        }
    }).getProperties());
    Mockito.verify(spewer).withIndex("local-datashare");
}
Also used : PropertiesProvider(org.icij.datashare.PropertiesProvider) ElasticsearchSpewer(org.icij.datashare.text.indexing.elasticsearch.ElasticsearchSpewer) Publisher(org.icij.datashare.com.Publisher) Test(org.junit.Test)

Example 70 with PropertiesProvider

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

the class ResumeNlpTaskTest method test_bug_size_of_search.

@Test
public void test_bug_size_of_search() throws Exception {
    for (int i = 0; i < 20; i++) {
        indexer.add(TEST_INDEX, createDoc("doc" + i).with(Pipeline.Type.CORENLP).build());
    }
    Publisher publisher = mock(Publisher.class);
    ResumeNlpTask resumeNlpTask = new ResumeNlpTask(publisher, indexer, new PropertiesProvider(new HashMap<String, String>() {

        {
            put("defaultProject", "test-datashare");
        }
    }), new User("test"), new HashSet<Pipeline.Type>() {

        {
            add(Pipeline.Type.OPENNLP);
        }
    });
    resumeNlpTask.call();
    verify(publisher, times(22)).publish(any(), any());
}
Also used : PropertiesProvider(org.icij.datashare.PropertiesProvider) User(org.icij.datashare.user.User) HashMap(java.util.HashMap) Publisher(org.icij.datashare.com.Publisher) 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