use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class BatchSearchRunnerTest method test_run_batch_search_with_throttle_should_not_last_more_than_max_time.
@Test
public void test_run_batch_search_with_throttle_should_not_last_more_than_max_time() throws Exception {
mockSearch.willReturn(5, 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;
SearchException searchException = assertThrows(SearchException.class, () -> new BatchSearchRunner(indexer, new PropertiesProvider(new HashMap<String, String>() {
{
put(BATCH_THROTTLE, "1000");
put(BATCH_SEARCH_MAX_TIME, "1");
}
}), batchSearch, resultConsumer).call());
assertThat(searchException.toString()).contains("Batch timed out after 1s");
assertThat(timeRule.now().getTime() - beforeBatch.getTime()).isEqualTo(1000);
}
use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class BatchSearchResourceTest method setUp.
@Before
public void setUp() {
initMocks(this);
configure(routes -> routes.add(new BatchSearchResource(batchSearchRepository, batchSearchQueue, new PropertiesProvider())).filter(new LocalUserFilter(new PropertiesProvider())));
}
use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class YesCookieAuthFilterTest method test_matches.
@Test
public void test_matches() {
YesCookieAuthFilter filter = new YesCookieAuthFilter(new PropertiesProvider(new HashMap<String, String>() {
{
put("protectedUrPrefix", "prefix");
}
}));
assertThat(filter.matches("foo", null)).isFalse();
assertThat(filter.matches("prefix", null)).isTrue();
}
use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class BatchDownloadLoopTestInt method test_batch_download_task_view_properties.
@Test(timeout = 1000)
public void test_batch_download_task_view_properties() {
TaskFactory factory = mock(TaskFactory.class);
when(factory.createDownloadRunner(any(), any())).thenReturn(mock(BatchDownloadRunner.class));
BatchDownloadLoop batchDownloadLoop = new BatchDownloadLoop(new PropertiesProvider(), batchDownloadQueue, factory, taskManager);
batchDownloadQueue.add(new BatchDownload(Project.project("prj"), User.local(), "foo"));
batchDownloadLoop.enqueuePoison();
batchDownloadLoop.run();
assertThat(taskManager.get()).hasSize(1);
assertThat(taskManager.get().get(0).properties).hasSize(1);
}
use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class BatchSearchRunnerIntTest method test_search_with_paths_ko.
@Test
public void test_search_with_paths_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, null, singletonList("/foo/bar"), 0);
new BatchSearchRunner(indexer, new PropertiesProvider(), searchKo, resultConsumer).call();
verify(resultConsumer, never()).apply(eq(searchKo.uuid), eq("mydoc"), anyList());
}
Aggregations