Search in sources :

Example 6 with PropertiesProvider

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

the class NoteResourceTest method setUp.

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

Example 7 with PropertiesProvider

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

the class ProjectResourceTest method test_delete_project_with_unauthorized_user.

@Test
public void test_delete_project_with_unauthorized_user() {
    configure(routes -> routes.add(new ProjectResource(repository, indexer)).filter(new YesBasicAuthFilter(new PropertiesProvider())));
    when(repository.deleteAll("projectId")).thenReturn(true);
    delete("/api/project/hacker-datashare").withPreemptiveAuthentication("hacker", "pass").should().respond(401);
    delete("/api/project/projectId").should().respond(401);
}
Also used : PropertiesProvider(org.icij.datashare.PropertiesProvider) YesBasicAuthFilter(org.icij.datashare.session.YesBasicAuthFilter) AbstractProdWebServerTest(org.icij.datashare.web.testhelpers.AbstractProdWebServerTest) Test(org.junit.Test)

Example 8 with PropertiesProvider

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

the class StatusResourceTest method setUp.

@Before
public void setUp() {
    initMocks(this);
    when(documentCollectionFactory.createQueue(any(), eq(new PropertiesProvider().get(PropertiesProvider.QUEUE_NAME_OPTION).orElse("extract:queue")))).thenReturn(mock(DocumentQueue.class));
    configure(routes -> routes.add(new StatusResource(new PropertiesProvider(), repository, indexer, dataBus, documentCollectionFactory)));
}
Also used : PropertiesProvider(org.icij.datashare.PropertiesProvider) DocumentQueue(org.icij.extract.queue.DocumentQueue) Before(org.junit.Before)

Example 9 with PropertiesProvider

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

the class BatchSearchRunnerTest method test_run_batch_search_with_throttle.

@Test
public void test_run_batch_search_with_throttle() throws Exception {
    mockSearch.willReturn(1, createDoc("doc").build());
    BatchSearch batchSearch = new BatchSearch("uuid1", project("test-datashare"), "name1", "desc1", asSet("query1", "query2"), new Date(), BatchSearch.State.QUEUED, local());
    Date beforeBatch = timeRule.now;
    new BatchSearchRunner(indexer, new PropertiesProvider(new HashMap<String, String>() {

        {
            put(BATCH_THROTTLE, "1000");
        }
    }), batchSearch, resultConsumer).call();
    assertThat(timeRule.now().getTime() - beforeBatch.getTime()).isEqualTo(1000);
}
Also used : PropertiesProvider(org.icij.datashare.PropertiesProvider) BatchSearch(org.icij.datashare.batch.BatchSearch) Date(java.util.Date) Test(org.junit.Test)

Example 10 with PropertiesProvider

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

the class BatchSearchRunnerTest method test_run_batch_search.

@Test
public void test_run_batch_search() throws Exception {
    Document[] documents = { createDoc("doc1").build(), createDoc("doc2").build() };
    mockSearch.willReturn(1, documents);
    BatchSearch search = new BatchSearch("uuid1", project("test-datashare"), "name1", "desc1", asSet("query1", "query2"), new Date(), BatchSearch.State.QUEUED, User.local());
    assertThat(new BatchSearchRunner(indexer, new PropertiesProvider(), search, resultConsumer).call()).isEqualTo(2);
    verify(resultConsumer).apply("uuid1", "query1", asList(documents));
}
Also used : PropertiesProvider(org.icij.datashare.PropertiesProvider) BatchSearch(org.icij.datashare.batch.BatchSearch) 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