CheckedDatastoreReaderWriter { <T> List<T> query(Query<T> query) throws IOException { return call(() -> ImmutableList.copyOf(rw.run(query))); } CheckedDatastoreReaderWriter(DatastoreReaderWriter rw);   }
@Test public void query() throws IOException { when(rw.run(query)).thenReturn(queryResults); when(queryResults.results()).thenReturn(Stream.of(entity1, entity2).iterator()); assertThat(sut.query(query), contains(entity1, entity2)); verify(rw).run(query); }