@Test
public void test_run_batch_searches() throws Exception {

    Document[] documents = {createDoc("doc1").build(), createDoc("doc2").build()};
    firstSearchWillReturn(1, documents);
    when(repository.getQueued()).thenReturn(asList(
            new BatchSearch("uuid1", project("test-datashare"), "name1", "desc1", asSet("query1", "query2"), new Date(), BatchSearch.State.RUNNING, User.local()),
            new BatchSearch("uuid2", project("test-datashare"), "name2", "desc1", asSet("query3", "query4"), new Date(), BatchSearch.State.RUNNING, User.local())
    ));
    assertThat(new BatchSearchRunner(indexer, repository, new PropertiesProvider(), local()).call()).isEqualTo(2);
    verify(repository).saveResults("uuid1", "query1", asList(documents));
    verify(repository).setState("uuid1", BatchSearch.State.RUNNING);
    verify(repository).setState("uuid1", BatchSearch.State.SUCCESS);
    verify(repository, never()).saveResults(eq("uuid2"), anyString(), anyList());
}