JobExecutionFeService extends CommonFeService { public void stopJobExecution(final Long jobExecutionId, final String applicationInstanceId) { final LightminClientApplication lightminClientApplication = this.findLightminClientApplicatonById(applicationInstanceId); try { this.jobServerService.stopJobExecution(jobExecutionId, lightminClientApplication); } catch (final Exception e) { throw new SpringBatchLightminApplicationException("Could not stop Job"); } } JobExecutionFeService(final RegistrationBean registrationBean, final JobServerService jobServerService); ContentPageModel<List<JobExecutionModel>> getJobExecutionModelPage(final String applicationInstanceId,
                                                                              final String jobName,
                                                                              final Integer startIndex,
                                                                              final Integer pageSize); JobExecutionDetailsModel getJobExecutionDetailsModel(final Long jobExecutionId,
                                                                final String applicationInstanceId); void restartJobExecution(final Long jobExecutionId, final String applicationInstanceId); void stopJobExecution(final Long jobExecutionId, final String applicationInstanceId);  }
@Test public void testStopJobExecution() { final LightminClientApplication applicationInstance = new LightminClientApplication(); when(this.registrationBean.findById(APPLICATION_INSTANCE_ID)).thenReturn(applicationInstance); this.jobExecutionFeService.stopJobExecution(JOB_EXECUTION_ID, APPLICATION_INSTANCE_ID); verify(this.jobServerService, times(1)) .stopJobExecution(JOB_EXECUTION_ID, applicationInstance); }
@Test(expected = SpringBatchLightminApplicationException.class) public void testStopJobExecutionError() { final LightminClientApplication applicationInstance = new LightminClientApplication(); when(this.registrationBean.findById(APPLICATION_INSTANCE_ID)).thenReturn(applicationInstance); doThrow(new RuntimeException("Test Exception")).when(this.jobServerService).stopJobExecution(JOB_EXECUTION_ID, applicationInstance); this.jobExecutionFeService.stopJobExecution(JOB_EXECUTION_ID, APPLICATION_INSTANCE_ID); verify(this.jobServerService, times(1)) .stopJobExecution(JOB_EXECUTION_ID, applicationInstance); }