@Test
void cleanup() {

  ClearScrollRequestBuilder requestBuilder = mock(ClearScrollRequestBuilder.class);
  when(nodeClient.prepareClearScroll()).thenReturn(requestBuilder);
  when(requestBuilder.addScrollId(any())).thenReturn(requestBuilder);
  when(requestBuilder.get()).thenReturn(null);
  ElasticsearchNodeClient client =
      new ElasticsearchNodeClient(mock(ClusterService.class), nodeClient);
  ElasticsearchScrollRequest request = new ElasticsearchScrollRequest("test", factory);
  request.setScrollId("scroll123");
  client.cleanup(request);
  assertFalse(request.isScrollStarted());
  InOrder inOrder = Mockito.inOrder(nodeClient, requestBuilder);
  inOrder.verify(nodeClient).prepareClearScroll();
  inOrder.verify(requestBuilder).addScrollId("scroll123");
  inOrder.verify(requestBuilder).get();
}