@SuppressWarnings("unchecked") @Test void testSubmitExecutorService() throws ExecutionException, InterruptedException { ExecutorService myExecutorService = mock(ExecutorService.class); String jobExecutionEntityTypeId = "MyJobExecutionId"; EntityType jobExecutionEntityType = mock(EntityType.class); when(jobExecutionEntityType.getId()).thenReturn(jobExecutionEntityTypeId); JobExecution jobExecution = mock(JobExecution.class); when(jobExecution.getEntityType()).thenReturn(jobExecutionEntityType); Job job = mock(Job.class); JobFactory jobFactory = mock(JobFactory.class); when(jobFactoryRegistry.getJobFactory(jobExecution)).thenReturn(jobFactory); when(jobFactory.createJob(jobExecution)).thenReturn(job); JobExecutionContext jobExecutionContext = mock(JobExecutionContext.class); when(jobExecutionContextFactory.createJobExecutionContext(jobExecution)) .thenReturn(jobExecutionContext); Progress progress = mock(Progress.class); when(jobExecutionRegistry.registerJobExecution(jobExecution)).thenReturn(progress); doAnswer( (InvocationOnMock invocation) -> { ((Runnable) invocation.getArguments()[0]).run(); return null; }) .when(myExecutorService) .execute(any(Runnable.class)); jobExecutor.submit(jobExecution, myExecutorService).get(); verify(dataService).add(jobExecutionEntityTypeId, jobExecution); verify(jobExecutionTemplate).call(job, progress, jobExecutionContext); verify(jobExecutionRegistry).unregisterJobExecution(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);  }