Search in sources :

Example 31 with PropertiesProvider

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

the class UserResourceTest method setUp.

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

Example 32 with PropertiesProvider

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

the class RedisUserDocumentQueueTest method test_redis_queue_name_with_user_not_null_and_queue_name__user_queue_is_preferred.

@Test
public void test_redis_queue_name_with_user_not_null_and_queue_name__user_queue_is_preferred() {
    RedisUserDocumentQueue queue = new RedisUserDocumentQueue(new User("foo"), new PropertiesProvider(new HashMap<String, String>() {

        {
            put("redisAddress", "redis://redis:6379");
            put("queueName", "myqueue");
        }
    }));
    queue.offer(get("/path/to/doc"));
    assertThat(redis.keys("extract:queue_foo")).hasSize(1);
    assertThat(redis.lpop("extract:queue_foo")).isEqualTo("/path/to/doc");
}
Also used : PropertiesProvider(org.icij.datashare.PropertiesProvider) User(org.icij.datashare.user.User) User.nullUser(org.icij.datashare.user.User.nullUser) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 33 with PropertiesProvider

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

the class RedisUserDocumentQueueTest method test_redis_queue_name_with_null_user.

@Test
public void test_redis_queue_name_with_null_user() {
    RedisUserDocumentQueue queue = new RedisUserDocumentQueue(nullUser(), new PropertiesProvider(new HashMap<String, String>() {

        {
            put("redisAddress", "redis://redis:6379");
        }
    }));
    queue.offer(get("/path/to/doc"));
    assertThat(redis.keys("extract:queue")).hasSize(1);
    assertThat(redis.lpop("extract:queue")).isEqualTo("/path/to/doc");
}
Also used : PropertiesProvider(org.icij.datashare.PropertiesProvider) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 34 with PropertiesProvider

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

the class RedisUserDocumentQueueTest method test_redis_queue_name_with_user_not_null_and_no_parameter_queue_name.

@Test
public void test_redis_queue_name_with_user_not_null_and_no_parameter_queue_name() {
    RedisUserDocumentQueue queue = new RedisUserDocumentQueue(new User("foo"), new PropertiesProvider(new HashMap<String, String>() {

        {
            put("redisAddress", "redis://redis:6379");
        }
    }));
    queue.offer(get("/path/to/doc"));
    assertThat(redis.keys("extract:queue_foo")).hasSize(1);
    assertThat(redis.lpop("extract:queue_foo")).isEqualTo("/path/to/doc");
}
Also used : PropertiesProvider(org.icij.datashare.PropertiesProvider) User(org.icij.datashare.user.User) User.nullUser(org.icij.datashare.user.User.nullUser) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 35 with PropertiesProvider

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

the class BatchSearchRunnerTest method test_cancel_current_batch_search.

@Test
public void test_cancel_current_batch_search() throws Exception {
    CountDownLatch countDownLatch = new CountDownLatch(1);
    BatchSearch batchSearch = new BatchSearch("uuid1", project("test-datashare"), "name1", "desc1", asSet("query1", "query2"), new Date(), BatchSearch.State.QUEUED, local());
    Document[] documents = { createDoc("doc").build() };
    mockSearch.willReturn(1, documents);
    BatchSearchRunner batchSearchRunner = new BatchSearchRunner(indexer, new PropertiesProvider(), batchSearch, resultConsumer, countDownLatch);
    executor.submit(batchSearchRunner);
    executor.shutdown();
    countDownLatch.await();
    batchSearchRunner.cancel();
    assertThat(executor.awaitTermination(2, TimeUnit.SECONDS)).isTrue();
}
Also used : PropertiesProvider(org.icij.datashare.PropertiesProvider) BatchSearch(org.icij.datashare.batch.BatchSearch) CountDownLatch(java.util.concurrent.CountDownLatch) Document(org.icij.datashare.text.Document) Date(java.util.Date) 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