Mockito Test for Elastic Java api client

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.

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());
}

Any idea how to do that?

CC - @swallez

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