@Test
public void shouldDecrementShardWithNoExcessUsage() throws IOException {

  // init counter
  assertEquals(0, shardedCounter.getCounter(COUNTER_ID1));
  updateShard(COUNTER_ID1, 0, 1);
  updateShard(COUNTER_ID1, 1, 1);
  updateLimitInStorage(COUNTER_ID1, 2);
  // Invalidate snapshot to force pull changes from Datastore emulator
  shardedCounter.inMemSnapshot.invalidate(COUNTER_ID1);
  // assert cache is updated with the new value
  assertEquals(2L, shardedCounter.getCounter(COUNTER_ID1));
  //decrement counter by 1
  updateCounterInTransaction(COUNTER_ID1, -1L);
  assertThat(1L,
      either(is(datastore.get(getKey(COUNTER_ID1, 0)).getLong(PROPERTY_SHARD_VALUE)))
          .or(is(datastore.get(getKey(COUNTER_ID1, 1)).getLong(PROPERTY_SHARD_VALUE))));
  // assert cache is updated with the new value
  shardedCounter.inMemSnapshot.invalidate(COUNTER_ID1);
  assertEquals(1L, shardedCounter.getCounter(COUNTER_ID1));
}