use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class TaskResourceTest method setUp.
@Before
public void setUp() {
PipelineRegistry pipelineRegistry = new PipelineRegistry(new PropertiesProvider());
pipelineRegistry.register(EmailPipeline.class);
configure(new CommonMode(new Properties()) {
@Override
protected void configure() {
bind(TaskFactory.class).toInstance(taskFactory);
bind(Indexer.class).toInstance(mock(Indexer.class));
bind(TaskManager.class).toInstance(taskManager);
bind(PipelineRegistry.class).toInstance(pipelineRegistry);
bind(Filter.class).to(LocalUserFilter.class).asEagerSingleton();
bind(PropertiesProvider.class).toInstance(new PropertiesProvider(getDefaultProperties()));
}
@Override
protected Routes addModeConfiguration(Routes routes) {
return routes.add(TaskResource.class).filter(LocalUserFilter.class);
}
}.createWebConfiguration());
init(taskFactory);
}
use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class TaskResourceTest method test_findNames_should_create_resume.
@Test
public void test_findNames_should_create_resume() {
RestAssert response = post("/api/task/findNames/EMAIL", "{\"options\":{\"waitForNlpApp\": false}}");
response.should().haveType("application/json");
List<String> taskNames = taskManager.waitTasksToBeDone(1, SECONDS).stream().map(t -> t.name).collect(toList());
assertThat(taskNames.size()).isEqualTo(2);
verify(taskFactory).createResumeNlpTask(local(), singleton(Pipeline.Type.EMAIL));
ArgumentCaptor<Pipeline> pipelineArgumentCaptor = ArgumentCaptor.forClass(Pipeline.class);
HashMap<String, String> properties = getDefaultProperties();
properties.put("waitForNlpApp", "false");
verify(taskFactory).createNlpTask(eq(local()), pipelineArgumentCaptor.capture(), eq(new PropertiesProvider(properties).getProperties()), any());
assertThat(pipelineArgumentCaptor.getValue().getType()).isEqualTo(Pipeline.Type.EMAIL);
}
use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class BatchSearchResourceTest method test_get_search_results_csv_with_url_prefix_parameter.
@Test
public void test_get_search_results_csv_with_url_prefix_parameter() {
server.configure(routes -> {
PropertiesProvider propertiesProvider = new PropertiesProvider(new HashMap<String, String>() {
{
put("rootHost", "http://foo.com:12345");
}
});
routes.add(new BatchSearchResource(batchSearchRepository, batchSearchQueue, propertiesProvider)).filter(new LocalUserFilter(propertiesProvider));
});
when(batchSearchRepository.get(User.local(), "batchSearchId")).thenReturn(new BatchSearch(project("prj"), "name", "desc", asSet("q"), User.local()));
when(batchSearchRepository.getResults(User.local(), "batchSearchId", new BatchSearchRepository.WebQuery())).thenReturn(singletonList(new SearchResult("q", "docId", "rootId", Paths.get("/path/to/doc"), new Date(), "content/type", 123L, 1)));
get("/api/batch/search/result/csv/batchSearchId").should().respond(200).haveType("text/csv").haveHeader("Content-Disposition", "attachment;filename=\"batchSearchId.csv\"").contain("\"http://foo.com:12345/#/d/prj/docId/rootId\",\"docId\",\"rootId\"");
}
use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class BatchDownloadRunnerTest method test_max_default_results.
@Test
public void test_max_default_results() throws Exception {
Document[] documents = IntStream.range(0, 3).mapToObj(i -> createDoc("doc" + i).with(createFile(i)).build()).toArray(Document[]::new);
mockSearch.willReturn(2, documents);
File zip = new BatchDownloadRunner(indexer, new PropertiesProvider(new HashMap<String, String>() {
{
put(BATCH_DOWNLOAD_MAX_NB_FILES, "3");
put(SCROLL_SIZE, "3");
}
}), new BatchDownload(project("test-datashare"), User.local(), "query"), updater).call();
assertThat(new ZipFile(zip).size()).isEqualTo(3);
}
use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class BatchSearchRunnerIntTest method test_search_with_paths_ok.
@Test
public void test_search_with_paths_ok() throws Exception {
Document mydoc = createDoc("mydoc").build();
indexer.add(TEST_INDEX, mydoc);
BatchSearch searchOk = new BatchSearch(project(TEST_INDEX), "name", "desc", asSet("mydoc"), User.local(), false, null, singletonList("/path/to"), 0);
new BatchSearchRunner(indexer, new PropertiesProvider(), searchOk, resultConsumer).call();
verify(resultConsumer).apply(searchOk.uuid, "mydoc", singletonList(mydoc));
}
Aggregations