ShardedCounterSnapshotFactory implements CounterSnapshotFactory { public ShardedCounter.Snapshot create(String counterId) throws IOException { return new ShardedCounter.Snapshot(counterId, ShardedCounter.getLimit(storage, counterId), getShards(storage, counterId)); } ShardedCounterSnapshotFactory(Storage storage); ShardedCounter.Snapshot create(String counterId);  }
@Test public void testCreate() throws IOException { counterSnapshotFactory.create(RESOURCE_ID); assertEquals(128, storage.shardsForCounter(RESOURCE_ID).size()); }
@Test public void testSpeedOfCreate() throws IOException { counterSnapshotFactory.create(RESOURCE_ID); verify(storage, times(NUM_SHARDS / TRANSACTION_GROUP_SIZE + 1)).runInTransactionWithRetries(any()); assertEquals(128, storage.shardsForCounter(RESOURCE_ID).size()); }