@Test
public void shouldFailToUpdateResourceCountersOnDequeueDueToCapacityAndNoInfoEventSent() throws Exception {

  final Set<Resource> resources = ImmutableSet.of(Resource.create("resource1", 1));
  final List<String> resourceIds = resources.stream().map(Resource::id).sorted().collect(toList());
  final Message message = Message.info(String.format("Resource limit reached for: %s", resourceIds));
  final RunState runState = RunState.create(INSTANCE, State.QUEUED,
      STATE_DATA_1.builder().messages(message).build(),
      NOW.minusMillis(1), 17);
  when(transaction.readActiveState(INSTANCE)).thenReturn(Optional.of(runState));
  doThrow(new CounterCapacityException("foo"))
      .when(transaction).updateCounter(shardedCounter, "resource1", 1);
  final Event dequeueEvent = Event.dequeue(INSTANCE,
      resources.stream().map(Resource::id).collect(toSet()));
  final PersistentStateManager spied = spy(stateManager);
  try {
    spied.receive(dequeueEvent);
    fail();
  } catch (Exception e) {
    // expected exception
  }
  verify(spied, never()).receiveIgnoreClosed(eq(Event.info(INSTANCE, message)), anyLong());
}