InternalRecord extends InternalMapAccessorWithDefaultValue implements Record { @Override public int index( String key ) { int result = queryKeys.indexOf( key ); if ( result == -1 ) { throw new NoSuchElementException( "Unknown key: " + key ); } else { return result; } } InternalRecord( List<String> keys, Value[] values );  InternalRecord( QueryKeys queryKeys, Value[] values ); @Override List<String> keys(); @Override List<Value> values(); @Override List<Pair<String, Value>> fields(); @Override int index( String key ); @Override boolean containsKey( String key ); @Override Value get( String key ); @Override Value get( int index ); @Override int size(); @Override Map<String, Object> asMap(); @Override Map<String,T> asMap( Function<Value,T> mapper ); @Override String toString(); @Override boolean equals( Object other ); @Override int hashCode();  }
@Test void shouldHaveCorrectFieldIndices() { InternalRecord record = createRecord(); assertThat( record.index( "k1" ), equalTo( 0 ) ); assertThat( record.index( "k2" ), equalTo( 1 ) ); }
@Test void shouldThrowWhenAskingForIndexOfUnknownField() { InternalRecord record = createRecord(); assertThrows( NoSuchElementException.class, () -> record.index( "BATMAN" ) ); }
@Test void testIndex() { InternalRecord record = createRecord(); assertThat( record.index( "k1" ), equalTo( 0 ) ); assertThat( record.index( "k2" ), equalTo( 1 ) ); }