private IncidentQuery setupMockIncidentQuery(IList <Incident> incidents) { IncidentQuery sampleQuery = mock(typeof(IncidentQuery)); when(sampleQuery.incidentId(anyString())).thenReturn(sampleQuery); when(sampleQuery.singleResult()).thenReturn(mock(typeof(Incident))); mockRuntimeService = mock(typeof(RuntimeServiceImpl)); when(processEngine.RuntimeService).thenReturn(mockRuntimeService); when(mockRuntimeService.createIncidentQuery()).thenReturn(sampleQuery); return(sampleQuery); }