Search in sources :

Example 1 with PropertiesProvider

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

the class IndexerHelper method indexEmbeddedFile.

File indexEmbeddedFile(String project, String docPath) throws IOException {
    Path path = get(getClass().getResource(docPath).getPath());
    Extractor extractor = new Extractor(new DocumentFactory().withIdentifier(new DigestIdentifier("SHA-384", Charset.defaultCharset())));
    extractor.setDigester(new UpdatableDigester(project, Entity.HASHER.toString()));
    TikaDocument document = extractor.extract(path);
    ElasticsearchSpewer elasticsearchSpewer = new ElasticsearchSpewer(client, l -> ENGLISH, new FieldNames(), mock(Publisher.class), new PropertiesProvider()).withRefresh(IMMEDIATE).withIndex("test-datashare");
    elasticsearchSpewer.write(document);
    return path.toFile();
}
Also used : Path(java.nio.file.Path) PropertiesProvider(org.icij.datashare.PropertiesProvider) ElasticsearchSpewer(org.icij.datashare.text.indexing.elasticsearch.ElasticsearchSpewer) DocumentFactory(org.icij.extract.document.DocumentFactory) UpdatableDigester(org.icij.extract.extractor.UpdatableDigester) FieldNames(org.icij.spewer.FieldNames) DigestIdentifier(org.icij.extract.document.DigestIdentifier) TikaDocument(org.icij.extract.document.TikaDocument) Extractor(org.icij.extract.extractor.Extractor) Publisher(org.icij.datashare.com.Publisher)

Example 2 with PropertiesProvider

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

the class DocumentResourceTest method setUp.

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

Example 3 with PropertiesProvider

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

the class IndexResourceTest method test_no_auth_post_forward_request_to_elastic_with_body.

@Test
public void test_no_auth_post_forward_request_to_elastic_with_body() {
    configure(routes -> routes.add(new IndexResource(indexer)).filter(new LocalUserFilter(new PropertiesProvider(new HashMap<String, String>() {

        {
            put("defaultUserName", "test");
        }
    }))));
    post("/api/index/search/test-datashare/_search", "{}").should().respond(200).contain("\"successful\":1");
}
Also used : PropertiesProvider(org.icij.datashare.PropertiesProvider) LocalUserFilter(org.icij.datashare.session.LocalUserFilter) HashMap(java.util.HashMap) AbstractProdWebServerTest(org.icij.datashare.web.testhelpers.AbstractProdWebServerTest) Test(org.junit.Test)

Example 4 with PropertiesProvider

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

the class IndexResourceTest method test_no_auth_options_forward_request_to_elastic.

@Test
public void test_no_auth_options_forward_request_to_elastic() {
    configure(routes -> routes.add(new IndexResource(indexer)).filter(new LocalUserFilter(new PropertiesProvider(new HashMap<String, String>() {

        {
            put("defaultUserName", "test");
        }
    }))));
    options("/api/index/search/test-datashare").should().respond(200);
}
Also used : PropertiesProvider(org.icij.datashare.PropertiesProvider) LocalUserFilter(org.icij.datashare.session.LocalUserFilter) HashMap(java.util.HashMap) AbstractProdWebServerTest(org.icij.datashare.web.testhelpers.AbstractProdWebServerTest) Test(org.junit.Test)

Example 5 with PropertiesProvider

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

the class IndexResourceTest method test_no_auth_get_forward_request_to_elastic_if_granted_to_read_index.

@Test
public void test_no_auth_get_forward_request_to_elastic_if_granted_to_read_index() {
    configure(routes -> routes.add(new IndexResource(indexer)).filter(new LocalUserFilter(new PropertiesProvider(new HashMap<String, String>() {

        {
            put("defaultUserName", "test");
        }
    }))));
    get("/api/index/search/unauthorized/_search").should().respond(401);
}
Also used : PropertiesProvider(org.icij.datashare.PropertiesProvider) LocalUserFilter(org.icij.datashare.session.LocalUserFilter) HashMap(java.util.HashMap) AbstractProdWebServerTest(org.icij.datashare.web.testhelpers.AbstractProdWebServerTest) 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