@Before public void setUp() { Store.Configuration configuration = mock(Store.Configuration.class); when(configuration.getResourcePools()) .thenReturn(newResourcePoolsBuilder().heap(10, EntryUnit.ENTRIES).build()); when(configuration.getKeyType()).thenReturn(Long.class); when(configuration.getValueType()).thenReturn(Value.class); when(configuration.getExpiry()).thenReturn(Expirations.noExpiration()); @SuppressWarnings("unchecked") Store.Configuration<Long, Value> config = configuration; Copier<Value> valueCopier = new Copier<Value>() { @Override public Value copyForRead(Value obj) { if (copyForRead) { return new Value(obj.state); } return obj; } @Override public Value copyForWrite(Value obj) { if (copyForWrite) { return new Value(obj.state); } return obj; } }; store = new OnHeapStore<Long, Value>( config, SystemTimeSource.INSTANCE, new IdentityCopier<Long>(), valueCopier, new NoopSizeOfEngine(), NullStoreEventDispatcher.<Long, Value>nullStoreEventDispatcher()); }
@Override public <K, V> Store<K, V> createStore( Store.Configuration<K, V> storeConfig, ServiceConfiguration<?>... serviceConfigs) { ServiceLocator serviceLocator = dependencySet().with(new DefaultSerializationProvider(null)).build(); try { serviceLocator.startAllServices(); } catch (Exception e) { throw new RuntimeException(e); } final Copier defaultCopier = new IdentityCopier(); return new OnHeapStore<K, V>( storeConfig, SystemTimeSource.INSTANCE, defaultCopier, defaultCopier, new NoopSizeOfEngine(), NullStoreEventDispatcher.<K, V>nullStoreEventDispatcher()) { @Override public Map<K, ValueHolder<V>> bulkCompute( Set<? extends K> keys, Function< Iterable<? extends Map.Entry<? extends K, ? extends V>>, Iterable<? extends Map.Entry<? extends K, ? extends V>>> remappingFunction) throws StoreAccessException { throw new StoreAccessException("Problem trying to bulk compute"); } @Override public Map<K, ValueHolder<V>> bulkComputeIfAbsent( Set<? extends K> keys, Function<Iterable<? extends K>, Iterable<? extends Map.Entry<? extends K, ? extends V>>> mappingFunction) throws StoreAccessException { throw new StoreAccessException("Problem trying to bulk compute"); } }; }