@Override
  public void storeRowInCache( DatabaseLookupMeta meta, RowMetaInterface lookupMeta, Object[] lookupRow,
                               Object[] add ) {
    RowMetaAndData rowMetaAndData = new RowMetaAndData( lookupMeta, lookupRow );
    if ( !map.containsKey( rowMetaAndData ) ) {
      map.put( rowMetaAndData, add );
    }

    // DEinspanjer 2009-02-01: If you had previously set a cache size and then turned on load all, this
    // method would throw out entries if the previous cache size wasn't big enough.
    if ( !meta.isLoadingAllDataInCache() && meta.getCacheSize() > 0 && map.size() > meta.getCacheSize() ) {
      map.remove( map.entrySet().iterator().next().getKey() );
    }
  }
@Test
  public void storeRowInCacheTest() throws Exception {
    DatabaseLookupData databaseLookupData = mock( DatabaseLookupData.class );
    DatabaseLookupMeta databaseLookupMeta = mock( DatabaseLookupMeta.class );
    DefaultCache defaultCache = new DefaultCache( databaseLookupData, 10 );
    when( databaseLookupMeta.isLoadingAllDataInCache() ).thenReturn( true );
    RowMeta rowMeta = new RowMeta();
    //Several inserts with different key and different values
    for ( int i = 1; i <= 10; ++i ) {
      defaultCache.storeRowInCache( databaseLookupMeta, rowMeta, new Object[]{i}, new Object[]{ i * 100 } );
    }
    LinkedHashMap<RowMetaAndData, Object[]> map = (LinkedHashMap<RowMetaAndData, Object[]>) getInternalState( defaultCache, "map" );
    //All inserted entries expected
    assertEquals( 10, map.size() );
  }