@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 storeRowInCacheSameIdTest() {
    DatabaseLookupData databaseLookupData = mock( DatabaseLookupData.class );
    DatabaseLookupMeta databaseLookupMeta = mock( DatabaseLookupMeta.class );
    DefaultCache defaultCache = new DefaultCache( databaseLookupData, 10 );
    //Several inserts with the same key and different values
    RowMeta rowMeta1 = new RowMeta(  );
    RowMeta rowMeta2 = new RowMeta(  );
    RowMeta rowMeta3 = new RowMeta(  );
    defaultCache.storeRowInCache( databaseLookupMeta, rowMeta1, new Object[]{1}, new Object[]{ 100 } );
    defaultCache.storeRowInCache( databaseLookupMeta, rowMeta2, new Object[]{1}, new Object[]{ 200 } );
    defaultCache.storeRowInCache( databaseLookupMeta, rowMeta3, new Object[]{1}, new Object[]{ 300 } );
    LinkedHashMap<RowMetaAndData, Object[]> map = (LinkedHashMap<RowMetaAndData, Object[]>) getInternalState( defaultCache, "map" );
    //Only one entry expected
    assertEquals( 1, map.size() );
    //The value expected is the first one inserted
    assertEquals( 100, map.get( new RowMetaAndData( rowMeta1, new Object[]{1} ) )[0] );
  }