@Test
public void checkIfStateProcessorsAreStuckLogsLongRunningInstance() {

  WorkflowStateProcessor executor1 = mock(WorkflowStateProcessor.class);
  WorkflowStateProcessor executor2 = mock(WorkflowStateProcessor.class);
  when(executor1.getStartTime()).thenReturn(now().minusSeconds(STUCK_THREAD_THRESHOLD + 1));
  when(executor2.getStartTime()).thenReturn(now().minusSeconds(STUCK_THREAD_THRESHOLD));
  factory.processingInstances.put(111L, executor1);
  factory.processingInstances.put(222L, executor2);
  factory.listeners = listeners;
  int potentiallyStuckProcessors = factory.getPotentiallyStuckProcessors();
  assertThat(potentiallyStuckProcessors, is(1));
  verify(executor1).logPotentiallyStuck(anyLong());
  verify(executor2, never()).logPotentiallyStuck(anyLong());
  verify(executor1).handlePotentiallyStuck(any(Duration.class));
  verify(executor2, never()).handlePotentiallyStuck(any(Duration.class));
}