use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class BatchDownloadRunnerTest method test_elasticsearch_status_exception__should_be_sent.
@Test(expected = ElasticsearchStatusException.class)
public void test_elasticsearch_status_exception__should_be_sent() throws Exception {
mockSearch.willThrow(new ElasticsearchStatusException("error", RestStatus.BAD_REQUEST, new RuntimeException()));
new BatchDownloadRunner(indexer, new PropertiesProvider(), new BatchDownload(project("test-datashare"), User.local(), "query"), updater).call();
}
use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class BatchDownloadRunnerTest method test_max_zip_size.
@Test
public void test_max_zip_size() throws Exception {
Document[] documents = IntStream.range(0, 3).mapToObj(i -> createDoc("doc" + i).with(createFile(i)).with("hello world " + i).build()).toArray(Document[]::new);
mockSearch.willReturn(2, documents);
File zip = new BatchDownloadRunner(indexer, new PropertiesProvider(new HashMap<String, String>() {
{
put(BATCH_DOWNLOAD_MAX_SIZE, valueOf("hello world 1".getBytes(StandardCharsets.UTF_8).length * 3));
put(SCROLL_SIZE, "3");
}
}), new BatchDownload(project("test-datashare"), User.local(), "query"), updater).call();
assertThat(new ZipFile(zip).size()).isEqualTo(4);
}
use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class RootResourcePluginTest method setUp.
@Before
public void setUp() {
propertiesProvider = new PropertiesProvider(new HashMap<String, String>() {
{
put("pluginsDir", folder.getRoot().toString());
}
});
server.configure(routes -> routes.add(new RootResource(propertiesProvider)).bind("/plugins", folder.getRoot()).filter(new LocalUserFilter(new PropertiesProvider())));
}
use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class SettingsResourceTest method test_patch_configuration.
@Test
public void test_patch_configuration() throws IOException {
File settings = folder.newFile("file.settings");
Files.write(settings.toPath(), asList("foo=doe", "bar=baz"));
configure(routes -> routes.add(new SettingsResource(new PropertiesProvider(settings.getAbsolutePath()))).filter(new BasicAuthFilter("/", "icij", singleUser(local()))));
patch("/api/settings", "{\"data\": {\"foo\": \"qux\", \"xyzzy\":\"fred\"}}").withPreemptiveAuthentication("local", "pass").should().respond(200);
Properties properties = new PropertiesProvider(settings.getAbsolutePath()).getProperties();
assertThat(properties).includes(entry("foo", "qux"), entry("bar", "baz"), entry("xyzzy", "fred"));
}
use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class TaskResourceTest method test_index_and_scan_directory_with_options.
@Test
public void test_index_and_scan_directory_with_options() {
String path = getClass().getResource("/docs/").getPath();
RestAssert response = post("/api/task/batchUpdate/index/" + path.substring(1), "{\"options\":{\"foo\":\"baz\",\"key\":\"val\"}}");
response.should().haveType("application/json");
HashMap<String, String> defaultProperties = getDefaultProperties();
defaultProperties.put("foo", "baz");
defaultProperties.put("key", "val");
verify(taskFactory).createIndexTask(local(), "extract:queue", new PropertiesProvider(defaultProperties).getProperties());
verify(taskFactory).createScanTask(local(), "extract:queue", Paths.get(path), new PropertiesProvider(defaultProperties).getProperties());
}
Aggregations