use of org.icij.datashare.batch.BatchSearch in project datashare by ICIJ.
the class BatchSearchResourceTest method testTripleQuote.
private void testTripleQuote(Boolean phraseMatch, String query, String tripleQuoteResult) {
when(batchSearchRepository.save(any())).thenReturn(true);
Response response = postRaw("/api/batch/search/prj", "multipart/form-data;boundary=AaB03x", new MultipartContentBuilder("AaB03x").addField("name", "my batch search").addFile(new FileUpload("csvFile").withFilename("search.csv").withContentType("text/csv").withContent(query + "\"query two\"\r\n" + "query three\r\n" + "query\" four\r\n")).addField("phrase_matches", String.valueOf(phraseMatch)).build()).response();
assertThat(response.code()).isEqualTo(200);
ArgumentCaptor<BatchSearch> argument = ArgumentCaptor.forClass(BatchSearch.class);
verify(batchSearchRepository).save(argument.capture());
assertThat(argument.getValue().queries.keySet()).containsOnly(tripleQuoteResult, "\"query two\"", "query three", "query\" four");
}
use of org.icij.datashare.batch.BatchSearch in project datashare by ICIJ.
the class BatchSearchResourceTest method test_get_queries_json.
@Test
public void test_get_queries_json() {
when(batchSearchRepository.get(User.local(), "batchSearchId")).thenReturn(new BatchSearch(project("prj"), "name", "desc", asSet("q1", "q2"), User.local()));
get("/api/batch/search/batchSearchId/queries").should().respond(200).haveType("application/json;charset=UTF-8").contain("[\"q1\",\"q2\"]");
}
use of org.icij.datashare.batch.BatchSearch in project datashare by ICIJ.
the class BatchSearchResourceTest method test_upload_batch_search_csv_with_name_and_csvfile_should_send_OK.
@Test
public void test_upload_batch_search_csv_with_name_and_csvfile_should_send_OK() throws InterruptedException {
when(batchSearchRepository.save(any())).thenReturn(true);
Response response = postRaw("/api/batch/search/prj", "multipart/form-data;boundary=AaB03x", new MultipartContentBuilder("AaB03x").addField("name", "nameValue").addFile(new FileUpload("csvFile").withContent("query\r\néèàç\r\n")).build()).response();
assertThat(response.code()).isEqualTo(200);
BatchSearch expected = new BatchSearch(response.content(), project("prj"), "nameValue", null, asSet("query", "éèàç"), new Date(), BatchSearch.State.QUEUED, User.local());
verify(batchSearchRepository).save(eq(expected));
assertThat(batchSearchQueue.take()).isEqualTo(expected.uuid);
}
use of org.icij.datashare.batch.BatchSearch 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());
}
use of org.icij.datashare.batch.BatchSearch in project datashare by ICIJ.
the class BatchSearchRunnerIntTest method test_search_with_phraseMatches_with_ner.
@Test
public void test_search_with_phraseMatches_with_ner() throws Exception {
Document mydoc = createDoc("docId").with("anne's doc to find").build();
indexer.add(TEST_INDEX, mydoc);
indexer.add(TEST_INDEX, NamedEntity.create(NamedEntity.Category.PERSON, "anne", asList(12L), mydoc.getId(), mydoc.getRootDocument(), Pipeline.Type.CORENLP, Language.FRENCH));
BatchSearch searchKo = new BatchSearch(project(TEST_INDEX), "name", "desc", asSet("anne doc"), User.local(), false, null, null, true);
BatchSearch searchOk = new BatchSearch(project(TEST_INDEX), "name", "desc", asSet("anne's doc"), User.local(), false, null, null, true);
new BatchSearchRunner(indexer, new PropertiesProvider(), searchKo, resultConsumer).call();
new BatchSearchRunner(indexer, new PropertiesProvider(), searchOk, resultConsumer).call();
verify(resultConsumer, never()).apply(eq(searchKo.uuid), eq("anne doc"), anyList());
verify(resultConsumer).apply(searchOk.uuid, "anne's doc", singletonList(mydoc));
}
Aggregations