@Test
public void fakePostgreSQLpollNextWorkflowInstances() {

  JdbcTemplate j = mock(JdbcTemplate.class);
  WorkflowInstanceDao d = preparePostgreSQLDao(j);
  ArgumentCaptor<String> sql = ArgumentCaptor.forClass(String.class);
  when(j.queryForList(sql.capture(), eq(Long.class))).thenReturn(asList(1L, 2L, 3L));
  assertThat(d.pollNextWorkflowInstanceIds(5), is(asList(1L, 2L, 3L)));
  assertEquals(
      "update nflow_workflow set executor_id = 42, status = 'executing'::workflow_status, external_next_activation = null where id in (select id from nflow_workflow where executor_id is null and status in ('created'::workflow_status, 'inProgress'::workflow_status) and next_activation <= current_timestamp and group matches order by priority desc, next_activation asc limit 5 for update skip locked) and executor_id is null returning id",
      sql.getValue());
}