@Test
public void insertWorkflowInstanceWhenPreprocessorThrowsCausesException() {

  WorkflowInstance i = constructWorkflowInstanceBuilder().setType("nonexistent").build();
  when(workflowInstancePreProcessor.process(i)).thenThrow(new RuntimeException("preprocessor reject"));
  RuntimeException thrown = assertThrows(RuntimeException.class, () -> service.insertWorkflowInstance(i));
  assertThat(thrown.getMessage(), containsString("preprocessor reject"));
}