# Mocking HighlevelRestClient in junit

**URL:** <https://discuss.elastic.co/t/mocking-highlevelrestclient-in-junit/179612>\
**Category:** Elasticsearch\
**Created:** [May 4, 2019, 10:42am UTC](https://discuss.elastic.co/t/mocking-highlevelrestclient-in-junit/179612 "2019-05-04T10:42:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AshwiniD15](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ashwinid15/32/41348_2.png) [@AshwiniD15](https://discuss.elastic.co/u/AshwiniD15)\
**Post date:** [May 4, 2019, 10:42am UTC](https://discuss.elastic.co/t/mocking-highlevelrestclient-in-junit/179612/1 "2019-05-04T10:42:14Z")

</div>

I am using HighlevelRestClient for fetching the data from elasticsearch.while adding junit , mocking it and it is getting mocked but low level rest client is null. Tried with extending ESTestCase as well . But unable to add it.can you suggest on it

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 1, 2019, 10:42am UTC](https://discuss.elastic.co/t/mocking-highlevelrestclient-in-junit/179612/2 "2019-06-01T10:42:19Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
