// Check that the river is started
assertThat(awaitBusy(new Predicate<Object>() {
public boolean apply(Object obj) {
try {
refresh();
GetResponse response = get("_river", getDbName(), "_status");
return response.isExists();
} catch (IndexMissingException e) {
return false;
}
}
}, 5, TimeUnit.SECONDS), equalTo(true));
logger.info(" -> Creating test database [{}]", getDbName());
CouchDBClient.dropAndCreateTestDatabase(getDbName());
logger.info(" -> Inserting [{}] docs in couchdb", nbDocs);
for (int i = 0; i < nbDocs; i++) {
CouchDBClient.putDocument(getDbName(), "" + i, "foo", "bar", "content", "" + i);
}
// Check that docs are still processed by the river
assertThat(awaitBusy(new Predicate<Object>() {
public boolean apply(Object obj) {
try {
refresh();
SearchResponse response = client().prepareSearch(getDbName()).get();
logger.info(" -> got {} docs in {} index", response.getHits().totalHits(), getDbName());
return response.getHits().totalHits() == nbDocs;
} catch (IndexMissingException e) {
return false;
}
}
}, 1, TimeUnit.MINUTES), equalTo(true));