InternalRecord extends InternalMapAccessorWithDefaultValue implements Record { @Override public List<Value> values() { return Arrays.asList( values ); } 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 mapExtractionShouldPreserveIterationOrder() { List<String> keys = Arrays.asList( "k2", "k1" ); InternalRecord record = new InternalRecord( keys, new Value[]{value( 0 ), value( 1 )} ); Function<Value,Integer> addOne = value -> value.asInt() + 1; Map<String,Integer> map = Extract.map( record, addOne ); assertThat( map.keySet(), contains( "k2", "k1" ) ); Iterator<Integer> values = map.values().iterator(); assertThat( values.next(), equalTo( 1 ) ); assertThat( values.next(), equalTo( 2 ) ); }
@Test void shouldHaveMethodToGetValues() { List<String> keys = Arrays.asList( "k2", "k1" ); Value[] values = new Value[]{value( 0 ), value( 1 )}; InternalRecord record = new InternalRecord( keys, values ); List<Value> appendedValues = record.values(); assertThat( appendedValues, equalTo( Arrays.asList( values ) ) ); }
@Test void emptyValuesShouldGiveEmptyList() { List<String> keys = Collections.emptyList(); Value[] values = new Value[]{}; InternalRecord record = new InternalRecord( keys, values ); List<Value> appendedValues = record.values(); assertThat( appendedValues, equalTo( Arrays.asList( values ) ) ); }