@Test void testSubmitJobCreationFails() { String jobExecutionEntityTypeId = "MyJobExecutionId"; EntityType jobExecutionEntityType = mock(EntityType.class); when(jobExecutionEntityType.getId()).thenReturn(jobExecutionEntityTypeId); JobExecution jobExecution = mock(JobExecution.class); when(jobExecution.getEntityType()).thenReturn(jobExecutionEntityType); doThrow(new RuntimeException()).when(jobFactoryRegistry).getJobFactory(jobExecution); assertThrows(RuntimeException.class, () -> jobExecutor.submit(jobExecution)); verify(dataService).add(jobExecutionEntityTypeId, jobExecution); verify(jobExecution).setStatus(Status.FAILED); verify(dataService).update(jobExecutionEntityTypeId, jobExecution); }
public CompletableFuture<Void> submit(JobExecution jobExecution) { return submit(jobExecution, executorService); }
JobExecutor { public CompletableFuture<Void> submit(JobExecution jobExecution) { return submit(jobExecution, executorService); } }
JobExecutor { public CompletableFuture<Void> submit(JobExecution jobExecution) { return submit(jobExecution, executorService); } JobExecutor(
      DataService dataService,
      EntityManager entityManager,
      ExecutorService executorService,
      JobFactoryRegistry jobFactoryRegistry,
      JobExecutionContextFactory jobExecutionContextFactory,
      JobExecutionRegistry jobExecutionRegistry); }
JobExecutor { public CompletableFuture<Void> submit(JobExecution jobExecution) { return submit(jobExecution, executorService); } JobExecutor(
      DataService dataService,
      EntityManager entityManager,
      ExecutorService executorService,
      JobFactoryRegistry jobFactoryRegistry,
      JobExecutionContextFactory jobExecutionContextFactory,
      JobExecutionRegistry jobExecutionRegistry); @RunAsSystem void executeScheduledJob(String scheduledJobId); CompletableFuture<Void> submit(JobExecution jobExecution); CompletableFuture<Void> submit(
      JobExecution jobExecution, ExecutorService executorService); void cancel(JobExecution jobExecution); }
JobExecutor { public CompletableFuture<Void> submit(JobExecution jobExecution) { return submit(jobExecution, executorService); } JobExecutor(
      DataService dataService,
      EntityManager entityManager,
      ExecutorService executorService,
      JobFactoryRegistry jobFactoryRegistry,
      JobExecutionContextFactory jobExecutionContextFactory,
      JobExecutionRegistry jobExecutionRegistry); @RunAsSystem void executeScheduledJob(String scheduledJobId); CompletableFuture<Void> submit(JobExecution jobExecution); CompletableFuture<Void> submit(
      JobExecution jobExecution, ExecutorService executorService); void cancel(JobExecution jobExecution);  }