@Test
public void test_run_batch_search_with_throttle_should_not_last_more_than_max_time() throws Exception {

    firstSearchWillReturn(5, createDoc("doc").build());
    when(repository.getQueued()).thenReturn(singletonList(
        new BatchSearch("uuid1", project("test-datashare"), "name1", "desc1", asSet("query1", "query2"), new Date(), BatchSearch.State.RUNNING, User.local())
    ));
    Date beforeBatch  = timeRule.now;
    new BatchSearchRunner(indexer, repository, new PropertiesProvider(new HashMap<String, String>() {{
        put(BATCH_SEARCH_THROTTLE, "1000");
        put(BATCH_SEARCH_MAX_TIME, "1");
    }}), local()).call();
    assertThat(timeRule.now().getTime() - beforeBatch.getTime()).isEqualTo(1000);
}