### Question:
FluentCursor extends CrossProcessCursorWrapper { public <T> FluentIterable<T> toFluentIterable(Function<? super Cursor, T> singleRowTransform) { try { return Cursors.toFluentIterable(this, singleRowTransform); } finally { close(); } } FluentCursor(Cursor cursor); FluentIterable<T> toFluentIterable(Function<? super Cursor, T> singleRowTransform); LazyCursorList<T> toLazyCursorList(Function<? super Cursor, T> singleRowTransform); LinkedHashMultimap<TKey, TValue> toMultimap(Function<? super Cursor, TKey> keyTransform, Function<? super Cursor, TValue> valueTransform); LinkedHashMap<TKey, TValue> toMap(Function<? super Cursor, TKey> keyTransform, Function<? super Cursor, TValue> valueTransform); T toOnlyElement(Function<? super Cursor, T> singleRowTransform); T toOnlyElement(Function<? super Cursor, T> singleRowTransform, T defaultValue); int toRowCount(); FluentCursor withNotificationUri(ContentResolver resolver, Uri uri);  }### Answer:
@Test public void shouldAcceptFunctionsOperatingOnObject() throws Exception { new FluentCursor(null).toFluentIterable(Functions.constant(1L)); }
@Test public void shouldCloseCursorAfterItIsTransformed() throws Exception { final MatrixCursor cursor = new MatrixCursor(new String[] { TEST_COLUMN }); final FluentCursor fluentCursor = new FluentCursor(cursor); fluentCursor.toFluentIterable(Functions.constant(null)); assertThat(fluentCursor.isClosed()).isTrue(); }
@Test public void shouldApplyGivenFunctionOnEverySingleRow() throws Exception { final MatrixCursor cursor = buildMatrixCursor(10); final FluentCursor fluentCursor = new FluentCursor(cursor); final FluentIterable<Long> transformed = fluentCursor.toFluentIterable(new Function<Cursor, Long>() { @Override public Long apply(Cursor cursor) { return cursor.getLong(cursor.getColumnIndexOrThrow(TEST_COLUMN)); } }); assertThat(transformed).hasSize(cursor.getCount()); assertThat(transformed.allMatch(new Predicate<Long>() { @Override public boolean apply(Long aLong) { return aLong.equals(18L); } })).isTrue(); }
@Test public void shouldAlwaysCloseCursorAfterCallingToFluentIterable() throws Exception { final FluentCursor fluentCursor = new FluentCursor(buildMatrixCursor(10)); try { fluentCursor.toFluentIterable(KABOOM); } catch (Throwable t) { } assertThat(fluentCursor.isClosed()).isTrue(); }