use of org.icij.datashare.batch.SearchResult in project datashare by ICIJ.
the class BatchSearchResourceTest method test_get_search_results_csv.
@Test
public void test_get_search_results_csv() {
when(batchSearchRepository.get(User.local(), "batchSearchId")).thenReturn(new BatchSearch(project("prj"), "name", "desc", asSet("q1", "q2"), User.local()));
when(batchSearchRepository.getResults(User.local(), "batchSearchId", new BatchSearchRepository.WebQuery())).thenReturn(asList(new SearchResult("q1", "docId1", "rootId1", Paths.get("/path/to/doc1"), new Date(), "content/type", 123L, 1), new SearchResult("q2", "docId2", "rootId2", Paths.get("/path/to/doc2"), new Date(), "content/type", 123L, 2)));
get("/api/batch/search/result/csv/batchSearchId").should().respond(200).haveType("text/csv").haveHeader("Content-Disposition", "attachment;filename=\"batchSearchId.csv\"").contain(format("\"localhost:%d/#/d/prj/docId1/rootId1\",\"docId1\",\"rootId1\"", port())).contain(format("\"localhost:%d/#/d/prj/docId2/rootId2\",\"docId2\",\"rootId2\"", port()));
}
use of org.icij.datashare.batch.SearchResult 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\"");
}
Aggregations