use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class BatchSearchRunnerTest method test_run_batch_search_failure.
@Test(expected = RuntimeException.class)
public void test_run_batch_search_failure() throws Exception {
Document[] documents = { createDoc("doc").build() };
mockSearch.willReturn(1, documents);
BatchSearch batchSearch = new BatchSearch("uuid1", project("test-datashare"), "name1", "desc1", asSet("query1", "query2"), new Date(), BatchSearch.State.QUEUED, local());
when(resultConsumer.apply(anyString(), any(), anyList())).thenThrow(new RuntimeException());
new BatchSearchRunner(indexer, new PropertiesProvider(), batchSearch, resultConsumer).call();
}
use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class BatchSearchRunnerTest method test_run_batch_search_truncate_to_60k_max_results.
@Test
public void test_run_batch_search_truncate_to_60k_max_results() throws Exception {
Document[] documents = IntStream.range(0, MAX_SCROLL_SIZE).mapToObj(i -> createDoc("doc" + i).build()).toArray(Document[]::new);
mockSearch.willReturn(MAX_BATCH_RESULT_SIZE / MAX_SCROLL_SIZE + 1, documents);
BatchSearch batchSearch = new BatchSearch("uuid1", project("test-datashare"), "name", "desc", asSet("query"), new Date(), BatchSearch.State.QUEUED, local());
assertThat(new BatchSearchRunner(indexer, new PropertiesProvider(), batchSearch, resultConsumer).call()).isLessThan(60000);
}
use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class LocalUserFilterTest method test_adds_custom_user_to_context.
@Test
public void test_adds_custom_user_to_context() throws Exception {
LocalUserFilter localUserFilter = new LocalUserFilter(new PropertiesProvider(new HashMap<String, String>() {
{
put("defaultUserName", "foo");
}
}));
Payload payload = localUserFilter.apply("url", context, nextFilter);
assertThat(payload).isSameAs(next);
verify(context).setCurrentUser(user.capture());
assertThat(user.getValue().login()).isEqualTo("foo");
}
use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class LocalUserFilterTest method test_adds_local_user_to_context.
@Test
public void test_adds_local_user_to_context() throws Exception {
LocalUserFilter localUserFilter = new LocalUserFilter(new PropertiesProvider());
Payload payload = localUserFilter.apply("url", context, nextFilter);
assertThat(payload).isSameAs(next);
verify(context).setCurrentUser(user.capture());
assertThat(user.getValue().login()).isEqualTo("local");
assertThat(user.getValue().isInRole("local")).isTrue();
}
use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class YesCookieAuthFilterTest method test_adds_new_user_to_context.
@Test
public void test_adds_new_user_to_context() throws Exception {
YesCookieAuthFilter filter = new YesCookieAuthFilter(new PropertiesProvider(new HashMap<String, String>() {
{
put("defaultProject", "demo");
put("messageBusAddress", "redis://redis:6379");
}
}));
Payload payload = filter.apply("url", context, nextFilter);
assertThat(payload).isSameAs(next);
verify(context).setCurrentUser(user.capture());
assertThat(user.getValue().login()).isNotEmpty();
assertThat(((DatashareUser) user.getValue()).getProjects()).containsExactly("demo");
assertThat(user.getValue().isInRole("local")).isFalse();
}
Aggregations