InternalResult implements Result { @Override public Record single() { return blockingGet( cursor.singleAsync() ); } InternalResult(Connection connection, ResultCursor cursor ); @Override List<String> keys(); @Override boolean hasNext(); @Override Record next(); @Override Record single(); @Override Record peek(); @Override Stream<Record> stream(); @Override List<Record> list(); @Override List<T> list( Function<Record, T> mapFunction ); @Override ResultSummary consume(); @Override void remove();  }
@Test void singleShouldWorkAsExpected() { assertNotNull( createResult( 1 ).single() ); }
@Test void singleShouldThrowOnBigResult() { assertThrows( NoSuchRecordException.class, () -> createResult( 42 ).single() ); }
@Test void singleShouldThrowOnEmptyResult() { assertThrows( NoSuchRecordException.class, () -> createResult( 0 ).single() ); }
@Test void accessingOutOfBoundsShouldBeNull() { Result result = createResult( 1 ); Record record = result.single(); assertThat( record.get( 0 ), equalTo( value( "v1-1" ) ) ); assertThat( record.get( 1 ), equalTo( value( "v2-1" ) ) ); assertThat( record.get( 2 ), equalTo( NullValue.NULL ) ); assertThat( record.get( -37 ), equalTo( NullValue.NULL ) ); }