@Test
public void insertWorkflowInstanceWorks() {

  WorkflowInstance i = constructWorkflowInstanceBuilder().setStatus(created).setExternalId("123").setState(null).build();
  when(workflowInstancePreProcessor.process(i)).thenReturn(i);
  when(workflowInstanceDao.insertWorkflowInstance(stored.capture())).thenReturn(42L);
  assertThat(service.insertWorkflowInstance(i), is(42L));
  assertThat(stored.getValue().externalId, is("123"));
  assertThat(stored.getValue().status, is(created));
}