use of net.codestory.rest.RestAssert in project datashare by ICIJ.
the class TaskResourceTest method test_index_and_scan_default_directory.
@Test
public void test_index_and_scan_default_directory() {
RestAssert response = post("/api/task/batchUpdate/index/file", "{}");
HashMap<String, String> properties = getDefaultProperties();
properties.put("foo", "bar");
response.should().respond(200).haveType("application/json");
verify(taskFactory).createScanTask(local(), "extract:queue", Paths.get("/default/data/dir"), new PropertiesProvider(properties).getProperties());
}
use of net.codestory.rest.RestAssert in project datashare by ICIJ.
the class TaskResourceTest method test_run_batch_search.
@Test
public void test_run_batch_search() {
RestAssert response = post("/api/task/batchSearch", "{}");
response.should().respond(200).haveType("application/json");
verify(taskFactory).createBatchSearchLoop();
}
use of net.codestory.rest.RestAssert in project datashare by ICIJ.
the class TaskResourceTest method test_findNames_with_resume_false_should_not_launch_resume_task.
@Test
public void test_findNames_with_resume_false_should_not_launch_resume_task() {
RestAssert response = post("/api/task/findNames/EMAIL", "{\"options\":{\"resume\":\"false\", \"waitForNlpApp\": false}}");
response.should().haveType("application/json");
verify(taskFactory, never()).createResumeNlpTask(null, singleton(Pipeline.Type.OPENNLP));
}
use of net.codestory.rest.RestAssert in project datashare by ICIJ.
the class TaskResourceTest method test_findNames_with_options_should_merge_with_property_provider.
@Test
public void test_findNames_with_options_should_merge_with_property_provider() {
RestAssert response = post("/api/task/findNames/EMAIL", "{\"options\":{\"waitForNlpApp\": false, \"key\":\"val\",\"foo\":\"loo\"}}");
response.should().haveType("application/json");
verify(taskFactory).createResumeNlpTask(local(), singleton(Pipeline.Type.EMAIL));
ArgumentCaptor<Pipeline> pipelineCaptor = ArgumentCaptor.forClass(Pipeline.class);
ArgumentCaptor<Properties> propertiesCaptor = ArgumentCaptor.forClass(Properties.class);
verify(taskFactory).createNlpTask(eq(local()), pipelineCaptor.capture(), propertiesCaptor.capture(), any());
assertThat(propertiesCaptor.getValue()).includes(entry("key", "val"), entry("foo", "loo"));
assertThat(pipelineCaptor.getValue().getType()).isEqualTo(Pipeline.Type.EMAIL);
}
use of net.codestory.rest.RestAssert in project datashare by ICIJ.
the class TaskResourceTest method test_index_directory.
@Test
public void test_index_directory() {
RestAssert response = post("/api/task/batchUpdate/index/file/" + getClass().getResource("/docs/").getPath().substring(1), "{}");
ShouldChain responseBody = response.should().haveType("application/json");
List<String> taskNames = taskManager.waitTasksToBeDone(1, SECONDS).stream().map(t -> t.name).collect(toList());
responseBody.should().contain(format("{\"name\":\"%s\"", taskNames.get(0)));
responseBody.should().contain(format("{\"name\":\"%s\"", taskNames.get(1)));
}
Aggregations