@Test
public void shouldReInitializeWFInstanceFromNextCounter() throws Exception {

  when(storage.getLatestStoredCounter(INSTANCE)).thenReturn(Optional.of(INSTANCE_NEW_STATE.counter()));
  when(transaction.workflow(INSTANCE.workflowId())).thenReturn(Optional.of(WORKFLOW));
  stateManager.trigger(INSTANCE, TRIGGER1, PARAMETERS);
  verify(storage).getLatestStoredCounter(INSTANCE);
  verify(transaction).writeActiveState(INSTANCE, INSTANCE_QUEUED_STATE);
  verify(storage).writeEvent(SequenceEvent.create(
      Event.triggerExecution(INSTANCE, TRIGGER1, PARAMETERS),
      INSTANCE_QUEUED_STATE.counter(), NOW.toEpochMilli()));
}