Hi, I have a service which uses RestHighLevelClient and which I want to unit test. I have a method that has the following lines:
....
IndexRequest request = new IndexRequest(index, type).source(getContentBuilder(update));
IndexResponse response = restHighLevelClient.index(request);
return response.getResult() == CREATED;
....
So, in my test I'm trying to do the following:
@Mock
RestHighLevelClient esClient = Mockito.mock(RestHighLevelClient.class);
@InjectMocks
MyService updateService;
And directly in the test:
when(esClient.index(any(IndexRequest.class)))
.thenReturn(new IndexResponse());
But I get the NullPointerExeption in this line.
I found information that we cannot mock RestHighLevelClient. I would like to get more details about it. So, is it possible to test my method using something like that?
Thanks in advance