@Inject
private RestHighLevelClient esClient;
public SearchResponse getData(SearchRequest searchRequest) {
try {
SearchResponse searchResponse = esClient.search(searchRequest, RequestOptions.DEFAULT);
log.info("Successfully fetched the data from ES");
return searchResponse;
} catch (ElasticsearchException e) {
log.error("ES exception occurs on fetching data.");
} catch (IOException e) {
log.error("Runtime exception occurs on fetching data from ES.");
}
}
I have tried several way to write the unit test of it but sometime it gives null pointer exception, sometime can not mock a final class, final method etc. I have tried almost every way. So can anyone help me here by saying how I should write the unit test for this method.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.