@Test
public void testSearchFactsWithSearchResult() {

  UUID id = UUID.randomUUID();
  FactDocument document = new FactDocument().setId(id);
  FactEntity entity = new FactEntity().setId(id);
  FactRecord record = new FactRecord().setId(id);
  FactSearchCriteria criteria = createFactSearchCriteria();
  when(factSearchManager.searchFacts(criteria)).thenReturn(ScrollingSearchResult.<FactDocument>builder()
          .setInitialBatch(new ScrollingSearchResult.ScrollingBatch<>("TEST_SCROLL_ID",
                  ListUtils.list(document).iterator(), true))
          .setCount(1)
          .build());
  when(factManager.getFacts(anyList())).thenReturn(ListUtils.list(entity).iterator());
  when(factRecordConverter.fromEntity(entity)).thenReturn(record);
  ResultContainer<FactRecord> container = dao.searchFacts(criteria);
  assertEquals(1, container.getCount());
  assertEquals(ListUtils.list(record), ListUtils.list(container));
  verify(factSearchManager).searchFacts(criteria);
  verify(factManager).getFacts(argThat(list -> list.contains(id)));
  verify(factRecordConverter).fromEntity(entity);
}