String mongoDocument = copyToStringFromClasspath(TEST_SIMPLE_MONGODB_DOCUMENT_JSON);
DBObject dbObject = (DBObject) JSON.parse(mongoDocument);
mongoCollection.insert(dbObject);
Thread.sleep(wait);
assertThat(getNode().client().admin().indices().exists(new IndicesExistsRequest(index)).actionGet().isExists(), equalTo(true));
refreshIndex(index);
CountResponse countResponse = getNode().client().count(countRequest(index)).actionGet();
assertThat(countResponse.getCount(), equalTo(0L));
mongoCollection.remove(dbObject);
// Wait 5 seconds and store a new document
Thread.sleep(5000);
dbObject = (DBObject) JSON.parse(mongoDocument);
mongoCollection.insert(dbObject);
Thread.sleep(wait);
assertThat(getNode().client().admin().indices().exists(new IndicesExistsRequest(index)).actionGet().isExists(), equalTo(true));
assertThat(getNode().client().admin().indices().prepareTypesExists(index).setTypes(getDatabase()).execute().actionGet()
.isExists(), equalTo(true));
refreshIndex(index);