@Before
  public void setUp() throws Exception {
    ElasticsearchUtils.setMapper(mapper);
    DataStore dataStore = TestUtils.getDataStore();

    // Initializing Cache Factory
    hazelcastInstance = new TestHazelcastInstanceFactory(1).newHazelcastInstance();
    HazelcastConnection hazelcastConnection = Mockito.mock(HazelcastConnection.class);
    when(hazelcastConnection.getHazelcast()).thenReturn(hazelcastInstance);
    CacheUtils.setCacheFactory(new DistributedCacheFactory(hazelcastConnection, mapper));

    elasticsearchServer = new MockElasticsearchServer(UUID.randomUUID().toString());
    ElasticsearchConnection elasticsearchConnection = Mockito.mock(ElasticsearchConnection.class);
    when(elasticsearchConnection.getClient()).thenReturn(elasticsearchServer.getClient());
    ElasticsearchUtils.initializeMappings(elasticsearchServer.getClient());

    // Ensure that table exists before saving/reading data from it
    TableMetadataManager tableMetadataManager = Mockito.mock(TableMetadataManager.class);
    when(tableMetadataManager.exists(TestUtils.TEST_TABLE_NAME)).thenReturn(true);
    when(tableMetadataManager.get(anyString())).thenReturn(TestUtils.TEST_TABLE);
    QueryStore queryStore =
        new ElasticsearchQueryStore(tableMetadataManager, elasticsearchConnection, dataStore);
    AnalyticsLoader analyticsLoader =
        new AnalyticsLoader(tableMetadataManager, dataStore, queryStore, elasticsearchConnection);
    TestUtils.registerActions(analyticsLoader, mapper);
    ExecutorService executorService = Executors.newFixedThreadPool(1);
    queryExecutor = new QueryExecutor(analyticsLoader, executorService);
    queryStore.save(TestUtils.TEST_TABLE_NAME, TestUtils.getQueryDocuments(mapper));
  }