@Test void testCancelUnknownJobExecution() { String jobExecutionType = "MyJobExecutionType"; String jobExecutionId = "MyJobExecutionId"; EntityType jobExecutionMetadataParent = mock(EntityType.class); when(jobExecutionMetadataParent.getId()).thenReturn("sys_job_JobExecution"); EntityType jobExecutionMetadata = mock(EntityType.class); when(jobExecutionMetadata.getExtends()).thenReturn(jobExecutionMetadataParent); when(dataService.getEntityType(jobExecutionType)).thenReturn(jobExecutionMetadata); assertThrows( UnknownEntityException.class, () -> jobsService.cancel(jobExecutionType, jobExecutionId)); }
@Transactional @Override public void cancel(String jobExecutionType, String jobExecutionId) { EntityType jobExecutionMetadata = dataService.getEntityType(jobExecutionType); if (!isJobExecutionMetadata(jobExecutionMetadata)) { throw new InvalidJobExecutionTypeException(jobExecutionType); } JobExecution jobExecution = (JobExecution) dataService.findOneById(jobExecutionType, jobExecutionId); if (jobExecution == null) { throw new UnknownEntityException(jobExecutionMetadata, jobExecutionId); } jobExecutor.cancel(jobExecution); }
JobsServiceImpl implements JobsService { @Transactional @Override public void cancel(String jobExecutionType, String jobExecutionId) { EntityType jobExecutionMetadata = dataService.getEntityType(jobExecutionType); if (!isJobExecutionMetadata(jobExecutionMetadata)) { throw new InvalidJobExecutionTypeException(jobExecutionType); } JobExecution jobExecution = (JobExecution) dataService.findOneById(jobExecutionType, jobExecutionId); if (jobExecution == null) { throw new UnknownEntityException(jobExecutionMetadata, jobExecutionId); } jobExecutor.cancel(jobExecution); } }
JobsServiceImpl implements JobsService { @Transactional @Override public void cancel(String jobExecutionType, String jobExecutionId) { EntityType jobExecutionMetadata = dataService.getEntityType(jobExecutionType); if (!isJobExecutionMetadata(jobExecutionMetadata)) { throw new InvalidJobExecutionTypeException(jobExecutionType); } JobExecution jobExecution = (JobExecution) dataService.findOneById(jobExecutionType, jobExecutionId); if (jobExecution == null) { throw new UnknownEntityException(jobExecutionMetadata, jobExecutionId); } jobExecutor.cancel(jobExecution); } JobsServiceImpl(DataService dataService, JobExecutor jobExecutor); }
JobsServiceImpl implements JobsService { @Transactional @Override public void cancel(String jobExecutionType, String jobExecutionId) { EntityType jobExecutionMetadata = dataService.getEntityType(jobExecutionType); if (!isJobExecutionMetadata(jobExecutionMetadata)) { throw new InvalidJobExecutionTypeException(jobExecutionType); } JobExecution jobExecution = (JobExecution) dataService.findOneById(jobExecutionType, jobExecutionId); if (jobExecution == null) { throw new UnknownEntityException(jobExecutionMetadata, jobExecutionId); } jobExecutor.cancel(jobExecution); } JobsServiceImpl(DataService dataService, JobExecutor jobExecutor); @Transactional @Override void cancel(String jobExecutionType, String jobExecutionId); }
JobsServiceImpl implements JobsService { @Transactional @Override public void cancel(String jobExecutionType, String jobExecutionId) { EntityType jobExecutionMetadata = dataService.getEntityType(jobExecutionType); if (!isJobExecutionMetadata(jobExecutionMetadata)) { throw new InvalidJobExecutionTypeException(jobExecutionType); } JobExecution jobExecution = (JobExecution) dataService.findOneById(jobExecutionType, jobExecutionId); if (jobExecution == null) { throw new UnknownEntityException(jobExecutionMetadata, jobExecutionId); } jobExecutor.cancel(jobExecution); } JobsServiceImpl(DataService dataService, JobExecutor jobExecutor); @Transactional @Override void cancel(String jobExecutionType, String jobExecutionId);  }