Mockito Test for Elastic Java api client

1.1k Views Asked by At

I have tried to mock the response for the below method, but it's not working. Not able to mock the search.hits().hits() method.

Any idea how to do that?

SearchResponse<Product> search = client.search(s -> s
    .index("products")
    .query(q -> q
        .term(t -> t
            .field("name")
            .value(v -> v.stringValue("bicycle"))
        )),
    Product.class);

for (Hit<Product> hit: search.hits().hits()) {
    processProduct(hit.source());
}

Reference for code- https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/connecting.html#_your_first_request

0

There are 0 best solutions below